-
Notifications
You must be signed in to change notification settings - Fork 5
Configuration
There is lots that can be configured in Frugal-IoT, and several places it is possible to do so.
Configuration variables are added from multiple places, in a specific order, in most cases changes will be saved between reboots.
-
Any defaults in the code e.g. frugal_iot.addWifi(foo, bar) adds knowledge of the password for the wifi with SSID=foo
-
In PlatformIO there can be a /data directory, which can be written to a node's flash memory. This is one way to configure nodes, and is particularly useful for wifi parameters.
-
From the flash memory's SPIFFs system, it is read during each object's setup for example /frugal_iot/device_name is a one-line file with the name of the device read in System_Frugal::setup /wifi/foo is a one-line file with the password for the wifi with SSID foo, read in WiFi::setup /hysterisis/limit (or maybe /hysterisis/limit/value ) will be the value of the limit for the hysterisis control, read during it's setup
-
From MQTT's saved values, these are sent when the device subscribes to ///set. For example, /dev/developers/esp1234/hysterisis/limit/value. Incoming
setmessages should be written to the SPIFFS indispatchTwig(). -
During configuration a WiFi captive-portal is available on the node, some values can be set there, they are received in a HTTP
POSTand have the same id e.g.hysterisis/limit/value(no leading/). The value is written to the SPIFFS so they are retained for next time. -
When changed in the UX, it is sent to the portal as an MQTT message; the broker saves this value (currently lost during broker restarts). It then goes to the node, next time it is connected. The value is written to the SPIFFS so they are retained for next time.
Note that its possible for outputs to "flash" for example if they are hard-coded as off, the SPIFFS overrides it on, and the MQTT sets it off again, all during startup of the node.
- Values may be set to a default in the code e.g. temperature controls have reasonable min and max
- Values received in the node's discovery message should override these defaults
- At connection time, MQTT messages should send changes previously made by the clients or node
- After connection they will be set live as changes are made on other clients, or the node
For example if you want to add /data/mysensor/myvalue
- Optionally, in PlatformIO, add to your /data/mysensor/myvalue and upload to the node
- Add a call to
sensor_mysensor::setup()toreadConfigFromFS()to read from the SPIFFS - Add code in
sensor_mysensor::dispatchTwigto recognizemyvalueand set the variable. - Optionally add to the portal
To look at values on inputs or outputs eg. sht/temperature/max
- Inputs should TODO-153 recognize values that can be changed - e.g. for INfloat it should recongize min and max
- Check that system_sht::dispatchTwig (or its superclass system_ht::disptachTwig) has the call to
writeConfigToFS(), (this may be done for all sensors at system_base at some point. - Add a
Sensor_Mysensor::captiveLines()method, this will add it to the captive portal - (see System_mqtt.cpp for an example) - Optionally add to the
advertisementso it appears on the client UX (I haven't done this yet).