Adhoc wifi network

Hi all,

I had a Adhoc wifi network functioning great before they added Network-Manager on top of WPA_Supplicant and so trying to re-learn how to do everything. Has anyone had success getting a Adhoc network setup with network-manager at all?

I’m currently placing this in a file in system-connections (how I’ve been configuring my balena nodes to put up access points - different file obv which works great). So trying to understand what’s wrong with this file, if I can get it working with this then I’ll script it with the Python API for Nwtwork Manager

I’ve tried:
With/Without Security
With/Without Static IP
With/Without band specification


[connection]
id=ADHOCPI
type=wifi
autoconnect=false
permissions=

[wifi]
mac-address-blacklist=
mode=adhoc
ssid=ADHOCPI

[wifi-security]
key-mgmt=wpa-psk
psk=1234567890

[ipv4]
address1=10.42.1.1/24
dns-search=
method=shared

I’ve noticed on the Arch linux wiki page the following note: NetworkManager does not support WPA encryption in ad-hoc mode. Could be the reason. I do not have personally experience with setting up an ad-hoc type of network.

@majorz Thanks for the reply!

I’ve tried without security as well - no luck. Was wondering if there’s any requirements from Balena side that they might not accept a network without security?

Will making the device act as an access point with DNS/DHCP enabled be also suitable for your use case? Can you please provide more details about the purpose.

No, I can’t be reliant on a single node hence using adhoc. I have a bunch of pis on drones that communicate over adhoc wifi network. I’m trying to use Balena as easy way of managing the whole swarm but network is proving difficult

ideas?

Hi r4space,

Did you manage to get this concept working?

I am also thinking about using an adhoc solution to collect the sensor data from multiple RPi without a need of a ready Wifi infrastructure. A Wifi adhoc can also extend the collection coverage. However, I don’t know if Balena.io is a suitable system for this concept.

@r4space @vbtdung

Here are two examples with using an Ad-Hoc network, which I verified they are working on two devices connected with each other.

First one is with static IP (you need to change 192.168.2.1 to 192.168.2.2 on the second device):

[connection]
id=Ad-Hoc
uuid=291b2424-9f8c-3d32-bae0-fd5e2c831e68
type=802-11-wireless

[802-11-wireless]
ssid=Ad-Hoc
mode=adhoc

[ipv4]
method=manual
address1=192.168.2.1/24,0.0.0.0

[ipv6]
method=ignore

After this you may ping both of those devices from each other.

Another way is with a local-link method:

[connection]
id=Ad-Hoc
uuid=291b2424-9f8c-3d32-bae0-fd5e2c831e68
type=802-11-wireless

[802-11-wireless]
ssid=Ad-Hoc
mode=adhoc

[ipv4]
method=link-local

[ipv6]
method=ignore

You may also use method=auto on one of the devices, but then you will need to run a DHCP service (e.g. dnsmasq) on the other device, so that IP addresses are assigned.

1 Like

Thanks @majorz!

In the end I got it working with python dbus so here’s another method for anyone looking!

Hi majorz and rspace,
Thank you for your comments! It is a very useful information for me.

Hi @r4space

I’m trying to develop the same application as you. Bunch of drones and Pis.
Do you have an updated link for the example you posted? It seems to be offline.

Thank you!

Hi

Uh try it again, seems to be online for me
https://gitlab.com/r4space/balena_networking/blob/master/src/pi3_networking.py

It didn’t work. Maybe the repo is private?

Apologies, I forgot this repo was private - open now

Thank you!

When I try to run your project I get the following error:

dbus.exceptions.DBusException: org.freedesktop.DBus.Error.FileNotFound: Failed to connect to socket /host/run/dbus/system_bus_socket: No such file or directory

Have you had the same issue?

Hey @rezenders

Do you have the supervisor label io.balena.features.dbus, described here: https://www.balena.io/docs/reference/supervisor/docker-compose/#labels ?

I don’t …

Never used labels before. Is it possible to set up labels when using just balena push in local mode?
Without docker-compose.yml?

I guess I can push the image then ssh into the board and run
balena run -it --rm --volume "/run/dbus:/host/run/dbus:rw" local_image_adhoc_net

Hi again,

If you aren’t running a multicontainer set of services (ie. you’re only balena pushing with a Dockerfile), then you shouldn’t need to set these labels. Attempting to run containers manually on the device is not at all recommended, as the Supervisor accounts for all containers/images that it knows about, and by running these manually you may have extremely unexpected results.

You should be able to SSH into your single running container and see something similar to the following:

root@2e9f783:/simple-server-node# ls -l /host/run/dbus/system_bus_socket
srw-rw-rw- 1 root root 0 May 22 13:53 /host/run/dbus/system_bus_socket

If you don’t, could you possibly share your Dockerfile with us so we can try and mimic what you’re seeing as closely as possible?

Best regards. Heds

Hello,

For now, I’m just trying to reproduce what @r4space did. I was able to do so using the --volume option. Now I can see something like:

root@7717b8805929:/# ls -l /host/run/dbus/system_bus_socket
srw-rw-rw- 1 root root 0 May 22 13:53 /host/run/dbus/system_bus_socket

My next step will be developing my own application that makes use of the ad_hoc net.

Thank you everyone.