As the title says... Chat on...

User avatar
By linuxslate.com
#59065 I am trying to implement a simple "Factory Reset" by copying some master settings files over the files that contain the current settings.

I am using the script from the NodeMCU Documentation (https://nodemcu.readthedocs.io/en/maste ... ject-model)

It is an exact cut and past, except inside a function where the filenames are passed in.

The problem is that it seems to be "stuck" in Basic mode.

A handle to file.open("filename", "r") only returns a boolean, never a handle.

For example:

Code: Select allprint(file.open("index.html","r"))


Returns true as long as index.html exists.

I have tried things such as:

Code: Select allf = {}
f = file.open("index.html","r")


but it still turns f back into a boolean.

Help appreciated.
User avatar
By marcelstoer
#59089
linuxslate.com wrote:file.open("filename", "r") only returns a boolean, never a handle


You do have a firmware version that actually contains this feature, right?

-> https://github.com/nodemcu/nodemcu-firmware/releases
User avatar
By linuxslate.com
#59091
You do have a firmware version that actually contains this feature, right?


I guess I do not.

I used the On-Line Build Tool, and that does not allow you to access user_config.h, so I think I am stuck with one open file at a time (no object model).

I came up with a work around that is fine for my project:

Instead of copying a master over the active files, I simply set all the settings (variables) to the defaults, and then call the script that saves the settings.

Some of these are the HTML files that allow the user to see the settings, so now if someone wants to change the user interface, they have to change code, too, which is not desirable, but it is acceptable.

I'll look into actually building a firmware at some point.

Thanks for the replies, and it looks like we already helped someone else with the same question.