Wi-Fi Auto Reconnect

Does Zephyr support automatic reconnection of the Wi-Fi if a connection is lost?  I can't find any documentation on this, or code examples.  It seems like every example connects to WiFi on boot, and doesn't have any provision to retry it if the connection is lost (e.g.- if the Access Point goes down due to a power glitch).

I can write my own handler that gets triggered by the connection lost event, but I'm hoping there is something built into Zephyr, or a best-practices example somewhere.

Parents
  • Hi Glen,

    There should be support for automatic connections, you can for instance see here. Though adding this yourself using the disconnect event also works. Glad to hear that you are also using a workqueue for this.

    Did you see any issues with reconnection before adding this though? Or when using any default samples. I agree that I can't seem to find anything public regarding best-practices for this.

    Regards,

    Elfving

  • Hi Elfving,

    You are right, the automatic reconnect works even if I remove the code to reconnect from the disconnect event handler.

    I saw the automatic connect feature but assumed it didn't apply to our code for two reasons.  First, we are not using the Wi-Fi Credentials library and connect using an SSID and password that we manage separately.  And second, the documentation talks about automatic connection which I interpreted as just the initial connection, not reconnection after a loss of connection.

    I guess that explains why I couldn't find any real discussion about this.  It just works, without any extra code, and even if you connect more directly without the credentials library.

    Thanks,

    Glen

Reply
  • Hi Elfving,

    You are right, the automatic reconnect works even if I remove the code to reconnect from the disconnect event handler.

    I saw the automatic connect feature but assumed it didn't apply to our code for two reasons.  First, we are not using the Wi-Fi Credentials library and connect using an SSID and password that we manage separately.  And second, the documentation talks about automatic connection which I interpreted as just the initial connection, not reconnection after a loss of connection.

    I guess that explains why I couldn't find any real discussion about this.  It just works, without any extra code, and even if you connect more directly without the credentials library.

    Thanks,

    Glen

Children
No Data
Related