- My goal is: To reconfigure WiFi credentials without having to reboot. The use case here is that the WiFi credentials were initially misconfigured (wrong password, for example), and I would like the end user to be able to correct the password without rebooting the device. The configuration is done through Bluetooth, so I don’t want the bonding between device and user to be broken.
- My actions are: I’ve tried two methods. Each begins with setting the new credentials with
mgos_sys_config_set_wifi_sta_ssid()
andmgos_sys_config_set_wifi_sta_pass()
. I’ve tried (1) callingmgos_wifi_disconnect()
and thenmgos_wifi_connect()
, and (2) trying to reset the WiFi sta like so:
struct mgos_config_wifi_sta sta_config = {
.enable = true,
.ssid = ssid,
.pass = pass,
};
mgos_wifi_disconnect();
if (mgos_wifi_setup_sta(&sta_config)) {
mg_rpc_send_responsef(ri, "ok");
} else {
mg_rpc_send_responsef(ri, "couldn't set up sta");
}
where ssid
and pass
are the new SSID and password, respectively.
3. The result I see is: I’m still connecting to the same network. Trying to set an incorrect password, for example, will not disconnect me from the AP.
4. My expectation & question is: I expect to be able to smoothly change WiFi creds while the device is running without any restarts. Is this possible?
Thanks!