A question about onInit function #6420
Replies: 1 comment
-
Posted at 2020-05-31 by @MaBecker Well I guess you did wifi.save() in the past, so your wifi config is saved. Boot process: If there is a Posted at 2020-05-31 by @allObjects Use same pattern for lines 96 and 97 as you use for mqtt: pack them in the connected event for wifi... you may need to keep track of the things that have successfully initialized / connected and need not to be initialized / connected again. Posted at 2020-06-02 by RajaNandSharma @MaBecker Nope, I haven't saved the credentials at any point in time nor I have a .wificfg in the storage. Posted at 2020-06-02 by @MaBecker
Ok, as long as you connected to power, wifi connection is still up. Posted at 2020-06-06 by RajaNandSharma @MaBecker Yes exactly. It disconnects when I switch off my router. But again when I switch it on, NodeMCU magically reconnects to it, and I am not able to understand how. Posted at 2021-01-27 by user124651 Figured I'd drop a note here in case someone else wondered about this: WiFi on ESP8266 is managed by the ESP8266's SDK. Arduino and Espruino are essentially "remote controlling" the chip's built-in functionality by sending AT commands that tell it what to do. You can see these commands in the JavaScript source for Espruino's Wifi library. With that in mind, one of the features of the ESP8266 SDK is that it automatically reconnects to networks after a connection drops. It's mentioned here in the Arduino documentation for the ESP8266. |
Beta Was this translation helpful? Give feedback.
-
Posted at 2020-05-31 by RajaNandSharma
Hello there,
I have written a piece of code that fetches base64 encoded images from the web and displays on a 128x64 OLED (Web2OLED)
And following is the piece of code:
I upload this to the board and save it (using save()).
Now I am under the assumption that the code inside onInit is only executed once (and not looped).
The weird thing that's happening is that when I turn off/on my WiFi router(after the NodeMCU is connected to the WiFi), it automatically tries to reconnect to the WiFi.
But you can see above that nowhere there is a loop that checks for WiFi disconnect event. The setTimeout will only work as long as it is switched on for the first time and is not able to connect to the WiFi.
After it has connected to the WiFi the control should not go to the if block where setTimeout is called.
Please help me understand this (I am a newbie to Espruino, please let me know if I have missed out something very trivial 😊)
Thanks
Beta Was this translation helpful? Give feedback.
All reactions