src/app/esp8266-rtos/sdk_src/main/interface.c
static void wifi_sta_event_handler(void* arg, esp_event_base_t event_base,
                                int32_t event_id, void* event_data)
{
    if (event_base == WIFI_EVENT) {
        switch (event_id) {
            case WIFI_EVENT_STA_START:
                esp_wifi_connect();
                break;
            case WIFI_EVENT_STA_DISCONNECTED:
                if (retry_num < 0) {
                    esp_wifi_connect();
                    break;
                }
                if (retry_num) {
                    esp_wifi_connect();
                    --retry_num;
                    break;
                }
                xEventGroupSetBits(wifi_event_group, WIFI_FAIL_BIT);
                break;
        }
    } else if (event_base == IP_EVENT) {
        if (event_id == IP_EVENT_STA_GOT_IP) {
            // ip_event_got_ip_t* event = (ip_event_got_ip_t*) event_data;
            // char *ipaddr = ip4addr_ntoa(&event->ip_info.ip));
            xEventGroupSetBits(wifi_event_group, CONNECTED_BIT);
        }
    }
}
// -1 retries forever, otherwise retry if nonzero and decrement
1 retries forever, otherwise retry if nonzero and decrement
1 retries forever otherwise retry if nonzero and decrement
static void wifi_sta_event_handler(void* arg, esp_event_base_t event_base,
                                int32_t event_id, void* event_data)
{
    if (event_base == WIFI_EVENT) {
        switch (event_id) {
            case WIFI_EVENT_STA_START:
                esp_wifi_connect();
                break;
            case WIFI_EVENT_STA_DISCONNECTED:
                if (retry_num < 0) {
                    esp_wifi_connect();
                    break;
                }
                if (retry_num) {
                    esp_wifi_connect();
                    --retry_num;
                    break;
                }
                xEventGroupSetBits(wifi_event_group, WIFI_FAIL_BIT);
                break;
        }
    } else if (event_base == IP_EVENT) {
        if (event_id == IP_EVENT_STA_GOT_IP) {
            xEventGroupSetBits(wifi_event_group, CONNECTED_BIT);
        }
    }
}
static void wifi_sta_event_handler ( void * arg , esp_event_base_t event_base , int32_t event_id , void * event_data ) { if ( event_base == WIFI_EVENT ) { switch ( event_id ) { case WIFI_EVENT_STA_START : esp_wifi_connect ( ) ; break ; case WIFI_EVENT_STA_DISCONNECTED : if ( retry_num < 0 ) { esp_wifi_connect ( ) ; break ; } if ( retry_num ) { esp_wifi_connect ( ) ; -- retry_num ; break ; } xEventGroupSetBits ( wifi_event_group , WIFI_FAIL_BIT ) ; break ; } } else if ( event_base == IP_EVENT ) { if ( event_id == IP_EVENT_STA_GOT_IP ) { xEventGroupSetBits ( wifi_event_group , CONNECTED_BIT ) ; } } }
1 retries forever, otherwise retry if nonzero and decrement
1 retries forever otherwise retry if nonzero and decrement
// ip_event_got_ip_t* event = (ip_event_got_ip_t*) event_data; // char *ipaddr = ip4addr_ntoa(&event->ip_info.ip));