-
My goal is:
Allow user to change wifi ssid and password using WebUI when the GPIO0 is pushed -
My actions are:
Add- origin: https://github.com/mongoose-os-libs/wifi-setup-web-ui
in the mos.yml lib section -
The result I see is:
The WebUI works as expected, and then the AP is disabled -
My expectation & question is:
After push the GPIO 0 (zero, or any other), the AP is up again and the user can change the wifi SSID and password
Have a look at the provision library.
1 Like
I use the following to turn AP on and off.
Took me a while to work out that the device config ap state does not change when you turn AP on/off, so I’m doing it explicitly. Probably means that this is not the right way to do it
static void enable_ap(void)
{
struct mgos_config_wifi_ap ap_cfg;
memcpy(&ap_cfg, mgos_sys_config_get_wifi_ap(), sizeof(ap_cfg));
ap_cfg.enable = true;
int result = mgos_wifi_setup_ap(&ap_cfg);
// Seems to be the easiest way to track AP enabled/disabled but it's not
// updated when the AP is turned on like your would expect
mgos_sys_config_set_wifi_ap_enable(true);
LOG(LL_INFO, ("Enabling AP"));
}
static void disable_ap(void)
{
struct mgos_config_wifi_ap ap_cfg;
memcpy(&ap_cfg, mgos_sys_config_get_wifi_ap(), sizeof(ap_cfg));
ap_cfg.enable = false;
int result = mgos_wifi_setup_ap(&ap_cfg);
// Seems to be the easiest way to track AP enabled/disabled but it's not
// updated when the AP is turned on like your would expect
mgos_sys_config_set_wifi_ap_enable(false);
LOG(LL_INFO, ("Disabling AP"));
}
1 Like
Thanks for this suggestion. I will investigate it.
This is also a good suggestion. I will consider.
mos latest seems to have broken something here, but mos 2.19.1 is working for me
core dump log:
0x40103707 in esp32_wifi_set_mode (mode=WIFI_MODE_NULL)
at /home/mongoose/deps/wifi/src/esp32/esp32_wifi.c:221
221 *((int *) 123) = 456;
#0 0x40103707 in esp32_wifi_set_mode (mode=WIFI_MODE_NULL)
at /home/mongoose/deps/wifi/src/esp32/esp32_wifi.c:221
#1 0x401037c8 in esp32_wifi_remove_mode (mode=<optimized out>)
at /home/mongoose/deps/wifi/src/esp32/esp32_wifi.c:285
#2 0x4010400c in mgos_wifi_dev_ap_setup (
cfg=0x3ffb6330 <mgos_task_stack+7736>)
at /home/mongoose/deps/wifi/src/esp32/esp32_wifi.c:458
#3 0x4010233d in mgos_wifi_setup_ap (cfg=0x3ffb6330 <mgos_task_stack+7736>)
at /home/mongoose/deps/wifi/src/mgos_wifi.c:220
#4 mgos_wifi_setup_ap (cfg=0x3ffb6330 <mgos_task_stack+7736>)
at /home/mongoose/deps/wifi/src/mgos_wifi.c:212
#5 0x400d7a6c in disable_ap ()
at /home/mongoose/src/main.c:1565
#6 0x400dab03 in mgos_app_init ()
at /home/mongoose/src/main.c:3136
#7 0x400d2d0a in mgos_init () at /mongoose-os/src/mgos_init.c:29
#8 0x400daf22 in mgos_init2 ()
at /home/mongoose/deps/freertos/src/mgos_freertos.c:169
#9 0x400823cb in mgos_task (arg=0x0)
at /home/mongoose/deps/freertos/src/mgos_freertos.c:180
I’d suggest to open an issue against the wifi library.
The line *((int *) 123) = 456;
was introduced by this commit.