homieiot / homie-esp8266

💡 ESP8266 framework for Homie, a lightweight MQTT convention for the IoT
http://homieiot.github.io/homie-esp8266
MIT License
1.36k stars 308 forks source link

Move Config to filesystem #16

Closed furyfire closed 8 years ago

furyfire commented 8 years ago

As the configuration array continues to grow and there is currently very little control validation on the data stored in EEPROM (checksums, lengths etc) would it not be an idea to simply store the json config in the file system? https://github.com/esp8266/Arduino/blob/master/doc/filesystem.md

It would simplify development as the flashtool today can automatically include the file.

Validation of the config file could then be put in a shared module allowing Homie to drop back into config mode if the data is unusable.

We would also retrain backwards compatibility to some extend as the JSON format would be easier to parse with the already included ArduinoJSON lib

Adding an optional setup call, which would default to Homie.setConfig("home/config.json");

marvinroger commented 8 years ago

I completely agree with this. And this would allow the developer to bypass the configuration mode, as this can be annoying if deploying a lot of devices. It will also simplify the API (reserveEeprom and getEepromOffset not needed anymore).

So:

Does it sound good?

enavarro222 commented 8 years ago

Sounds really good !

furyfire commented 8 years ago

And if homie/ota exists boot into ota If the config file is invalid it should boot into config mode with the choice of downloading old config (so we have a future upgrade path)

marvinroger commented 8 years ago

The choice of downloading old config? You can simply send the old json to the /config endpoint. I am not sure I understad what you mean!

furyfire commented 8 years ago

During an upgrade to a newer release of Homie your old config file could become outdated. I was wondering if it would be useful for a GUI configuration tool to download the old config and be able to fix the issues behind the curtain before reapplying it to /config.

marvinroger commented 8 years ago

The config file format won't change that often when we go stable, only on breaking releases. This is an interesting idea for later, though!

marvinroger commented 8 years ago

It's stable on my side, could you please test?

marvinroger commented 8 years ago

Feel free to reopen if something is wrong!