Getting rid of onInit() at runtime

Posted on
  • I've got an Espruino WiFi with a telnet connection but no USB (unless I do things I'd rather avoid).
    It's got onInit set with code I want to get rid of and rather replace by an E.setBootCode string.
    The goal is to clean up over wifi and then do an E.reboot.
    I'm not aware of a way to get rid of onInit and all the other objects created at runtime that would put the Espruino in a kind of clean state that would be worth a save().
    Can this be achieved at all?

  • Which version of the Espruino firmware do you have? The way things get saved changed a few versions ago.

    If it's up to date though then everything is saved into a filesystem - if you do require('Storage').list() then you get a list of all the files.

    If you do E.setBootCode(...) then that'll save just the code in the string you supplied. After that, you can remove the other (save()d) file from flash and you'll be sorted.

    If it's an earlier version then literally just calling E.setBootCode should blow away any code that you save()d :)

  • I'm using v1.99. Doing E.setBootCode followed by require('Storage').erase('.varimg') worked. Thanks!

  • Post a reply
    • Bold
    • Italics
    • Link
    • Image
    • List
    • Quote
    • code
    • Preview

Getting rid of onInit() at runtime

Posted by Avatar for Steffen @Steffen