Resin wifi-connect reset best practice?


#1

Hello, I would like to know what is the best practice to reset the WIFI credentials using resin wifi-connect?

Usually, I have 1 internal wifi adapter and once this is setup, I cannot reset to hotspot mode anymore. How I do it is: Connect to Ethernet LAN internet and delete the config files manually using SSH.
The other option I do is: I have a flask server running bound to 0.0.0.0. So this means I have to look up the IP inside resin of the connected device and execute the reset using my flask server, but this is not available option when I am not connected (credentials of wifi changed).

I would be happy to hear best practices of using resin-wifi connect. Thanks!


#3

You may reset WiFi credentials by re-running WiFi Connect for a second time when you need it. If you choose the same network, you may use a different passphrase. You may leave unused old connection profiles without problem. Please, let me know whether this answers your question.

You may check our example start script here for various conditions for running WiFi Connect: https://github.com/resin-io/resin-wifi-connect/blob/master/scripts/start.sh


#5

Hi, but the problem is, if you don’t have internet, how can you change the passphrase :slight_smile: or other information, because the wifi is locked to the one from the beginning.


#6

Right, you may detect whether the device is connected to a WiFi network from your application (e.g. by executing iwgetid -r and checking its exit status), and then launch wifi-connect from your application the device is not connected.


#8

Thats what I am doing. But the problem is. Lets says the user changes his password, same SSID.
This would mean that iwgetid -r is true, but I don’t get internet to change the password.

if [ $? -eq 0 ]; then
    printf 'Skipping WiFi Connect\n'
else
    printf 'Starting WiFi Connect\n'
    cd /usr/src/app/wificonnect && ./wifi-connect
fi

I would like to have something like, check every X seconds if a USB stick has been inserted with a keyfile and then reset wiif-connect or something.

My ideal solution I think would be having a second wifi usb dongle with a static ip having a reset button to trigger resin wifi connect. My problem here again, I don’t get predicitive interface names with resin, even with udev, sometimes onboard, sometimes usb wifi dongle gets initialized first, with udev.


#9

If the password for the network is changed, the device will not be able to connect to it, and thus the iwgetid -r check will trigger wifi-connect. Once wifi-connect is launched, it will create it’s AP and the user may connect to it using his phone or laptop. Or maybe I am not understanding you correctly?


#10

Ye, the problem is with that. Let says the device is placed in a store. At night electricity is switched off and at the morning it is switched on. The router needs 5 min to start. The iot device needs 1 min => goes to hotspot mode. Which I dont want.

If you just check for any connection info in networkmanager system connections available at start (on/offline), you lose capability to get back into hotspot mode. Thats why I was asking for a best practice. Thanks!


#11

Good point. I recommend using the --activity-timeout command line argument for this purpose. wifi-connect will exit when a user does not connect to the access point after the given number of seconds.