Skip to content
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

Add event callbacks to wifi.sta.config() and wifi.ap.config() and more #1903

Merged
merged 3 commits into from
May 21, 2017

Conversation

dnc40085
Copy link
Contributor

@dnc40085 dnc40085 commented Apr 5, 2017

Add feature requested in issue #1131.

  • This PR is for the dev branch rather than for master.
  • This PR is compliant with the other contributing guidelines as well (if not, please describe why).
  • I have thoroughly tested my contribution.
  • The code changes are reflected in the documentation at docs/en/*.

This PR adds the functionality requested in issue #1131, add optional callbacks to wifi.sta.connect() and wifi.sta.disconnect(). The option to register event callbacks as part of the Station/SoftAP configuration process has also been implemented.

Added option to register event callbacks during configuration of both
station and AP.
Added option to register event callbacks to `wifi.sta.connect()` and
`wifi.sta.disconnect()`
Other minor changes to wifi documentation are also included
@@ -1143,7 +1144,8 @@ Sets SSID and password in AP mode. Be sure to make the password at least 8 chara
- `save` save configuration to flash.
- `true` configuration **will** be retained through power cycle. (Default)
- `false` configuration **will not** be retained through power cycle.
- Event callbacks will only be available if `WIFI_SDK_EVENT_MONITOR_ENABLE` is enabled in `user_config.h`
- Event callbacks will only be available if `WIFI_SDK_EVENT_MONITOR_ENABLE` is uncommented in `user_config.h`
- Please note: To ensure all SoftAP events are handled at boot time, all relevant callbacks must be registered as early as possible in `init.lua` with either `wifi.ap.config()` or `wifi.eventmon.register()`.
Copy link
Collaborator

@TerryE TerryE Apr 8, 2017

Choose a reason for hiding this comment

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

One comment about this. The way this reads, the cb's are optional, which they are technically, but I feel that we should add a caveat to the effect that:

Application developers​ should not assume that the WiFi is connected at any time during initialization start-up. This should be validated either by using a wifi event callback or by polling the status on a timer.

Or words to that effect.

@marcelstoer marcelstoer added this to the 2.1 follow-up milestone May 15, 2017
@marcelstoer marcelstoer merged commit 169cb69 into nodemcu:dev May 21, 2017
@dnc40085 dnc40085 deleted the dev_wifi_connect_cb branch May 24, 2017 14:20
eiselekd pushed a commit to eiselekd/nodemcu-firmware that referenced this pull request Jan 7, 2018
nodemcu#1903)

* Add event callbacks to wifi.sta.config() and wifi.ap.config() and more

Added option to register event callbacks during configuration of both
station and AP.
Added option to register event callbacks to `wifi.sta.connect()` and
`wifi.sta.disconnect()`

* Add note about event registration to wifi module documentation

Other minor changes to wifi documentation are also included

* Add more detail to documentation for wifi.sta.config()
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants