mirror of
https://github.com/RIOT-OS/RIOT.git
synced 2024-12-29 04:50:03 +01:00
cpu/esp32: registration of RX callback in esp_wifi
RX callback function should be register when WiFi has been connected to AP successfully and should be unregistered when WiFi disconnects from AP. Therefore, esp_wifi_internal_reg_rxcb is called now in event handler on event SYSTEM_EVENT_STA_CONNECTED. It is reset now on event SYSTEM_EVENT_STA_DISCONNECTED.
This commit is contained in:
parent
f4cacc1e24
commit
90e9c95c30
@ -122,18 +122,28 @@ static esp_err_t IRAM_ATTR _esp_system_event_handler(void *ctx, system_event_t *
|
||||
|
||||
case SYSTEM_EVENT_STA_CONNECTED:
|
||||
DEBUG("%s WiFi connected\n", __func__);
|
||||
|
||||
/* register RX callback function */
|
||||
esp_wifi_internal_reg_rxcb(ESP_IF_WIFI_STA, _esp_wifi_rx_cb);
|
||||
|
||||
_esp_wifi_dev.connected = true;
|
||||
_esp_wifi_dev.event = SYSTEM_EVENT_ETH_CONNECTED;
|
||||
_esp_wifi_dev.netdev.event_callback(&_esp_wifi_dev.netdev, NETDEV_EVENT_ISR);
|
||||
|
||||
break;
|
||||
|
||||
case SYSTEM_EVENT_STA_DISCONNECTED:
|
||||
DEBUG("%s WiFi disconnected from ssid %s, reason %d\n", __func__,
|
||||
event->event_info.disconnected.ssid,
|
||||
event->event_info.disconnected.reason);
|
||||
|
||||
/* unregister RX callback function */
|
||||
esp_wifi_internal_reg_rxcb(ESP_IF_WIFI_STA, NULL);
|
||||
|
||||
_esp_wifi_dev.connected = false;
|
||||
_esp_wifi_dev.event = SYSTEM_EVENT_ETH_DISCONNECTED;
|
||||
_esp_wifi_dev.netdev.event_callback(&_esp_wifi_dev.netdev, NETDEV_EVENT_ISR);
|
||||
|
||||
break;
|
||||
|
||||
default:
|
||||
|
Loading…
Reference in New Issue
Block a user