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?