[riot-notifications] [RIOT-OS/RIOT] cpu/esp32: esp_wifi netdev driver (#10762)

Gunar Schorcht notifications at github.com
Sun Jan 13 18:13:56 CET 2019


### Contribution description

Event though this netdev driver was already part of the initial PR for ESP32, it was in an experimental state and officially not supported.

This PR fixes a lot of problems and makes the driver operational. ESP32 can now be used with infrastructure mode WiFi. If the router of the LAN is an IPv6 capable and  provides a global routing prefix, EPS32 get global connectivity.

The PR contains the following changes in detail:

- Fix of a serious memory leak. The buffer given by the WiFi driver has to be freed explicitly. Otherwise the `esp_wifi_netdev` stops working after some seconds.
- Fix of frame size handling. Although the MTU is 1500, it used `uint8_t` for transmitted and received frames before.
- Automatic reconnect after disconnect. If WiFi is disconnected, e.g., because of timeout for beacon frame, it is tried to reconnect automatically.
- Static WiFi configuration. The WiFi configuration has to be static to avoid memory access problems when WiFi AP is reconnected.
- Registration of RX callback. RX callback function should be registered when WiFi has been connected to AP successfully and should be unregistered when WiFi disconnects from AP.
- Call of `wifi_connect` in event handler. Before function wifi_connect is executed, starting the WiFi driver should have been finished. This is indicated by the WiFi driver by sending event `SYSTEM_EVENT_STA_START`. Function `wifi_connect` is moved therefore to the event handler for `SYSTEM_EVENT_STA_START`.
- Fix of handling `NETOPT_IS_WIRED`. Although `esp_wifi` is a wireless interface, it returned `true` instead of `false`.
- Fix of handling `NETOPT_LINK_CONNECTED`. `esp_wifi` was simply returning the connection state instead of filling the referenced value.
- Fix of event types in event handler.
- Improvement of some debug messages.

### Testing procedure

- Compile and flash `example/gnrc_networking` to at least one ESP32 node using your AP configuration, e.g.,
    ```
    CFLAGS='-DCONFIG_WIFI_STA_SSID=\"<your SSID>\" -DCONFIG_WIFI_STA_PASSWORD=\"your passphrase\"' USEMODULE="esp_wifi" make BOARD=esp32-wroom-32 -C examples/gnrc_networking flash
    ```
- Once the application is flashed connect the ESP32 node with any terminal programm with a default baudrate of 115.200 bps. You should be able to observe an output as follows:
   ```
    I (1885949) [      wifi]: mode : sta (30:ae:a4:41:60:f8)
    I (1885950) [     event]: system_event_sta_start_handle_default
    I (1885958) [main_trampoline]: main(): This is RIOT! (Version: 2018.10-RC1-947...)
    RIOT network stack example application
    All up, running the shell now
    >
    I (1888371) [      wifi]: n:8 0, o:1 0, ap:255 255, sta:8 0, prof:1
    I (1890036) [      wifi]: state: init -> auth (b0)
    I (1890045) [      wifi]: state: auth -> assoc (0)
    I (1890121) [      wifi]: state: assoc -> run (10)
    I (1890143) [      wifi]: connected with <your SSID>, channel 8
    I (1890144) [      wifi]: pm start, type: 1
    I (1890144) [     event]: system_event_sta_connected_handle_default
    ```
- Ping any host in your LAN.
- If your router provides a global routing prefix, check with `ifconfig` that the prefix is set.
You can view, comment on, or merge this pull request online at:

  https://github.com/RIOT-OS/RIOT/pull/10762

-- Commit Summary --

  * cpu/esp32: fixes frame size handling in esp_wifi
  * cpu/esp32: fixes NETOPT_IS_WIRED in esp_wifi
  * cpu/esp32: fixes NETOPT_LINK_CONNECTED in esp_wifi
  * cpu/esp32: use static WiFi config in esp_wifi
  * cpu/esp32: fixes serious memory leak in esp_wifi
  * cpu/esp32: move wifi_connect to event handler
  * cpu/esp32: improved debug message in esp_wifi
  * cpu/esp32: registration of RX callback in esp_wifi
  * cpu/esp32: automatic reconnect after disconnect
  * cpu/esp32: fix of event types in esp_wifi

-- File Changes --

    M cpu/esp32/esp-wifi/esp_wifi_netdev.c (101)
    M cpu/esp32/esp-wifi/esp_wifi_netdev.h (4)

-- Patch Links --

https://github.com/RIOT-OS/RIOT/pull/10762.patch
https://github.com/RIOT-OS/RIOT/pull/10762.diff

-- 
You are receiving this because you are subscribed to this thread.
Reply to this email directly or view it on GitHub:
https://github.com/RIOT-OS/RIOT/pull/10762
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.riot-os.org/pipermail/notifications/attachments/20190113/d1e7b481/attachment-0001.html>


More information about the notifications mailing list