overthesun / simoc-sam

Live backend for SAM at Biosphere 2
2 stars 1 forks source link

Reimplement the mesh setup using NetworkManager #107

Open ezio-melotti opened 3 months ago

ezio-melotti commented 3 months ago

It should be possible to reimplement the mesh setup using only NetworkManager instead of BATMAN. BATMAN should be more efficient and scale better, but for our use case with only a few devices NM might be enough.

It should look something like:

[connection]
id=mesh
uuid=xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx
type=wifi
interface-name=wlan0
permissions=

[wifi]
mode=mesh
ssid=sam-mesh
band=bg
channel=6

[wifi-security]
key-mgmt=wpa-none

[ipv4]
method=auto

[ipv6]
method=ignore

Currently we are already using NetworkManager for the other network configurations:

If we manage to configure the mesh network using NetworkManager too, it will greatly simplify the setup/teardown needed for the automation:

It is also possible to configure static IPs, and if needed it should be possible to use NetworkManager with BATMAN.

ezio-melotti commented 3 months ago

One attempt has been made using the following .nmconnection file and commands:

[connection]
id=mesh
uuid=268a2552-5a3f-4729-94e5-a307559ebe9e
type=wifi
interface-name=wlan0
autoconnect=true
autoconnect-priority=100

[wifi]
mode=adhoc
ssid=sam-mesh

[wifi-security]
key-mgmt=none

[ipv4]
method=manual
address1=172.27.0.10/24,172.27.0.1

[ipv6]
method=ignore

[proxy]
# Create the bat0 interface
sudo ip link add name bat0 type batadv

# Bring up the bat0 interface
sudo ip link set bat0 up

# Bring up the wlan0 interface
sudo ip link set wlan0 up

# Add wlan0 to the batman-adv mesh network
sudo batctl if add wlan0
sudo systemctl restart NetworkManager
sudo nmcli connection up mesh
nmcli connection show mesh
# set channel to 1
sudo nmcli connection modify mesh wifi.band bg
sudo nmcli connection modify mesh wifi.channel 1
sudo nmcli connection modify mesh wifi-sec.key-mgmt none

This didn't quite work, as it complains about password/encryption being required even if they shouldn't be.

I also tried:

sudo nmcli connection modify mesh wifi.mode mesh

Which gave a different error:

Error: Connection activation failed: No suitable device found for this connection (device eth0 not available because profile is not compatible with device (mismatching interface name)).

Note that these commands affect the .nmconnection file. In particular, band and channel can be added there too.