ThingPulse / esp8266-weather-station-color

ESP8266 Weather Station in Color using ILI9341 TFT 240x320 display
https://thingpulse.com/product/esp8266-wifi-color-display-kit-2-4/
MIT License
569 stars 222 forks source link

Properties file ? #146

Closed Greece2 closed 2 years ago

Greece2 commented 2 years ago

The example software tries to load the settings from a file named "/application.properties". As this file is not present, the hardcoded properties from settings.h are used. How should the file "/application.properties" look like if one would want to create this file ? To keep with the 8.3 standard, a naming like "properties.txt" would be better anyway. Examples welcome ! Thanks in advance ...

marcelstoer commented 2 years ago

The file is created by our App Fairy.. We blogged about how it does what it does and why it does so. In short:

The solution – rather our solution – to this bootstrapping problem is to write the user configuration into a file on the host computer. Subsequently, when the user flashes the application to the device the App Fairy also writes the configuration file to the device. Finally, when the application boots it will read that file and apply its configuration. The question is:

How to transfer a file from host computer to ESP8266/ESP32?

For NodeMCU-based applications there’s e.g. NodeMCU-Tool. Likewise, for MicroPython there’s e.g. MicroPython Tool. However, for ESP-IDF or Arduino-based applications the firmware SDKs don’t really have any built-in support for that. While they do support SPIFFS or LittleFS file systems there is no way we know of to interact with them from the host. In short, the only (non-TCP) solution is to build a SPIFFS image on the host and flash it to a defined memory address.

Other Qs:

How should the file "/application.properties" look like if one would want to create this file ?

As the file ending implies it's just a regular properties file with keys & values separated by =. You'll find the expected keys at https://github.com/ThingPulse/esp8266-weather-station-color/blob/master/esp8266-weather-station-color.ino#L740 ff.

To keep with the 8.3 standard, a naming like "properties.txt" would be better anyway.

As for the leading / that's how spiffsgen generates (the files in) the image. As SPIFFS does not support directory structures it uses / as part of the filename to simulate the presence of directories.

Using the non-descript .txt file ending for files that have a specific format/structure would feel odd to us. You wouldn't call a file with JSON content file.txt but rather file.json right?

FYI the Python code in the App Fairy that creates this file is here https://github.com/ThingPulse/app-fairy/blob/master/Main.py#L119