1. My goal is:
Call a callback after trying to connect to wifi network
2. My actions are:
I set a callback for the ip_aquired event from wifi lib:
mgos_event_add_handler(MGOS_WIFI_EV_STA_IP_ACQUIRED, connection_successed_cb, ri);
3. The result I see is:
the net lib (from mongoose-os core) and the wifi lib (from mongoose-os-libs) triggers the same event
[Oct 17 21:56:05.161] mgos_wifi.c:136 WiFi STA: Connected, BSSID 00:1a:3f:97:c5:da ch 1 RSSI -46
[Oct 17 21:56:05.161] mgos_net.c:89 WiFi STA: connected
[Oct 17 21:56:09.106] ip:10.0.0.105,mask:255.255.255.0,gw:10.0.0.1
[Oct 17 21:56:09.106] main.c:30 callback here
[Oct 17 21:56:09.106] main.c:30 callback here
4. My expectation & question is:
Why this happens and how to prevented?
So far I descovered that, both lib (net and wifi) set theirs event base with the same order:
#define MGOS_WIFI_EV_BASE MGOS_EVENT_BASE('W', 'F', 'I')
#define MGOS_EVENT_GRP_WIFI MGOS_WIFI_EV_BASE
enum mgos_wifi_event {
MGOS_WIFI_EV_STA_DISCONNECTED =
MGOS_WIFI_EV_BASE, /* Arg: mgos_wifi_sta_disconnected_arg */
MGOS_WIFI_EV_STA_CONNECTING, /* Arg: NULL */
MGOS_WIFI_EV_STA_CONNECTED, /* Arg: mgos_wifi_sta_connected_arg */
MGOS_WIFI_EV_STA_IP_ACQUIRED, /* Arg: NULL */
MGOS_WIFI_EV_AP_STA_CONNECTED, /* Arg: mgos_wifi_ap_sta_connected_arg */
MGOS_WIFI_EV_AP_STA_DISCONNECTED, /* Arg: mgos_wifi_ap_sta_disconnected_arg */
};
#define MGOS_EVENT_GRP_NET MGOS_EVENT_BASE('N', 'E', 'T')
enum mgos_net_event {
MGOS_NET_EV_DISCONNECTED = MGOS_EVENT_GRP_NET,
MGOS_NET_EV_CONNECTING,
MGOS_NET_EV_CONNECTED,
MGOS_NET_EV_IP_ACQUIRED,
};
But I don’t see how this interferes since the EVENT_BASEs differ.
I found this issue when trying to configure a captive portal using tripflex/captive-portal-wifi-stack