-
Notifications
You must be signed in to change notification settings - Fork 2.1k
cpu/esp32: esp_wifi netdev driver #10762
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Conversation
@TimoRoth Might be interesting for you 😉 |
Indeed. I wonder, would this work in parallel with ESP-NOW? |
@TimoRoth Theoretically yes, since ESP-NOW is using Vendor Action Frames which are management frames that can be transmitted/received in parallel to an association a station has to an AP. However, the implementation does not support it at the moment. The reason is that each module has its own WiFi initialization. While Trying If it is possible to use |
@TimoRoth BTW, I have a working |
@TimoRoth Good news, I had success with a modified version of your border router that is working with |
We kind of gave up on esp8266 after the majority of our devices turned into unflashable bricks within weeks of experimenting with them, but having more feature support for them is definitely nice. Being able to use a single ESP32 board as border router would definitely be amazing. I'm wondering a bit what the advantage of ESP-NOW would be though, as there does not seem to be a massively reduced power draw over a normal WiFi connection. I'll give this all a test run soon! |
The advantage of using GNRC and RPL over ESP-NOW would be that you can span a mesh network without having access to the AP from all nodes. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
code wise this looks pretty much okay and ready to go, however we really need some testing on this one: @MrKevinWeiss and @MichelRottleuthner can you give it quick try, our working group AP should distribute an IPv6 ULA prefix (fd..
something) so you can use that for testing.
merge #10766 before this one |
I can do some testing later in the week, pretty busy now... |
@smlng Thank you for your review. Let's hope that we get merged it in short term. |
@gschorcht are you trying to get this in the release? |
I'm not sure, even though it was there it was not supported officially til now. But it would be an enhancement if ESP32 could communicate using an infrastructure mode WiFi. |
Either way I should be able to do some testing tomorrow morning and ask @jia200x to get the other PR in. I know lots of people are interested in this! |
I was able to flash but every second or two I get Here is a bit more info:
|
I am pretty sure it's me, I think the router is ipv4 only. I will try more tomorrow... |
@MrKevinWeiss Thank you for trying 😄 Once the ESP32 can establish an association with the AP and can pass the authentication, it doesn't matter for link local IPv6 communication whether the router provides a global routing prefix or not. Since the IPv6 link local address From your log, I can see that your problem is definitely that your ESP32 node cannot establish the association to the AP. If it could establish an association but the authentication fails, your log would looks like as follows:
Please double check your |
The size of received and transmitted frames was stored in an uint8_t, which did not allow to process frames larger than 255 octets. However, WiFi has an MTU of 1500 octets.
esp_wifi returns false now.
esp_wifi was simply returning the connection state instead of filling the referenced value.
The WiFi configuration has to be static to avoid memory access problems when WiFi AP is reconnected.
The buffer given by the WiFi driver as parameter eb has to be freed explicitly. Otherwise the esp_wifi_netdev stops working after some seconds.
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.
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.
If WiFi is disconnected, e.g., because of timeout for beacon frame, it is tried to reconnect automatically.
To avoid further inconsistencies in documentation, README.md is not provided any longer
Fixes sporadic blocking of the wifi thread in esp_wifi_recv_cb function under heavy network load conditions when frames are coming in faster than they can be processed. Since esp_wifi_recv_cb function is not executed in interrupt context, the msg_send function used for ISR event can block when the message queue is full. With this change esp_wifi can be flooded with icmpv6 packets of maximum size without any problems over hours.
ESP-IDF heap handling has to be used for esp_wifi for stability reasons. Otherwise, heap is corrupted sporadically
a22e0a5
to
5bb05f0
Compare
@MrKevinWeiss @smlng Thanks for your support |
Contribution description
Even 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 IPv6 capable and provides a global routing prefix, EPS32 gets global connectivity.
The PR contains the following changes in detail:
esp_wifi_netdev
stops working after some seconds.uint8_t
for transmitted and received frames before.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 eventSYSTEM_EVENT_STA_START
. Functionwifi_connect
is moved therefore to the event handler forSYSTEM_EVENT_STA_START
.NETOPT_IS_WIRED
. Althoughesp_wifi
is a wireless interface, it returnedtrue
instead offalse
.NETOPT_LINK_CONNECTED
.esp_wifi
was simply returning the connection state instead of filling the referenced value.Testing procedure
example/gnrc_networking
to at least one ESP32 node using your AP configuration, e.g.,ifconfig
that the prefix is set.sudo ping6 fe80::<IID> -Ieth0 -s1392 -i 0.0001
should be stable over hours.Issues/PRs references
This PR depends on PR #10766