Page 10 of 11

Re: RPi + Runeaudio +Wifi as Accesspoint

PostPosted: 21 Oct 2016, 07:24
by Runebeginner
Thank you for the reply!

I actually did modify that file and added the code
Code: Select all
    // start AP if configured and no IP is assigned
    if (FALSE === $redis->hGet('AccessPoint', 'enabled')) {
        $redis->hSet('AccessPoint', 'enabled', 0);
    }
    if (FALSE === $redis->hGet('AccessPoint', 'ip-address')) {
        $redis->hSet('AccessPoint', 'ip-address', '192.168.1.1');
    }
    if (FALSE === $redis->hGet('AccessPoint', 'broadcast')) {
        $redis->hSet('AccessPoint', 'broadcast', '192.168.1.255');
    }
    if (FALSE === $redis->hGet('AccessPoint', 'ssid')) {
        $redis->hSet('AccessPoint', 'ssid', 'RuneAudioAP');
    }
    if (FALSE === $redis->hGet('AccessPoint', 'passphrase')) {
        $redis->hSet('AccessPoint', 'passphrase', 'RuneAudio');
    }
    if (FALSE === $redis->hGet('AccessPoint', 'dhcp-range')) {
        $redis->hSet('AccessPoint', 'dhcp-range', '192.168.1.2,192.168.1.254,24h');
    }
    if (FALSE === $redis->hGet('AccessPoint', 'dhcp-option')) {
        $redis->hSet('AccessPoint', 'dhcp-option', 'option:dns-server,192.168.1.1');
    }
    if (FALSE === $redis->hGet('AccessPoint', 'enable-NAT')) {
        $redis->hSet('AccessPoint', 'enable-NAT', 0);
    }
    if ($redis->hGet('AccessPoint', 'enabled') === '1') {
       runelog('------------------ try to start AP if no IP is assigned ---------------------');
       $got_one_IP = false;
       if (!empty($active_nics)) {
          foreach($active_nics as $nic) {
             if (($nic === "wlan0") && (sysCmd('ip address show dev '.$nic.' | grep inet | wc -l')[0] !== '0')) {
                runelog('########### got one IP for nic: '.$nic);
                $got_one_IP = true;
             }
          }
       }
       if ($got_one_IP === false) {
          runelog('########### no IP => start AP on wlan0');
          sysCmd('systemctl stop netctl-auto@wlan0');
          // change AP name
          $file = '/etc/hostapd/hostapd.conf';
            $newArray = wrk_replaceTextLine($file, '', 'ssid=', 'ssid='.$redis->hGet("AccessPoint", "ssid"));
            $fp = fopen($file, 'w');
            $return = fwrite($fp, implode("", $newArray));
            fclose($fp);
          // change passphrase
          $file = '/etc/hostapd/hostapd.conf';
            $newArray = wrk_replaceTextLine($file, '', 'wpa_passphrase=', 'wpa_passphrase='.$redis->hGet("AccessPoint", "passphrase"));
            $fp = fopen($file, 'w');
            $return = fwrite($fp, implode("", $newArray));
            fclose($fp);
          sysCmd('systemctl start hostapd');
          // change dhcp-range
          $file = '/etc/dnsmasq.conf';
            $newArray = wrk_replaceTextLine($file, '', 'dhcp-range=', 'dhcp-range='.$redis->hGet("AccessPoint", "dhcp-range"));
            $fp = fopen($file, 'w');
            $return = fwrite($fp, implode("", $newArray));
            fclose($fp);
          // change dhcp-option
          $file = '/etc/dnsmasq.conf';
            $newArray = wrk_replaceTextLine($file, '', 'dhcp-option=', 'dhcp-option='.$redis->hGet("AccessPoint", "dhcp-option"));
            $fp = fopen($file, 'w');
            $return = fwrite($fp, implode("", $newArray));
            fclose($fp);
          sysCmd('systemctl start dnsmasq');
          sysCmd('ip addr add '.$redis->hGet("AccessPoint", "ip-address").'/24 broadcast '.$redis->hGet("AccessPoint", "broadcast").' dev wlan0');
          if ($redis->hGet('AccessPoint', 'enable-NAT') === '1') {
             sysCmd('iptables -t nat -A POSTROUTING -o eth0 -j MASQUERADE');
             sysCmd('iptables -A FORWARD -m conntrack --ctstate RELATED,ESTABLISHED -j ACCEPT');
             sysCmd('iptables -A FORWARD -i wlan0 -o eth0 -j ACCEPT');
             sysCmd('sysctl net.ipv4.ip_forward=1');
          }
       }
    }
    // start AP end


before the code
Code: Select all
    // end - unlock the scan system
    runelog('--------------------------- unlock the scan system ---------------------------');
    $redis->Set('lock_wifiscan', 0);
    // colse Redis connection
    $redis->close();


I want to say that I followed all those steps including updating firmware but something has gone wrong. The Pie is supposed to use the built in wifi (I don't have an external dongle).

When I ran the command,
Code: Select all
hostapd -d /etc/hostapd/hostapd.conf


I noticed there are some error messages in the output code:
Code: Select all
nl80211: Failed to enable Probe Request frame reporting in AP mode
rfkill: initial event: idx=0 type=1 op=0 soft=0 hard=0
nl80211: Add own interface ifindex 3 (ifidx_reason -1)


and
Code: Select all
nl80211: Failed to enable Probe Request frame reporting in AP mode
rfkill: initial event: idx=0 type=1 op=0 soft=0 hard=0
nl80211: Add own interface ifindex 3 (ifidx_reason -1)
nl80211: if_indices[16]: 3(-1)


and
Code: Select all
wlan0: Could not connect to kernel driver
wlan0: Deauthenticate all stationswlan0: Could not connect to kernel driver
wlan0: Deauthenticate all stations


Could that have some effect?

Re: RPi + Runeaudio +Wifi as Accesspoint

PostPosted: 21 Oct 2016, 07:56
by Runebeginner
Thank you for your reply! It seems like my last post dissapeard.

I actually did edit:
Code: Select all
nano /var/www/command/refresh_nics


and added the code before the mentioned line.

I noticed some errors in the output from running:
Code: Select all
hostapd -d /etc/hostapd/hostapd.conf


Code: Select all
Failed to create interface mon.wlan0: -95 (Operation not supported)
nl80211: Driver does not support monitor interface type - try to run without it


Code: Select all
nl80211: Failed to enable Probe Request frame reporting in AP mode


Code: Select all
wlan0: Could not connect to kernel driver


Could those be affecting?

Re: RPi + Runeaudio +Wifi as Accesspoint

PostPosted: 21 Oct 2016, 09:32
by hondagx35
Hi Runebeginner,

running redis-cli hgetall AccessPoint gives:
1) "enabled"
2) "1"

So the code from refresh_nics was not executed or is faulty.

The output has to look like this:
Code: Select all
redis-cli hgetall AccessPoint
 1) "enabled"
 2) "1"
 3) "ip-address"
 4) "192.168.1.1"
 5) "broadcast"
 6) "192.168.1.255"
 7) "ssid"
 8) "RuneAudioAP"
 9) "passphrase"
10) "RuneAudio"
11) "dhcp-range"
12) "192.168.1.2,192.168.1.254,24h"
13) "dhcp-option-dns"
14) "192.168.1.1"
15) "dhcp-option-router"
16) "192.168.1.1"
17) "enable-NAT"
18) "0"


Frank

Re: RPi + Runeaudio +Wifi as Accesspoint

PostPosted: 21 Oct 2016, 10:53
by Runebeginner
Thank you Frank!

Something must have gotten wrong with the file when I edited it and added the text. I copied your file from the zip-file and replaced it (using winscp) and after rebooting the pi it works.

Now I just need to learn how to make the whole build "read only" to prevent the file system on the SD card getting corrupted due to powerloss.

Re: RPi + Runeaudio +Wifi as Accesspoint

PostPosted: 21 Oct 2016, 13:46
by Runebeginner
Before enabling the AP, Music playback works. The AP is working and enabled now, I can connect to it from my phone. When I play a file the player hangs. The user interface is not accessible through local web or a client. Trying to reboot system from putty and there it stops at "a stop job is running for Music player daemon". Reinstalled again and started over but get the same thing with another Micro SD card :(

Re: RPi + Runeaudio +Wifi as Accesspoint

PostPosted: 21 Oct 2016, 14:13
by hondagx35
Hi Runebeginner,

the AP feature is tested by many users (also with RP3) and it works like it should.
Where is your music stored?
Are you using ethernet to connect to your music library?

Frank

Re: RPi + Runeaudio +Wifi as Accesspoint

PostPosted: 21 Oct 2016, 14:21
by Runebeginner
I know, something is wrong with MY setup.

The Music is located on a Kingston usb memory (16 gigabyte) attached to the raspberry pi. I tried with the Ethernet Cable plugged in, not plugged in, with my router on only, with my routher and Cable pluggged in, with only the PI and its Rune AccessPoint on. Same stalling when playing a song, just after a few seconds.

Re: RPi + Runeaudio +Wifi as Accesspoint

PostPosted: 21 Oct 2016, 20:05
by Runebeginner
After enabling the Access Point (having it configured but not necessarily running) and unoplugging the ethernet cable,the player hangs after a few seconds has been played of a song.

Re: RPi + Runeaudio +Wifi as Accesspoint

PostPosted: 21 Oct 2016, 21:18
by hondagx35
Hi Runebeginner,

did you choose the same subnets for ethernet and AP?
If so, please use an other for your AP.

Sorry, but i have no idea what is going wrong on your setup.
I did a test with my RP2, USB SSD and a EDIMAX dongle.
Works with and without ethernet plugged in.

Frank

Re: RPi + Runeaudio +Wifi as Accesspoint

PostPosted: 21 Oct 2016, 21:30
by Runebeginner
I have finally got it working. I don't know how because I did it the same way over and over again.

I don't have the USB memory stick connected now though and only put 2 songs on the Micro SD card. Off to a good start!

Thank you so much for your help! Hurry up and make a backup of the Micro sd card now....