-
• #2
Never mind, figured it out...
-
• #3
Just for anyone else, you can write functions that get called on
init
andkill
.kill
is called before the reset happens, andinit
happens after.../*JSON{ "type" : "init", "generate" : "jswrap_net_init" }*/ void jswrap_net_init() { } /*JSON{ "type" : "kill", "generate" : "jswrap_net_kill" }*/ void jswrap_net_kill() { }
As part of a reset (various flavors in jsinteractive.c : https://github.com/espruino/Espruino/blob/59bbe375ef16a49088d7e911b4ed6aa8e4d0a22b/src/jsinteractive.c#L1895-L1933) the network variable gets deleted from the hiddenRoot (i.e. the var that gets fetched here https://github.com/espruino/Espruino/blob/59bbe375ef16a49088d7e911b4ed6aa8e4d0a22b/libs/network/network.c#L183). On the esp8266, this variable gets created at boot time ('cause the network exists always). I'm not sure how to re-create it after a reset because jshReset() gets executed too early and so I can't create it there. Suggestions?