Update: Fixed….. missing counter increment filled up Flash – I’ve asked Zeroday (the author of the ESP8266 if he can have a look at putting checks in to stop overflow.
I was beginning to think my new TCP/IP listener was the cause of being unable to even delete a file – but no.. Same issue with a fresh board.
If you’re into playing with the Lua Interpreter try this..
Put a new copy of the Interpreter on your board – so brand new, nothing else in there.
This is an attempt to write 3 variables into a file… then to read the file into a temporary place (as you can’t open 2 files at once)… and while doing that, amend one of the values.
Then delete the file and re-write it with the variable set… hence we get non-volatile variables.
Zeroday has suggested a better way – write to a second file and point to the one last updated – that’s a great idea and I’ll implement that later– but not until we get to the bottom of why this failed SPECTACULARLY.
Not only does it bomb, but even after a reboot you can’t re-run that or any other file operation – it needs the board to be reflashed. SURELY that should not happen in an interpreted environment.
So—here’s the code – please by all means test or comment on – or better yet, tell me I’ve done something wrong because that’s easier no doubt than an operating system fault? Once this is working (please…) I’ll publish a version using 2 files and an explanation of how to create and maintain non-volatile variables. What do you want those for? Example: simply App that turns a light on and off – do you REALLY want to forget it’s state after a reboot?
while x~=nil do
if items[counter]==newitem then values[counter]=newvalue .. “\n” end
while items[counter]~=nil do
file.writeline(items[counter] .. “=” .. values[counter])