SYSTEM_EVENT_WIFI_READY not invoked

RobinC
Posts: 45
Joined: Sat Feb 04, 2017 5:29 pm

SYSTEM_EVENT_WIFI_READY not invoked

Postby RobinC » Fri Jul 28, 2017 2:39 pm

I was looking for an event that would trigger wifi readiness for a call to esp_wifi_scan_start(). I thought maybe the event SYSTEM_EVENT_WIFI_READY would be useful. Unfortunately, that event doesn't seem to be invoked or used.

Perhaps after esp_wifi_init() returns, the wifi subsystem is ready? Should SYSTEM_EVENT_WIFI_READY be invoked in esp_wifi_init() before it returns?

Robin

User avatar
kolban
Posts: 1683
Joined: Mon Nov 16, 2015 4:43 pm
Location: Texas, USA

Re: SYSTEM_EVENT_WIFI_READY not invoked

Postby kolban » Fri Jul 28, 2017 2:53 pm

Howdy,
My notes seem to say that you should indeed see a SYSTEM_WIFI_READY event. Can you paste your code into pastebin and post a link to the code you are using? Specifically, I want to see how you are registering your event handler and to ensure it is being registered prior to the WiFi initialization.
Free book on ESP32 available here: https://leanpub.com/kolban-ESP32

RobinC
Posts: 45
Joined: Sat Feb 04, 2017 5:29 pm

Re: SYSTEM_EVENT_WIFI_READY not invoked

Postby RobinC » Fri Jul 28, 2017 6:37 pm

The handler is registered before init call. I see the SYSTEM_EVENT_STA_START event (and all of the other events that I should see) but never see the SYSTEM_EVENT_WIFI_READY. The event handler starts like:

Code: Select all

static esp_err_t event_handler(void *ctx, system_event_t *event)
{
    switch(event->event_id) {
    case SYSTEM_EVENT_WIFI_READY:
        ESP_LOGI(TAG, "wifi ready\n");
        break;
    case SYSTEM_EVENT_STA_START:
        ESP_LOGI(TAG, "wifi started\n");
        start_scan_wifi();
        break;
    case SYSTEM_EVENT_STA_STOP:
        ESP_LOGI(TAG, "wifi stopped\n");
        break;
    case SYSTEM_EVENT_STA_GOT_IP: {
        uint8_t mac[6];
        ESP_LOGI(TAG, "wifi got IP\n");
        esp_wifi_get_mac(WIFI_IF_AP, mac);
        ESP_LOGI(TAG, "~~~~~~~~~~~");
        ESP_LOGI(TAG, "WIFIIP:     "IPSTR, IP2STR(&event->event_info.got_ip.ip_info.ip));
        ESP_LOGI(TAG, "WIFIPMASK:  "IPSTR, IP2STR(&event->event_info.got_ip.ip_info.netmask));
        ESP_LOGI(TAG, "WIFIPGW:    "IPSTR, IP2STR(&event->event_info.got_ip.ip_info.gw));
        ESP_LOGI(TAG, "WIFIMAC:    %02x:%02x:%02x:%02x:%02x:%02x",
                 mac[0], mac[1], mac[2], mac[3], mac[4], mac[5]);
        ESP_LOGI(TAG, "~~~~~~~~~~~");
        xEventGroupSetBits(dvair_event_group, WIFI_CONNECTED_BIT);
        break;
    }
    case SYSTEM_EVENT_STA_CONNECTED:
and the logs look like:

Code: Select all

I (572) dvair_wifi: wifi initializing...
I (572) wifi: wifi firmware version: 72ddf26
I (572) wifi: config NVS flash: enabled
I (572) wifi: config nano formating: disabled
I (582) system_api: Base MAC address is not set, read default base MAC address from BLK0 of EFUSE
I (592) system_api: Base MAC address is not set, read default base MAC address from BLK0 of EFUSE
I (622) wifi: Init dynamic tx buffer num: 32
I (622) wifi: Init dynamic rx buffer num: 32
I (622) wifi: wifi driver task: 3ffe8674, prio:23, stack:4096
I (622) wifi: Init static rx buffer num: 10
I (632) wifi: Init dynamic rx buffer num: 32
I (632) wifi: Init rx ampdu len mblock:7
I (632) wifi: Init lldesc rx ampdu entry mblock:4
I (642) wifi: wifi power manager task: 0x3ffe901c prio: 21 stack: 2560
I (642) dvair_wifi: Setting wifi configuration SSID SSID...
I (652) dvair_wifi: wifi initialized
I (662) wifi: wifi timer task: 3ffe94f4, prio:22, stack:3584
I (672) wifi: mode : sta (30:ae:a4:xx:xx:xx)
I (672) dvair_main: wifi started
Robin

User avatar
kolban
Posts: 1683
Joined: Mon Nov 16, 2015 4:43 pm
Location: Texas, USA

Re: SYSTEM_EVENT_WIFI_READY not invoked

Postby kolban » Fri Jul 28, 2017 7:38 pm

I take it back ... I was plain wrong ... apparently we will never see this event ... see:

http://esp-idf.readthedocs.io/en/latest ... wifi-ready
Free book on ESP32 available here: https://leanpub.com/kolban-ESP32

RobinC
Posts: 45
Joined: Sat Feb 04, 2017 5:29 pm

Re: SYSTEM_EVENT_WIFI_READY not invoked

Postby RobinC » Sat Jul 29, 2017 12:21 pm

Great research! I looked through *almost* all of the docs and code... :)

Robin

Who is online

Users browsing this forum: Google [Bot] and 154 guests