Hi all,
Frank, is there a chance you could release some early ‘alpha’ information that a few of us could try?
Yes i can, but it will not work on all devices the same way.
So let us start with Raspberry Pi2 and Pi3 (latest image required)
With this modification Rune starts an AP if no IP is assigned to wlan0 after booting.
A configured WIFI connection will always be tried first and only if it fails the AP starts.
* get access to the console (ssh)
*
check the free space on your sd card (<=85%). If not resize your partition (see documentation)
* update the kernel and firmware (this is needed to get the EDIMAX dongle working and doesn't hurt anyway)
pacman -Sy --force raspberrypi-firmware-bootloader linux-raspberrypi
Edit:
the above doesn't work anymore, use this instead:
pacman -Sy --force raspberrypi-firmware raspberrypi-bootloader linux-raspberrypi
* add "dtparam=audio=on" to your /boot/config.txt
# Uncomment one of these lines to enable an audio interface
#dtoverlay=hifiberry-dac
#dtoverlay=hifiberry-dacplus
#dtoverlay=hifiberry-digi
#dtoverlay=hifiberry-amp
#dtoverlay=iqaudio-dac
#dtoverlay=iqaudio-dacplus
dtparam=audio=on
* delete the file /etc/modules-load.d/ras....conf
* install and check your WIFI dongle
iw list
should show something like this
Wiphy phy0
max # scan SSIDs: 9
max scan IEs length: 2304 bytes
max # sched scan SSIDs: 0
max # match sets: 0
Retry short limit: 7
Retry long limit: 4
Coverage class: 0 (up to 0m)
Supported Ciphers:
* WEP40 (00-0f-ac:1)
* WEP104 (00-0f-ac:5)
* TKIP (00-0f-ac:2)
* CCMP (00-0f-ac:4)
Available Antennas: TX 0 RX 0
Supported interface modes:
* IBSS
* managed
* AP
* monitor
* P2P-client
* P2P-GO
Band 1:
Capabilities: 0x1862
HT20/HT40
Static SM Power Save
RX HT20 SGI
RX HT40 SGI
No RX STBC
Max AMSDU length: 7935 bytes
DSSS/CCK HT40
Maximum RX AMPDU length 65535 bytes (exponent: 0x003)
Minimum RX AMPDU time spacing: 16 usec (0x07)
HT Max RX data rate: 150 Mbps
HT TX/RX MCS rate indexes supported: 0-7, 32
Bitrates (non-HT):
* 1.0 Mbps
* 2.0 Mbps
* 5.5 Mbps
* 11.0 Mbps
* 6.0 Mbps
* 9.0 Mbps
* 12.0 Mbps
* 18.0 Mbps
* 24.0 Mbps
* 36.0 Mbps
* 48.0 Mbps
* 54.0 Mbps
Frequencies:
* 2412 MHz [1] (20.0 dBm)
* 2417 MHz [2] (20.0 dBm)
* 2422 MHz [3] (20.0 dBm)
* 2427 MHz [4] (20.0 dBm)
* 2432 MHz [5] (20.0 dBm)
* 2437 MHz [6] (20.0 dBm)
* 2442 MHz [7] (20.0 dBm)
* 2447 MHz [8] (20.0 dBm)
* 2452 MHz [9] (20.0 dBm)
* 2457 MHz [10] (20.0 dBm)
* 2462 MHz [11] (20.0 dBm)
* 2467 MHz [12] (20.0 dBm)
* 2472 MHz [13] (20.0 dBm)
* 2484 MHz [14] (disabled)
Band 2:
Capabilities: 0x1862
HT20/HT40
Static SM Power Save
RX HT20 SGI
RX HT40 SGI
No RX STBC
Max AMSDU length: 7935 bytes
DSSS/CCK HT40
Maximum RX AMPDU length 65535 bytes (exponent: 0x003)
Minimum RX AMPDU time spacing: 16 usec (0x07)
HT Max RX data rate: 150 Mbps
HT TX/RX MCS rate indexes supported: 0-7, 32
Bitrates (non-HT):
* 6.0 Mbps
* 9.0 Mbps
* 12.0 Mbps
* 18.0 Mbps
* 24.0 Mbps
* 36.0 Mbps
* 48.0 Mbps
* 54.0 Mbps
Frequencies:
* 5170 MHz [34] (20.0 dBm)
* 5180 MHz [36] (20.0 dBm)
* 5190 MHz [38] (20.0 dBm)
* 5200 MHz [40] (20.0 dBm)
* 5210 MHz [42] (20.0 dBm)
* 5220 MHz [44] (20.0 dBm)
* 5230 MHz [46] (20.0 dBm)
* 5240 MHz [48] (20.0 dBm)
* 5260 MHz [52] (20.0 dBm) (radar detection)
DFS state: usable (for 40621 sec)
DFS CAC time: 60000 ms
* 5280 MHz [56] (20.0 dBm) (radar detection)
DFS state: usable (for 40621 sec)
DFS CAC time: 60000 ms
* 5300 MHz [60] (20.0 dBm) (radar detection)
DFS state: usable (for 40621 sec)
DFS CAC time: 60000 ms
* 5320 MHz [64] (20.0 dBm) (radar detection)
DFS state: usable (for 40621 sec)
DFS CAC time: 60000 ms
* 5500 MHz [100] (26.0 dBm) (radar detection)
DFS state: usable (for 40621 sec)
DFS CAC time: 60000 ms
* 5520 MHz [104] (26.0 dBm) (radar detection)
DFS state: usable (for 40621 sec)
DFS CAC time: 60000 ms
* 5540 MHz [108] (26.0 dBm) (radar detection)
DFS state: usable (for 40621 sec)
DFS CAC time: 60000 ms
* 5560 MHz [112] (26.0 dBm) (radar detection)
DFS state: usable (for 40621 sec)
DFS CAC time: 60000 ms
* 5580 MHz [116] (26.0 dBm) (radar detection)
DFS state: usable (for 40621 sec)
DFS CAC time: 60000 ms
* 5600 MHz [120] (26.0 dBm) (radar detection)
DFS state: usable (for 40621 sec)
DFS CAC time: 60000 ms
* 5620 MHz [124] (26.0 dBm) (radar detection)
DFS state: usable (for 40621 sec)
DFS CAC time: 60000 ms
* 5640 MHz [128] (26.0 dBm) (radar detection)
DFS state: usable (for 40621 sec)
DFS CAC time: 60000 ms
* 5660 MHz [132] (26.0 dBm) (radar detection)
DFS state: usable (for 40621 sec)
DFS CAC time: 60000 ms
* 5680 MHz [136] (26.0 dBm) (radar detection)
DFS state: usable (for 40621 sec)
DFS CAC time: 60000 ms
* 5700 MHz [140] (26.0 dBm) (radar detection)
DFS state: usable (for 40621 sec)
DFS CAC time: 60000 ms
* 5745 MHz [149] (disabled)
* 5765 MHz [153] (disabled)
* 5785 MHz [157] (disabled)
* 5805 MHz [161] (disabled)
* 5825 MHz [165] (disabled)
* 5920 MHz [184] (disabled)
* 5940 MHz [188] (disabled)
* 5960 MHz [192] (disabled)
* 5980 MHz [196] (disabled)
* 6000 MHz [200] (disabled)
* 6020 MHz [204] (disabled)
* 6040 MHz [208] (disabled)
* 6060 MHz [212] (disabled)
* 6080 MHz [216] (disabled)
Supported commands:
* new_interface
* set_interface
* new_key
* start_ap
* new_station
* set_bss
* join_ibss
* set_pmksa
* del_pmksa
* flush_pmksa
* remain_on_channel
* frame
* set_channel
* connect
* disconnect
Supported TX frame types:
* IBSS: 0x00 0x10 0x20 0x30 0x40 0x50 0x60 0x70 0x80 0x90 0xa0 0xb0 0xc0 0xd0 0xe0 0xf0
* managed: 0x00 0x10 0x20 0x30 0x40 0x50 0x60 0x70 0x80 0x90 0xa0 0xb0 0xc0 0xd0 0xe0 0xf0
* AP: 0x00 0x10 0x20 0x30 0x40 0x50 0x60 0x70 0x80 0x90 0xa0 0xb0 0xc0 0xd0 0xe0 0xf0
* AP/VLAN: 0x00 0x10 0x20 0x30 0x40 0x50 0x60 0x70 0x80 0x90 0xa0 0xb0 0xc0 0xd0 0xe0 0xf0
* P2P-client: 0x00 0x10 0x20 0x30 0x40 0x50 0x60 0x70 0x80 0x90 0xa0 0xb0 0xc0 0xd0 0xe0 0xf0
* P2P-GO: 0x00 0x10 0x20 0x30 0x40 0x50 0x60 0x70 0x80 0x90 0xa0 0xb0 0xc0 0xd0 0xe0 0xf0
Supported RX frame types:
* IBSS: 0xd0
* managed: 0x40 0xd0
* AP: 0x00 0x20 0x40 0xa0 0xb0 0xc0 0xd0
* AP/VLAN: 0x00 0x20 0x40 0xa0 0xb0 0xc0 0xd0
* P2P-client: 0x40 0xd0
* P2P-GO: 0x00 0x20 0x40 0xa0 0xb0 0xc0 0xd0
software interface modes (can always be added):
* monitor
interface combinations are not supported
Device supports scan flush.
The interesting part is:
Supported interface modes:
* IBSS
* managed
* AP
* monitor
* P2P-client
* P2P-GO
We are looking for AP mode.
* install haveged
pacman -S haveged
systemctl enable haveged
* install hostapd and dnsmasq
pacman -S hostapd dnsmasq
* edit /etc/hostapd/hostapd.conf
nano /etc/hostapd/hostapd.conf
# interface and driver
interface=wlan0
driver=nl80211
# WIFI-Config
ssid=RuneAudioAP
channel=7
hw_mode=g
wmm_enabled=1
auth_algs=1
max_num_sta=10
# WIFI authorization
wpa=2
wpa_key_mgmt=WPA-PSK
wpa_pairwise=TKIP CCMP
rsn_pairwise=CCMP
wpa_passphrase=RuneAudio
* edit /etc/dnsmasq.conf
nano /etc/dnsmasq.conf
# DHCP-Server for WIFI-Interface
interface=wlan0
# exclude DHCP-Server for ethernet
no-dhcp-interface=eth0
# IPv4 address-range and lease-time
dhcp-range=192.168.1.2,192.168.1.254,24h
# DNS
dhcp-option=option:dns-server,192.168.1.1
The IP settings here are only dummy values. They get overwritten by the settings from database (see below)
* modify /var/www/command/refresh_nics
nano /var/www/command/refresh_nics
and add this
// 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
// end - unlock the scan system
runelog('--------------------------- unlock the scan system ---------------------------');
$redis->Set('lock_wifiscan', 0);
// colse Redis connection
$redis->close();
at the end of that file.
* enable the AccessPoint
redis-cli hset AccessPoint enabled 1
* if you like you can also enable NAT to connect wifi and ethernet
redis-cli hset AccessPoint enable-NAT 1
* reboot and enjoy the AP
This is tested with:
- EDIMAX EW-7811UN
- D-LINK DWL-G122
- RP3 integrated wifi
The default values are:
- SSID = RuneAudioAP
- KEY = RuneAudio
- DHCP = 192.168.1.2 - 192.168.1.254
- IP (Pi) = 192.168.1.1
All settings are stored in redis as "AccessPoint", so it will be easy to setup a settings page on Rune.
redis-cli hgetall AccessPoint
root@runeaudio(rw):~# 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"
14) "option:dns-server,192.168.1.1"
15) "enable-NAT"
16) "1"
You can enable or disable the AP with:
redis-cli hset AccessPoint enabled 1
redis-cli hset AccessPoint enabled 0
You can enable or disable the NAT mode with:
redis-cli hset AccessPoint enable-NAT 1
redis-cli hset AccessPoint enable-NAT 0
You can try this on all other platforms, but skip updating kernel and firmware.
The EDIMAX EW-7811UN will only work with latest kernel!
Other platforms follow as soon as i made some tests.
- AccessPoint.zip
- (3.68 KiB) Downloaded 1067 times
Edit: NAT functionality added
Edit: changed hostapd.conf
Frank