Wifi-connect over wlan1 instead of wlan0

Hello!

I am running resin-wifi-connect in a Docker container on resinOS, so the executable module is installed during the Dockerfile build and is basically a black box when it shows up on the device.

I’d like to run on wlan1 instead of wlan0, and use the input network credentials to also connect on wlan1. My reason for this is that my Raspberry Pi is enclosed within a metal box, so I must use a USB wifi dongle that is accessed on wlan1. If I could use wlan0 as a fallback when wlan1 is not present, that would be ideal.

Any ideas how to accomplish this?

Thanks.

@dysri Hi, you may use the -i, --portal-interface argument to specify the wlan1 interface:

You may find the list with arguments here: https://github.com/resin-io/resin-wifi-connect/blob/master/docs/command-line-arguments.md

Tha same repository contains all the source code of WiFi Connect as well.

As for using wlan0 if wlan1 is not plugged in, then I think you may check before starting wifi-connect for the existence of wlan1. If it exists then pass wlan1 to --portal-interface, otherwise pass wlan0.

An easy way to check for the existence of wlan1 would be checking the exit code of ip link show wlan1:

ip link show wlan1

interface = $(if [ $? -eq 0 ]; then echo "wlan1"; else echo "wlan0"; fi)

You may take a look at the example start script we provide, which you will need to modify with such code as above according to your needs: https://github.com/resin-io/resin-wifi-connect/blob/master/scripts/start.sh

Please note that wifi-connect currently binds the created connection profile to the device hardware address, not the interface name. That is to say, if you plug another dongle, you will need to create a new profile, even if it shows up as wlan1. This is the default behavior for Desktop Linux systems that use NetworkManager as well.

Please let me know if you have any questions or if you encounter difficulties with setting this up.

1 Like

Thank you, this worked like a charm.