Config class as singleton with initializer in setup
This commit is contained in:
16
src/main.cpp
16
src/main.cpp
@@ -18,6 +18,10 @@
|
||||
|
||||
#include "utils.h"
|
||||
|
||||
/////////////// GLOBALS ///////////////
|
||||
Config& conf = Config::getInstance();
|
||||
/////////////// GLOBALS ///////////////
|
||||
|
||||
void callback(char *topic, uint8_t *payload, unsigned int length)
|
||||
{
|
||||
std::string pl;
|
||||
@@ -42,13 +46,11 @@ void setup()
|
||||
{
|
||||
Serial.begin(9600);
|
||||
LOG_ATTACH_SERIAL(Serial);
|
||||
conf.init();
|
||||
}
|
||||
|
||||
void loop()
|
||||
{
|
||||
/////////////// GLOBALS ///////////////
|
||||
Config conf = Config();
|
||||
/////////////// GLOBALS ///////////////
|
||||
const uint8_t baseRegister(0x00);
|
||||
uint16_t k(0);
|
||||
uint8_t sensors(0);
|
||||
@@ -79,11 +81,11 @@ void loop()
|
||||
mqtt.setServer(conf.m_mqttHost.c_str(), conf.m_mqttPort);
|
||||
mqtt.setCallback(callback);
|
||||
//////////////// NETWORK ////////////////
|
||||
|
||||
//////////////// NETWORK ////////////////
|
||||
/////////////// CALLBACK ////////////////
|
||||
|
||||
//////////////// NETWORK ////////////////
|
||||
/////////////// CALLBACK ////////////////
|
||||
Network.onEvent(
|
||||
[&conf, ð, &rtc, &mqtt, &buzzer, &led](arduino_event_id_t event, arduino_event_info_t info) -> void
|
||||
[ð, &rtc, &mqtt, &buzzer, &led](arduino_event_id_t event, arduino_event_info_t info) -> void
|
||||
{
|
||||
eth.onEvent(event, info); // Arduino Ethernet event handler
|
||||
if (!eth.isConnected())
|
||||
|
||||
Reference in New Issue
Block a user