Wombat Environmental Node 1.0
An environmental node for SDI-12 and digital sensors.
|
Node configuration options for both getting and setting values. More...
#include <DeviceConfig.h>
Public Member Functions | |
void | reset () |
Reset device configuration values back to their default. More... | |
void | load () |
Load device configuration values from SPIFFS storage. More... | |
void | save () |
Save device configuration values to SPIFFS storage. More... | |
uint32_t | getBootCount (void) |
Method to get the number of times the ESP32 has rebooted. bootCount is incremented when the singleton is created, meaning at power-on it will be 1 by the time any code can ask for it. It is easier to do modulo arithmetic with a 0-based bootCount so adjust it before returning it. More... | |
uint16_t | getMeasureInterval () |
void | setMeasureInterval (const uint16_t seconds) |
Set the measurement interval. More... | |
uint16_t | getUplinkInterval () |
void | setUplinkInterval (const uint16_t seconds) |
Set the uplink interval. More... | |
void | setMeasurementAndUplinkIntervals (const uint16_t measurement_seconds, const uint16_t uplink_seconds) |
Set both the measurement and uplink intervals. More... | |
void | setMqttHost (const std::string &host) |
Set the MQTT hostname. More... | |
void | setMqttPort (uint16_t port) |
Set the MQTT port. More... | |
void | setMqttUser (const std::string &user) |
Set the MQTT broker username. More... | |
void | setMqttPassword (const std::string &password) |
Set the MQTT broker password. More... | |
std::string & | getMqttHost () |
Get the MQTT hostname. More... | |
uint16_t | getMqttPort () |
Get the MQTT port. More... | |
std::string & | getMqttUser () |
Get the MQTT broker username. More... | |
std::string & | getMqttPassword () |
Get the MQTT broker password. More... | |
void | setFtpHost (const std::string &host) |
Set the FTP hostname. More... | |
void | setFtpUser (const std::string &user) |
Set the FTP username. More... | |
void | setFtpPassword (const std::string &password) |
Set the FTP password. More... | |
std::string & | getFtpHost () |
Get the FTP hostname. More... | |
std::string & | getFtpUser () |
Get the FTP username. More... | |
std::string & | getFtpPassword () |
Get the FTP password. More... | |
float | getSleepAdjustment () |
void | setSleepAdjustment (float _sleep_adjustment) |
void | dumpConfig (Stream &stream) |
Print out device configuration to a stream. More... | |
const JsonDocument & | getSDI12Defns (void) |
Get the SDI-12 device definitions from SPIFFS storage. More... | |
Static Public Member Functions | |
static DeviceConfig & | get () |
Provides an instance to other functions (MQTT and uplink intervals) to access (set, get) device configuration. More... | |
static const char * | getMsgFilePrefix (void) |
Public Attributes | |
uint8_t | mac [6] |
char | node_id [13] |
char | mqtt_topic_template [MAX_CONFIG_STR+1] |
Static Public Attributes | |
static constexpr size_t | MAX_CONFIG_STR = 32 |
Maximum length of a configuration string. More... | |
Private Member Functions | |
DeviceConfig () | |
Device configuration constructor with default values. More... | |
DeviceConfig (const DeviceConfig &)=delete | |
Avoid operations that would make copies of the singleton instance. More... | |
DeviceConfig & | operator= (const DeviceConfig &)=delete |
Private Attributes | |
float | sleep_adjustment = 1.0f |
Multiplier for the sleep time to account for clock speed variations. More... | |
uint16_t | measure_interval |
How often to read the sensors, in seconds. More... | |
uint16_t | uplink_interval |
How often to uplink the data, in seconds. More... | |
std::string | mqttHost |
MQTT hostname. More... | |
uint16_t | mqttPort |
MQTT port. More... | |
std::string | mqttUser |
MQTT broker username. More... | |
std::string | mqttPassword |
MQTT broker password. More... | |
std::string | ftpHost |
FTP hostname. More... | |
std::string | ftpUser |
FTP username. More... | |
std::string | ftpPassword |
FTP password. More... | |
Node configuration options for both getting and setting values.
Handles all device configuration commands. This includes measurement and uplink intervals, MQTT configuration and SDI-12 configuration. Values are stored in SPIFFS storage.
|
private |
Device configuration constructor with default values.
|
privatedelete |
Avoid operations that would make copies of the singleton instance.
void DeviceConfig::dumpConfig | ( | Stream & | stream | ) |
Print out device configuration to a stream.
stream | Output stream. |
|
inlinestatic |
Provides an instance to other functions (MQTT and uplink intervals) to access (set, get) device configuration.
uint32_t DeviceConfig::getBootCount | ( | void | ) |
Method to get the number of times the ESP32 has rebooted. bootCount is incremented when the singleton is created, meaning at power-on it will be 1 by the time any code can ask for it. It is easier to do modulo arithmetic with a 0-based bootCount so adjust it before returning it.
|
inline |
Get the FTP hostname.
|
inline |
Get the FTP password.
|
inline |
Get the FTP username.
|
inline |
|
inline |
Get the MQTT hostname.
|
inline |
Get the MQTT broker password.
|
inline |
Get the MQTT port.
|
inline |
Get the MQTT broker username.
|
inlinestatic |
const JsonDocument & DeviceConfig::getSDI12Defns | ( | void | ) |
Get the SDI-12 device definitions from SPIFFS storage.
|
inline |
|
inline |
void DeviceConfig::load | ( | ) |
Load device configuration values from SPIFFS storage.
Load the DeviceConfig values from a file on the file system.
This function loads the DeviceConfig values from a file on the file system and sets any missing values to their default states. It also loads the SDI-12 sensor definitions from a file on the file system.
|
privatedelete |
void DeviceConfig::reset | ( | ) |
Reset device configuration values back to their default.
Reset the DeviceConfig values to their default states.
This function resets the measure interval, uplink interval, MAC address, and MQTT connection parameters (host, port, user, and password) to their default values.
void DeviceConfig::save | ( | ) |
Save device configuration values to SPIFFS storage.
Save device configuration to SPIFFS storage.
|
inline |
Set the FTP hostname.
|
inline |
Set the FTP password.
|
inline |
Set the FTP username.
void DeviceConfig::setMeasureInterval | ( | const uint16_t | seconds | ) |
Set the measurement interval.
seconds | Time in seconds. |
void DeviceConfig::setMeasurementAndUplinkIntervals | ( | const uint16_t | measurement_seconds, |
const uint16_t | uplink_seconds | ||
) |
Set both the measurement and uplink intervals.
measurement_seconds | Measurement interval in seconds. |
uplink_seconds | Uplink interval in seconds. |
|
inline |
Set the MQTT hostname.
|
inline |
Set the MQTT broker password.
|
inline |
Set the MQTT port.
|
inline |
Set the MQTT broker username.
|
inline |
void DeviceConfig::setUplinkInterval | ( | const uint16_t | seconds | ) |
Set the uplink interval.
seconds | Time in seconds. |
|
private |
FTP hostname.
|
private |
FTP password.
|
private |
FTP username.
uint8_t DeviceConfig::mac[6] |
|
staticconstexpr |
Maximum length of a configuration string.
|
private |
How often to read the sensors, in seconds.
char DeviceConfig::mqtt_topic_template[MAX_CONFIG_STR+1] |
|
private |
MQTT hostname.
|
private |
MQTT broker password.
|
private |
MQTT port.
|
private |
MQTT broker username.
char DeviceConfig::node_id[13] |
|
private |
Multiplier for the sleep time to account for clock speed variations.
|
private |
How often to uplink the data, in seconds.