-
• #27
I'm not so sure about the save() call. I would like to use Espruino without wires, also for development. That means I need to store the wifi settings persistently and unaffected by whatever latest sketch I may have loaded. If I have to save() and that changes the wifi settings, then I have to be careful to have all this wifi init boilerplate in every sketch? That's not very appealing, is it?
-
• #28
All I meant was:
WiFi.connect({ ...., connectAtBoot:true}); save();
Not something like:
function onInit() { WiFi.connect({ ...., connectAtBoot:true}, function() { // do my stuff }); } save();
I really don't think that
WiFi.connect
should itself save information to flash - not only is it a massive pain to implement without it also saving all current information to flash, I'm not sure it's all that helpful. -
• #29
OK, I guess it comes down to preference/opinion. Let me try to enumerate why I believe that auto-save should be the default ;-):
- On the esp8266 the default when setting the wifi config is to save it to flash.
- On our laptop, when you associate with an access point it also gets stored and comes up again. You don't say "save this network" explicitly anywhere.
- If you don't auto-save you really have at least two configs, the saved one and the current one, so you really need more functions to set the current, set/save the saved, get the current, and get the saved one.
- The esp8266 actually has a notion of storing multiple network configs, like your laptop, and picking the appropriate one after a scan, but I have not seen code that uses that
- When you have persistent connections the notion of saving becomes a bit odd IMHO: you're saying you want a current connection that is re-established across certain events (such as loosing signal) but erased when certain other events occur (power cycle)? So it's really semi-persistent with some definition for what type of event causes loss of persistence? Boot? Reset? Power-cycle? Which do and which don't?
:-D
- On the esp8266 the default when setting the wifi config is to save it to flash.
-
• #30
My reasoning is it's a lot easier and more platform independent if you save the information into JsVars - but if you do that then you can't just trigger a
save()
when you call connect as you'll blow away existing saved code.Is there some other area of flash in the ESP8266 where the data could be saved? If so then you could store WiFi details in that - it's just that the solution wouldn't be portable to any other device.
I'd suggest
WiFi.connect({ ...., connectAtBoot:true})
or something similar? Then it's not overcomplicating the API.... but I still think you should have to
save()
after you type that in order for it to take effect. It makes the implementation a lot easier as you can then just create aninit
handler for the WiFi that checks for a WiFi config JsVar and does what it suggests.Yes, I think that's sensible. Possible as events on this
WiFi
object?