nodemcu / nodemcu-firmware

Lua based interactive firmware for ESP8266, ESP8285 and ESP32
https://nodemcu.readthedocs.io
MIT License
7.67k stars 3.13k forks source link

WiFi Monitor is always set to channel 1 when started #2433

Closed hugokerstens closed 6 years ago

hugokerstens commented 6 years ago

I'm trying to monitor all different channels using my NodeMCU EPS8266 module. However, I quickly ran into the issue that whatever I tried, the monitored channel was always 1.

Looking into the source code, I found that upon starting the channel is set back to 1.

https://github.com/nodemcu/nodemcu-firmware/blob/8181c3be7aed9f0a0ceb73ac8137c1a519e8a8e9/app/modules/wifi_monitor.c#L651

A workaround is to set the channel after starting the monitor, but that can be quite confusing. Even the provided example in the docs would not work, since the channel there is also set before starting the monitor.

https://nodemcu.readthedocs.io/en/master/en/modules/wifi_monitor/#example

I don't know if the call to wifi_set_channel is needed after changing into monitor mode, otherwise, the line can simply be removed.

Other solutions would be:

pjsg commented 6 years ago

You are absolutley right. The example should show the set channel happening after the call to start the monitor.

I had great difficulty in making the monitoring code work without crashing inside the SDK and I now can't recall whether the setchannel of 1 was necessary or not. I agree that it ought to be specified in the documentation.

Do you want to submit a pull request to fix the documentation?