When I use wifi_set_event_handler_cb() while in SOFTAP mode, it works like a charm, but if I try using it on STATION mode, it does not work, I receive no events.
Is it possible to receive wifi connection and dhcp events using something similar to wifi_set_event_handler_cb() when in STATION mode?
[Solved] Is there anything similar to wifi_set_event_handler_cb() that works for STATION mode?
Re: Is there anything similar to wifi_set_event_handler_cb() that works for STATION mode?
Postby ESP_Faye » Tue Dec 22, 2015 11:36 am
Hi,
wifi_set_event_handler_cb can work in station mode.
Here is an example:
wifi_set_event_handler_cb can work in station mode.
Here is an example:
Code: Select all
void wifi_handle_event_cb(System_Event_t *evt)
{
os_printf("event %x\n", evt->event);
switch (evt->event) {
case EVENT_STAMODE_CONNECTED:
os_printf("connect to ssid %s, channel %d\n",
evt->event_info.connected.ssid,
evt->event_info.connected.channel);
break;
case EVENT_STAMODE_DISCONNECTED:
os_printf("disconnect from ssid %s, reason %d\n",
evt->event_info.disconnected.ssid,
evt->event_info.disconnected.reason);
break;
case EVENT_STAMODE_AUTHMODE_CHANGE:
os_printf("mode: %d -> %d\n",
evt->event_info.auth_change.old_mode,
evt->event_info.auth_change.new_mode);
break;
case EVENT_STAMODE_GOT_IP:
os_printf("ip:" IPSTR ",mask:" IPSTR ",gw:" IPSTR,
IP2STR(&evt->event_info.got_ip.ip),
IP2STR(&evt->event_info.got_ip.mask),
IP2STR(&evt->event_info.got_ip.gw));
os_printf("\n");
break;
case EVENT_SOFTAPMODE_STACONNECTED:
os_printf("station: " MACSTR "join, AID = %d\n",
MAC2STR(evt->event_info.sta_connected.mac),
evt->event_info.sta_connected.aid);
break;
case EVENT_SOFTAPMODE_STADISCONNECTED:
os_printf("station: " MACSTR "leave, AID = %d\n",
MAC2STR(evt->event_info.sta_disconnected.mac),
evt->event_info.sta_disconnected.aid);
break;
default:
break;
}
}
void user_init(void)
{
wifi_set_opmode(STATION_MODE);
// TODO: add your own code here....
wifi_set_event_handler_cb(wifi_handle_event_cb);
}
Re: Is there anything similar to wifi_set_event_handler_cb() that works for STATION mode?
Postby doragasu » Tue Dec 22, 2015 3:46 pm
You are right, it works also in station mode! I don't know why but I got the impression it only worked on softap mode.
Thanks a lot for help!
Thanks a lot for help!
Who is online
Users browsing this forum: No registered users and 19 guests
Login
Newbies Start Here
Are you new to ESP8266?
Unsure what to do?
Dunno where to start?
Start right here!
Latest SDK
Documentation
Complete listing of the official ESP8266 related documentation release by ESPRESSIF!
Must read here!
- All times are UTC+08:00
- Top
- Delete all board cookies
About Us
Espressif Systems is a fabless semiconductor company providing cutting-edge low power WiFi SoCs and wireless solutions for wireless communications and Internet of Things applications. We are the manufacturer of ESP8266EX.