@rquant posted a new topic, subject "Resin wifi-connect reset best practice?". It read:

   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 570-786-2317. 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!

Then @majorz (Zahari Petkov) said

    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

@rquant replied

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

So @majorz (Zahari Petkov) replied

    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.

To which @rquant replied

    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.
    [code] 
        if [ $? -eq 0 ]; then
            printf 'Skipping WiFi Connect\n'
        else
            printf 'Starting WiFi Connect\n'
            cd /usr/src/app/wificonnect && ./wifi-connect
        fi
        
    [/code]
    
    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.

Then @majorz (Zahari Petkov) said

    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?

So @rquant replied

    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!

Then @majorz (Zahari Petkov) said

    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.


{'source': 'discourse', 'url': 'https://forums.balena.io/t/resin-wifi-connect-reset-best-practice/3366', 'title': 'Resin wifi-connect reset best practice?', 'views': 693, 'has_accepted_answer': False, 'word_count': 705, 'like_count': 0, 'reply_count': 5, 'participant_count': 2, 'posts': 8, 'tags': '', 'author': '@rquant', 'participants': '@rquant, @majorz (Zahari Petkov)', 'image_url': [None], 'created_at': '2018-06-22T08:27:00.638Z', 'last_posted_at': '2018-06-22T16:26:26.217Z'}