Common configuration
3 minute read
The throttle has the least complex configuration file, all other device build further on this file.
Human readable JSON configuration file
A non working example configuration file looks something like this:
{
"version" : 3,
"hostname" : "CTRL01",
"wifi": { "SSID": "ssid", "password" : "password" },
"loglevel": "DEBUG",
"mqtt" : { "broker" : "mqtt.example.com",
"port" : 1883,
"username" : "<not used>",
"password" : "<not used>",
"ebreakOnDisconnect" : false },
"update" : { "configUrl" : "http://192.168.178.10/esp/config/",
"manifestUrl": "http://192.168.178.10/esp/firmware/manifest",
"firmwareType": "esp32-rr2bricks-rrmaus"},
"OTAPassword" : "<OTAPassword>"
}
Version
The version field contains the current configuration file version, always an integer and 3. The release notes will state if it is compatible and the firmware will not load an unsupported version.
Hostname
The hostname field is the hostname of this ESP, but also the map where the ESP will look for a new configuration on the webserver.
The url where the ESP will search is <configURL>/hostname.
WiFi
The wifi section has two fields:
SSID: the WiFi ssid where the ESP32 has to connect to.password: the WiFi password
Loglevel
loglevel can only have the following values:
DEBUGINFOWARNINGERRORFATAL
mqtt
For the mqtt section the following fields must be defined:
broker: the name or IP address of the mqtt brokerport: the port number where the broker is listening tousername: the username, not yet usedpassword: the password, not yet used
update
All fields in update are optional, but is recommended to use them, it makes updating configurations and firmware quite easy.
The checks are done at boot time of the ESP32.
The configuration is is ESP hostname based, the base url is configured in configUrl the firmware is looking in configUrl hostname for updates in the configuration. If the sha-256 sum is different than the one stored on the EPS32 it will download this version and reboot to make the new configuration take effect.
The manifestUrl is the file where the EPS32 is looking for the latest firmware version, if it finds a newer one for the correct firmwareType it will download this version and reboot.
OTAPassword
The firmware also supports OTA updates, for this reason the OTAPassword is used, tit needs to be the same as the one used in the upload software (VSCode in this case.)
Generate configuration files for the ESP32
The JSON configuration file, generates three file, when convert_config_json2bin.py is called.
python ./convert_config_json2bin.py --src=./config/config.json --dest=./data
Note:
The data directory is not (yet) created../data/config: binary configuration file;./data/config.sha255: the sha256 sum of the config file, needed to check at the ESP32 if the file has changed;./data/hostname: the hostname of the ESP32