You are reading a single comment by @Robin and its replies.
Click here to read the full conversation.
-
Sun 2020.02.23
'the possibility I am using the StorageFile API incorrectly'
Were you aware @PiOfThings that it is possible to persue the source. Just R-Click on the arrow just to the Right of the heading
which launches:
https://github.com/espruino/Espruino/blob/master/src/jswrap_storage.c#L427
Descriptive text block there that might provide some insight
I have a problem of mostly my own making. My clock app writes various sensor settings to a log file and I have a python script that I can use to connect to the watch and download this log file (which is split by Bangle).
However, deleting the files via the script doesn't quite have any effect on the files because my app I believe holds on to the file handle and keeps writing to the same file.
To work around this, I put in a watch reboot using
E.reboot()
and this I believe clears the file handle and the files are actually gone for good and after reboot the app restarts and opens a new file handle.Now rebooting is a bazooka where a restart App would just do. If I could invoke a function on the app to tell it to reopen the file, that would be even more precise. Long-pressing BTN3 already does a reload, how can I mimic this via code?
There is also the possibility I am using the StorageFile API incorrectly. There isn't a
StorageFile.close()
orStorage.close()
so I didn't think I would need to close the file after each update and open it before each update.Any suggested approaches welcome. Thanks
Python script for sync
Custom BangleJS App
Update: Reboot actually doesn't work. It leaves the watch storage in an inconsistent state and the app is unable to update the file anymore. Keeps throwing
Uncaught Error: Unable to find or create file
. Basically I have to now invokeStorage.eraseAll()
and start fresh :(I'll have to think of a custom roll-over or something so the older log files are cleared out after it has been synced with a laptop.