Alternative Wi-Fi Network

Last Updated on : 2023-12-19 08:36:57download

The user might change the Wi-Fi network credentials (SSID and password) regularly for security purposes. Without the alternative Wi-Fi network feature, the user has to pair all smart devices again. The alternative Wi-Fi network feature allows the user to preset multiple sets of Wi-Fi network credentials. When the current Wi-Fi network is unavailable, the device will attempt to connect using one of the preset credentials.

Feature description

  • Add alternative Wi-Fi networks:
    The user adds multiple sets of Wi-Fi network credentials on the mobile app. The added Wi-Fi network credentials will be sent to the device and stored on its flash memory.
  • Switch to an alternative Wi-Fi network:
    • The user proactively switches to an alternative Wi-Fi network.
      The user selects an alternative Wi-Fi network on the mobile app. The mobile app sends the credentials of the selected Wi-Fi network to the device. The device connects to the target Wi-Fi network after receiving the credentials.
    • The device proactively switches to an alternative Wi-Fi network.
      When the current Wi-Fi network is unavailable, the device scans for alternative Wi-Fi networks and connects to an available one.

How it works

AppDeviceUser opens the device network page.Request the currently connected network.Return the currently connected network information.User opens the alternativenetwork setting page.Request alternative network information.Return alternative network information.User sets the alternative network.Initiate key agreement if new alternative network is added.Return the result of the key agreement.Send the alternative network information.Update and save the alternative network settings.Report the current alternative network settings.AppDeviceAdd alternative Wi-Fi network
AppDeviceUser switches to an alternative network.Agree on a key.Return the result of the key agreement.Send the alternative network the user wants to switch to.Scan for access points (APs). Try to connect to the specified AP if it is found.Return the status after the connection attempt. Switched to the alternative network or connected to the previous network.The currently connected network is disconnected.Scan for APs. Sort the APs that match the alternate networks by signal strength.Try to connect to the available alternate networks.A query is sent to the device when the user opens the device network page. The device returns the current network information.AppDeviceSwitch to an alternative network

Development guide

Runtime environment

Open tuya_iot_config.h and check if the following macro is defined.

#define ENABLE_WIFI_PROTECT 1

How to

The alternative Wi-Fi network feature is already integrated into the development framework, eliminating the need for custom development.

FAQs

How many alternative Wi-Fi networks can be added?

Up to three alternative Wi-Fi networks can be added.

Will the device reconnect to the previous network if it fails to switch to an alternative one?

In this case, the device will reconnect to the previous network.