found a bug in esp8266 wifi
found a bug in esp8266 wifi
Not sure if I posted that in correct place, if not please point me where I should report this.
In short I never used micropython on esp8266, so I give it a shot,
going thru the basics, making some init script for wifi, etc.
During testing them I realized, that once wifi Is set for AP mode, It always start AP after that, without being initialized. Or if initialized in station mode, it start AP again. Deleteting all files, unplug and plug device do not change anything, AP is UP and running, can connect to it and ping the device, tested with:
MicroPython v1.18 on 2022-01-17; ESP module with ESP8266
and
MicroPython v1.10-8-g8b7039d7d on 2019-01-26; ESP module with ESP8266
AP stop showing, only when I re-flash device with full erase of flash memory.
tested on 2 esp8266 devices.
In short I never used micropython on esp8266, so I give it a shot,
going thru the basics, making some init script for wifi, etc.
During testing them I realized, that once wifi Is set for AP mode, It always start AP after that, without being initialized. Or if initialized in station mode, it start AP again. Deleteting all files, unplug and plug device do not change anything, AP is UP and running, can connect to it and ping the device, tested with:
MicroPython v1.18 on 2022-01-17; ESP module with ESP8266
and
MicroPython v1.10-8-g8b7039d7d on 2019-01-26; ESP module with ESP8266
AP stop showing, only when I re-flash device with full erase of flash memory.
tested on 2 esp8266 devices.
- pythoncoder
- Posts: 5956
- Joined: Fri Jul 18, 2014 8:01 am
- Location: UK
- Contact:
Re: found a bug in esp8266 wifi
I think this is how it's supposed to work. The ESP8266 stores its configuration in Flash. For example, in station mode on power up it remembers its WiFi credentials and automatically logs in. I don't believe you can make it "forget" other than by erasing flash. I guess AP mode works similarly. I'm pretty sure it can support AP and station mode simultaneously.
This behaviour is a function of the chip and not of MicroPython. It was widely criticised on security grounds: Esspressif evidently took it on board because ESP32 does not do this.
This behaviour is a function of the chip and not of MicroPython. It was widely criticised on security grounds: Esspressif evidently took it on board because ESP32 does not do this.
Peter Hinch
Index to my micropython libraries.
Index to my micropython libraries.
Re: found a bug in esp8266 wifi
No that is not true. The SDK of the esp8266 has two calls to set the wifi configuration. One will store the credentials in flash and one without storing to flash (like the esp32). It was the decision of the developers of MicroPython to choose the one that stores in flash. They could have easily added a extra flag to choose between one of the two but unfortunately they did not. Of course, if you want this you can easily compile you own version and choose the call you want. See the SDK documentation: wifi_station_set_config, and wifi_station_set_config_current, wifi_softap_set_config, wifi_softap_set_config_current.pythoncoder wrote: ↑Fri Feb 11, 2022 5:18 pmI think this is how it's supposed to work. The ESP8266 stores its configuration in Flash. For example, in station mode on power up it remembers its WiFi credentials and automatically logs in. I don't believe you can make it "forget" other than by erasing flash. I guess AP mode works similarly. I'm pretty sure it can support AP and station mode simultaneously.
This behaviour is a function of the chip and not of MicroPython. It was widely criticised on security grounds: Esspressif evidently took it on board because ESP32 does not do this.
- pythoncoder
- Posts: 5956
- Joined: Fri Jul 18, 2014 8:01 am
- Location: UK
- Contact:
Re: found a bug in esp8266 wifi
OK, I stand corrected. I remain puzzled about the adverse comments in the technical press about the security implications, but these were in the early days. Did the SDK change at some point to provide this option?
In any event your best course is probably to raise a ticket against the ESP8266 port. If the firmware were to be changed it should default to the existing mechanism to avoid breaking code.
In any event your best course is probably to raise a ticket against the ESP8266 port. If the firmware were to be changed it should default to the existing mechanism to avoid breaking code.
Peter Hinch
Index to my micropython libraries.
Index to my micropython libraries.
Re: found a bug in esp8266 wifi
bad part is when problem happen, I initialize AP and set it to disable (false), it do not turn off AP, that is not acceptable for me at this point. Guess gonna move to LUA again.
Re: found a bug in esp8266 wifi
Show us your code to disable the AP.
Re: found a bug in esp8266 wifi
nothing special, just tested to see what gonna happen:
Code: Select all
import network
tmp=network.WLAN(network.AP_IF)
tmp.active(False)
Re: found a bug in esp8266 wifi
I've been doing some testing and it all works as expected for me. I'm using version 1.18 of Micropython, '.active(False)' disables the access point and if it's disabled it doesn't reconnect on reboot. If I then reconnect it has remembered the credentials but they are readily changed. You can ensure that the network doesn't reconnect with a couple of lines in boot.py :
Though this obviously requires that '.active(False)' works, which it does for me.
Not sure why you see things differently unless it's down to ESP8266 boards, the one I'm testing on is based on an ESP8266 12F module. Also tested on an ESP8266-01S board with the same results.
Not sure how you are testing for access point connection. I'm using my tablets WiFi 'show networks' option and it can take a good number of refreshes to both show a new connection and a lost one.
Code: Select all
import network
network.WLAN(network.AP_IF).active(False)
Not sure why you see things differently unless it's down to ESP8266 boards, the one I'm testing on is based on an ESP8266 12F module. Also tested on an ESP8266-01S board with the same results.
Not sure how you are testing for access point connection. I'm using my tablets WiFi 'show networks' option and it can take a good number of refreshes to both show a new connection and a lost one.
Re: found a bug in esp8266 wifi
I have changed the esp8266 board and can successful disable wireless now, guess something was happen to old one.
Still the fact that it stores wireless config every time when I initialize wireless is enough not to use micropython on esp8266, after all, writable memory life is limited.
Still the fact that it stores wireless config every time when I initialize wireless is enough not to use micropython on esp8266, after all, writable memory life is limited.