You are reading a single comment by @Vlad and its replies. Click here to read the full conversation.
  • Hi,

    You mean the nRF51822?

    That's not quite the way you'd use storage. You could try:

    var storage = require("Storage");
    print(storage.list());
    

    But I just checked and the 51822 build doesn't have it in, since it's got SAVE_ON_FLASH defined. nRF51 is really tight on flash memory so you can't easily build without.

    You could modify NRF51822.py to remove the debugger and tab complete, then edit jswrap_storage.c to remove all the "ifndef" : "SAVE_ON_FLASH", - but honestly you're going to keep hitting trouble with nRF51 - it's just not really big enough to handle Bluetooth and Espruino

  • Hi @Gordon, thanks for your suggestion to comment out "ifndef" : "SAVE_ON_FLASH", this actually works! I've removed all ifndef statements in the jswrap_storage.c file and also removed 'DEFINES += -DUSE_DEBUGGER -DUSE_TAB_COMPLETE', line in the NRF51822DK.py file. Now I can read/write stuff via Storage lib.

    var storage = require("Storage");
    print("Initial: " + storage.getFree());
    storage.write("MyFile", "Some data");
    print(storage.read("MyFile"));
    print("After storing some data: " + storage.getFree());
    

    This prints:

    >Initial: 3072
    >Some data
    After storing some data: 3044
    

    It seems to me 3072 bytes is more than enough for storing some basic backup data.

    BTW, could you please let me know what are these USE_DEBUGGER and USE_TAB_COMPLETE ? Anything important/useful? Cheers

About

Avatar for Vlad @Vlad started