← index #2620Issue #6969
Off-topic · high · value 0.128
QUERY · ISSUE

RFC: offical API to save WiFi-connection parameter

openby puuuopened 2016-11-11updated 2024-07-19
rfc

After @MarkR42 explained that the automatic storing of the WiFi-connection parameter can wear-out the flash of the ESP8266 many discussions came up: #2510, #2547, #2564 and http://forum.micropython.org/viewtopic.php?f=16&t=2631

This explains the importance of this issue.

In principle, the feature of saving the connection parameter is due to the ESP8266 SDK and strictly speaking not compatible to the existing HW API (https://github.com/micropython/micropython/wiki/Hardware-API#the-wlan-class). But on the other hand it provides a nice user experience. Also @pfalcon explained that this is a common feature in smart phones, computers, … So we have to expect, that the ESP8266 will not be the only device that supports saving of WiFi-connection parameters.
But, this side effects can lead to permanent hardware damage. Thus, we need a way to at least deactivate this feature.

Therefore, we have to find an agreement about the method, default behaviour and API names. That is the reason for this issue.

There are already three different possible methods described:

a) #2510 additional parameter save_to_flash in wlan.connect()
b) https://github.com/micropython/micropython/pull/2510#issuecomment-255714114 additional function esp.persist_wlan(val) which allows the user to turn on/off the feature of saving WiFi settings to flash
c) #2564 additional function esp.save_config() to save configuration to flash on demand

As default behaviour we have the possibilities:

  • wlan.connect() and wlan.active() always save to flash. That will probably lead to permanent hardware damage and is not possible for devices that do not support the saving (e.g. the WiPy board).
  • wlan.connect() and wlan.active() don't always save to flash. This will break the user experience of the ESP8266 users.

What are your comments?

CANDIDATE · ISSUE

esp2866 restart couldn't stop

closedby vidalouiswangopened 2021-02-27updated 2021-03-11
port-esp8266

`
def init():
import net
if net.connect('ssid', 'password'):
print("ok")

init()
`
After running this code, esp8266 will reboot itself(hard reset) won't stop.

net.py:
`
import network
def connect(ssid,password=None):
wlan = network.WLAN(network.STA_IF)
wlan.active(True)
import machine
a = scan(ssid)
if a:
wlan.connect(ssid, password)
while not wlan.isconnected():
machine.idle()
return True

def scan(ssid=None):
wlan = network.WLAN(network.STA_IF)
wlan.active(True)
if ssid:
a = wlan.scan()
for i in a:
if i[0] == bytes(ssid,"ascii"):
return i
else:
return wlan.scan()
`
Need to erase and flash firmware in esptool will recover.

Keyboard

j / / n
next pair
k / / p
previous pair
1 / / h
show query pane
2 / / l
show candidate pane
c
copy suggested comment
r
toggle reasoning
g i
go to index
?
show this help
esc
close overlays

press ? or esc to close

copied