maverick
maverick copied to clipboard
Network: Add wifi hybrid mode
Add a filesystem/SD file flag to boot the system into AP mode. This is useful if normal wifi or network configuration fails for any reason, and particularly useful in the field.
Add a simultaneous managed/AP option, set by default on raspberry
Good guide for the raspberry https://albeec13.github.io/2017/09/26/raspberry-pi-zero-w-simultaneous-ap-and-managed-mode-wifi/
Current wireless modes are managed, monitor and ap. Add a hybrid mode which simultaneously provides managed and ap, and set it by default on sample-nodes (download images) where possible.
Using the raspberry guides involves using udev rules and mac addresses. This is not feasible for distributed images as the mac address is unknown on user systems. Move the config up the stack.
iw phy phy0 interface add wlanap0 type __ap
This produces a 'rename3' interface: 3: rename3: <BROADCAST,MULTICAST> mtu 1500 qdisc noop state DOWN group default qlen 1000
Can use canonical interface name instead of physical:
sudo iw dev wlan0 interface add test1 type __ap
The interface then gets renamed immediately:
May 31 21:40:15 maverick-up kernel: [14008.805210] brcmfmac mmc1:0001:1 rename6: renamed from test1
Refs: https://superuser.com/questions/1272705/wifi-single-radio-acting-as-ap-and-ap-client-simultaneously?utm_medium=organic&utm_source=google_rich_qa&utm_campaign=google_rich_qa http://www.0xf8.org/2016/02/using-your-raspberry-pi-zeros-usb-wifi-adapter-as-both-wifi-client-and-access-point/
iw list shows combinations available for an interface (eg. for rpi3):
valid interface combinations:
* #{ managed } <= 1, #{ P2P-device } <= 1, #{ P2P-client, P2P-GO } <= 1,
total <= 3, #channels <= 2
* #{ managed } <= 1, #{ AP } <= 1, #{ P2P-client } <= 1, #{ P2P-device } <= 1,
total <= 4, #channels <= 1
Need to programatically obtain this list in a python structure so we can expose in -api and start to make decisions and present to the user. Parsing iwlist output is not ideal, try and find better underlying source of data.
Control with python. Need to figure out:
- How to determine which interfaces are capable of what combinations
- How to add virtual interfaces
- How to add virtuals in correct order for useable hybrid mode
Wireless tools provide iwconfig, iwlist etc. Different packages:
- iw (eventual replacement for wireless-tools)
- wireless-tools (iwlist, iwconfig)
- libiw30 (underlying wireless tools library)
- libiw-dev (dev tools for wireless-tools)
Python:
- iwlib
python iwlib doesn't provide anything about combinations. Need to look at the source code for iwlist, and then code it into a new python library. https://github.com/nathan-hoad/python-iwlib/blob/master/iwlib/_iwlib_build.py As a quick hack to start with, we can just parse iwlist
PyRIC contains the mechanisms necessary to extract combinations without any other 3rdparty support, but not the code to do so yet. It's probably the best way long term.
Add 'iw' package to support parsing 'iw list'.
Near impossible to parse iw output, notwithstanding warning from iw: Do NOT screenscrape this tool, we don't consider its output stable.
Instead, use netlink/pyric to extract the combinations in a proper python structure: https://github.com/wraith-wireless/PyRIC/issues/48
Can't get it to work with rpi3. Have to start with managed interface first, then add an AP. Interfaces are created, but don't seem to be useable although the AP shows up in other devices. https://www.raspberrypi.org/forums/viewtopic.php?f=36&t=138730&sid=af012818635ca579a0b0c609ad61e31b&start=150