Skip to content

drivers: wifi: esp32: Add WiFi event information for station connect and disconnect #88519

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

Open
wants to merge 1 commit into
base: main
Choose a base branch
from

Conversation

chirambaht
Copy link

The ESP32's WiFi event information system has now been linked with the Zephyr WiFi events system for station related operations. This allows users of the ESP32 wifi driver to obtain more precise WiFi connection related event information such as incorrect passwords, timeouts and more.

The work presented here was guided by the ESP32's WiFi event documentation provided here: https://docs.espressif.com/projects/esp-idf/en/stable/esp32/api-guides/wifi.html#event-handling.

In order to validate this, I ran the wifi_shell example with the appropriate logging levels for WiFi and passed in various different network credentials to see if the appropriate events were raised with the correct information.

Copy link

Hello @chirambaht, and thank you very much for your first pull request to the Zephyr project!
Our Continuous Integration pipeline will execute a series of checks on your Pull Request commit messages and code, and you are expected to address any failures by updating the PR. Please take a look at our commit message guidelines to find out how to format your commit messages, and at our contribution workflow to understand how to update your Pull Request. If you haven't already, please make sure to review the project's Contributor Expectations and update (by amending and force-pushing the commits) your pull request if necessary.
If you are stuck or need help please join us on Discord and ask your question there. Additionally, you can escalate the review when applicable. 😊

@chirambaht
Copy link
Author

@rodrigopex

@chirambaht chirambaht closed this Apr 14, 2025
@chirambaht chirambaht force-pushed the feature/esp32/wifi/events branch from b911bdc to f8d1d35 Compare April 14, 2025 10:47
@chirambaht chirambaht reopened this Apr 14, 2025
@chirambaht chirambaht force-pushed the feature/esp32/wifi/events branch 2 times, most recently from 9d673d5 to 84f731d Compare April 17, 2025 06:44
@chirambaht chirambaht requested a review from jukkar April 17, 2025 21:05
jukkar
jukkar previously approved these changes Apr 19, 2025
@chirambaht chirambaht force-pushed the feature/esp32/wifi/events branch from 84f731d to 5dc7d84 Compare April 22, 2025 01:21
}

LOG_DBG("Disconnect reason: %d", event->reason);
wifi_mgmt_raise_disconnect_result_event(esp32_wifi_iface, WIFI_REASON_DISCONN_SUCCESS);
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Perhaps you could return the disconnect event value from both calls you created and have this single call here with that value.
In current approach:

  1. wifi_mgmt_raise_disconnect_result_event is being called 2x.
  2. You have multiple calls to wifi_mgmt_raise_disconnect_result_event when you could use a single one.

Would you mind analyzing if the above suggestion is acceptable?

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks for the feedback.

There are two different events being made depending on weather iface is connected to an AP or not. If not connected, the event is a connect event and if it is connected, it's a disconnect event With that in mind, I think two functions could work, but I do agree that there are a lot of wifi_mgmt_raise_disconnect_result_event and wifi_mgmt_raise_connect_result_event calls. I will reduce those.

Would that be a workable solution?

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@sylvioalves I have updated the code to reflect this idea

Added events for when the station iface is used to connect and disconnect.
These events will feed the NET_EVENT_WIFI_CONNECT_RESULT and
NET_EVENT_WIFI_DISCONNECT_RESULT events to send information
to applications making use of them

Signed-off-by: Humphrey Chiramba <[email protected]>
@chirambaht chirambaht requested a review from sylvioalves April 24, 2025 10:55
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
area: Wi-Fi Wi-Fi platform: ESP32 Espressif ESP32
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants