|
LightHub 4.6.0
Open-source smart home controller firmware
|
Persistent system configuration manager. More...
#include <config.h>
Public Member Functions | |
| systemConfig () | |
| Constructs a config manager without a backing storage. | |
| systemConfig (flashStream *fs) | |
| Constructs a config manager over the given flash stream. | |
| bool | isValidSysConf () |
| Checks that the stored config block has a valid signature. | |
| bool | getMAC () |
| Loads the MAC address from flash into the mac member. | |
| String | getMACString () |
| Returns the MAC address of the controller as a hex string. | |
| bool | setMAC (macAddress &mac) |
| Stores the given MAC address into flash. | |
| char * | getMQTTpwd (char *buffer, uint16_t bufLen) |
| Reads the MQTT password from flash into a caller buffer. | |
| bool | setMQTTpwd (char *pwd=NULL) |
| Stores the MQTT password in flash (NULL clears it). | |
| char * | getOTApwd (char *buffer, uint16_t bufLen) |
| Reads the OTA (HTTP update) password from flash. | |
| bool | setOTApwd (char *pwd=NULL) |
| Stores the OTA password in flash (NULL clears it). | |
| bool | setServer (char *url) |
| Stores the URL of the remote configuration server in flash. Falls back to the compile-time MY_CONFIG_SERVER / CONFIG_SERVER when nothing is stored. | |
| char * | getServer (char *buffer, uint16_t bufLen) |
| Reads the stored configuration server URL into a buffer. | |
| bool | getIP (IPAddress &ip) |
| Loads the static IP address from flash. | |
| bool | getMask (IPAddress &mask) |
| Loads the static subnet mask from flash. | |
| bool | getDNS (IPAddress &dns) |
| Loads the static DNS server address from flash. | |
| bool | getGW (IPAddress &gw) |
| Loads the static default gateway address from flash. | |
| bool | setIP (IPAddress &ip) |
| Stores the static IP address in flash. | |
| bool | setMask (IPAddress &mask) |
| Stores the static subnet mask in flash. | |
| bool | setDNS (IPAddress &dns) |
| Stores the static DNS server address in flash. | |
| bool | setGW (IPAddress &gw) |
| Stores the static default gateway address in flash. | |
| bool | setSerialDebuglevel (short) |
| Sets the serial (debug port) log level in flash. | |
| bool | setUdpDebuglevel (short) |
| Sets the UDP (syslog) log level in flash. | |
| uint8_t | getSerialDebuglevel () |
| Returns the stored serial log level. | |
| uint8_t | getUdpDebuglevel () |
| Returns the stored UDP log level. | |
| bool | clear () |
| Wipes the whole config block and restores defaults. | |
| bool | getSaveSuccedConfig () |
| Returns whether a successfully downloaded config is auto-saved. | |
| bool | setSaveSuccedConfig (bool) |
| Enables/disables auto-save of a successfully downloaded config. | |
| bool | getLoadHTTPConfig () |
| Returns whether the config is fetched from the portal over HTTP. | |
| bool | setLoadHTTPConfig (bool) |
| Enables/disables fetching the config from the portal over HTTP (disabled permanently after a local config change). | |
| String | getETAG () |
| Returns the ETag of the current remote config, quoted for HTTP. | |
| bool | setETAG (String etag) |
| Sets the in-memory ETag of the remote config (strips quotes). | |
| bool | saveETAG () |
| Persists the in-memory ETag to flash. | |
| bool | loadETAG () |
| Loads the stored ETag from flash into memory. | |
| bool | getDHCPfallback () |
| Returns whether static-IP-to-DHCP fallback is enabled. | |
| bool | setDHCPfallback (bool flag) |
| Enables/disables static-IP-to-DHCP fallback in flash. | |
| systemConfigFlags | getConfigFlags () |
| Returns the packed system configuration flags from flash. | |
| bool | setConfigFlags (systemConfigFlags flags) |
| Writes the packed system configuration flags to flash. | |
Public Attributes | |
| macAddress | mac |
| MAC address of the controller, kept in memory after load. | |
Persistent system configuration manager.
Reads and writes the fixed-layout system configuration block (see systemConfigData) stored in flash/EEPROM through a flashStream: MAC address, static network parameters, MQTT/OTA passwords, the remote configuration server URL and assorted control flags. It also keeps track of the ETag of the last downloaded remote config, which is sent back as "If-None-Match" so that the portal server can answer 304 (not modified) and skip the download. The full JSON config load/save/submit workflow (HTTP download from MY_CONFIG_SERVER / CONFIG_SERVER, CRC validation, save to flash) is driven from main.cpp via loadConfigFromHttp(), cmdFunctionSave() and cmdFunctionLoad().
|
inline |
Constructs a config manager without a backing storage.
|
inline |
Constructs a config manager over the given flash stream.
| fs | Pointer to the flashStream holding the config block. |
| bool systemConfig::clear | ( | ) |
Wipes the whole config block and restores defaults.
| systemConfigFlags systemConfig::getConfigFlags | ( | ) |
Returns the packed system configuration flags from flash.
| bool systemConfig::getDHCPfallback | ( | ) |
Returns whether static-IP-to-DHCP fallback is enabled.
| bool systemConfig::getDNS | ( | IPAddress & | dns | ) |
Loads the static DNS server address from flash.
| dns | Output IPAddress. |
| String systemConfig::getETAG | ( | ) |
Returns the ETag of the current remote config, quoted for HTTP.
| bool systemConfig::getGW | ( | IPAddress & | gw | ) |
Loads the static default gateway address from flash.
| gw | Output IPAddress. |
| bool systemConfig::getIP | ( | IPAddress & | ip | ) |
Loads the static IP address from flash.
| ip | Output IPAddress. |
| bool systemConfig::getLoadHTTPConfig | ( | ) |
Returns whether the config is fetched from the portal over HTTP.
| bool systemConfig::getMAC | ( | ) |
Loads the MAC address from flash into the mac member.
| String systemConfig::getMACString | ( | ) |
Returns the MAC address of the controller as a hex string.
| bool systemConfig::getMask | ( | IPAddress & | mask | ) |
Loads the static subnet mask from flash.
| mask | Output IPAddress. |
| char * systemConfig::getMQTTpwd | ( | char * | buffer, |
| uint16_t | bufLen ) |
Reads the MQTT password from flash into a caller buffer.
| buffer | Output buffer for the password. |
| bufLen | Size of the buffer. |
| char * systemConfig::getOTApwd | ( | char * | buffer, |
| uint16_t | bufLen ) |
Reads the OTA (HTTP update) password from flash.
| buffer | Output buffer for the password. |
| bufLen | Size of the buffer. |
| bool systemConfig::getSaveSuccedConfig | ( | ) |
Returns whether a successfully downloaded config is auto-saved.
| uint8_t systemConfig::getSerialDebuglevel | ( | ) |
Returns the stored serial log level.
| char * systemConfig::getServer | ( | char * | buffer, |
| uint16_t | bufLen ) |
Reads the stored configuration server URL into a buffer.
| buffer | Output buffer. |
| bufLen | Size of the buffer. |
| uint8_t systemConfig::getUdpDebuglevel | ( | ) |
Returns the stored UDP log level.
| bool systemConfig::isValidSysConf | ( | ) |
Checks that the stored config block has a valid signature.
| bool systemConfig::loadETAG | ( | ) |
Loads the stored ETag from flash into memory.
| bool systemConfig::saveETAG | ( | ) |
Persists the in-memory ETag to flash.
| bool systemConfig::setConfigFlags | ( | systemConfigFlags | flags | ) |
Writes the packed system configuration flags to flash.
| flags | Flags to store. |
| bool systemConfig::setDHCPfallback | ( | bool | flag | ) |
Enables/disables static-IP-to-DHCP fallback in flash.
| flag | true to allow DHCP fallback. |
| bool systemConfig::setDNS | ( | IPAddress & | dns | ) |
Stores the static DNS server address in flash.
| dns | Address to write. |
| bool systemConfig::setETAG | ( | String | etag | ) |
Sets the in-memory ETag of the remote config (strips quotes).
| etag | ETag string. |
| bool systemConfig::setGW | ( | IPAddress & | gw | ) |
Stores the static default gateway address in flash.
| gw | Address to write. |
| bool systemConfig::setIP | ( | IPAddress & | ip | ) |
Stores the static IP address in flash.
| ip | Address to write. |
| bool systemConfig::setLoadHTTPConfig | ( | bool | load | ) |
Enables/disables fetching the config from the portal over HTTP (disabled permanently after a local config change).
| load | true to allow HTTP config loading. |
| bool systemConfig::setMAC | ( | macAddress & | mac | ) |
Stores the given MAC address into flash.
| mac | MAC address to write. |
| bool systemConfig::setMask | ( | IPAddress & | mask | ) |
Stores the static subnet mask in flash.
| mask | Mask to write. |
| bool systemConfig::setMQTTpwd | ( | char * | pwd = NULL | ) |
Stores the MQTT password in flash (NULL clears it).
| pwd | Null-terminated password, or NULL to erase. |
| bool systemConfig::setOTApwd | ( | char * | pwd = NULL | ) |
Stores the OTA password in flash (NULL clears it).
| pwd | Null-terminated password, or NULL to erase. |
| bool systemConfig::setSaveSuccedConfig | ( | bool | flag | ) |
Enables/disables auto-save of a successfully downloaded config.
| flag | true to enable auto-save. |
| bool systemConfig::setSerialDebuglevel | ( | short | level | ) |
Sets the serial (debug port) log level in flash.
| level | Log level to store. |
| bool systemConfig::setServer | ( | char * | url | ) |
Stores the URL of the remote configuration server in flash. Falls back to the compile-time MY_CONFIG_SERVER / CONFIG_SERVER when nothing is stored.
| url | Null-terminated server URL. |
| bool systemConfig::setUdpDebuglevel | ( | short | level | ) |
Sets the UDP (syslog) log level in flash.
| level | Log level to store. |
| macAddress systemConfig::mac |
MAC address of the controller, kept in memory after load.