formatting
This commit is contained in:
@@ -47,13 +47,12 @@ void loop()
|
|||||||
auto rtc = drivers::PCF85063(i2c, PCF85063_ADDRESS);
|
auto rtc = drivers::PCF85063(i2c, PCF85063_ADDRESS);
|
||||||
auto eth = drivers::Ethernet(conf.m_ethHostname);
|
auto eth = drivers::Ethernet(conf.m_ethHostname);
|
||||||
auto tmp = drivers::R4DCB08(bus, conf.m_modbusTemperatureAddr);
|
auto tmp = drivers::R4DCB08(bus, conf.m_modbusTemperatureAddr);
|
||||||
// Initialize temperature sensors
|
|
||||||
sensors = tmp.getNum();
|
|
||||||
delay(100);
|
|
||||||
auto seneca = drivers::S50140(bus, conf.m_modbusSenecaAddr);
|
auto seneca = drivers::S50140(bus, conf.m_modbusSenecaAddr);
|
||||||
auto buzzer = drivers::Buzzer();
|
auto buzzer = drivers::Buzzer();
|
||||||
auto led = drivers::Led();
|
auto led = drivers::Led();
|
||||||
auto io = digitalIO(i2c, bus, {conf.m_modbusRelayAddr});
|
auto io = digitalIO(i2c, bus, {conf.m_modbusRelayAddr});
|
||||||
|
// Initialize temperature sensors
|
||||||
|
sensors = tmp.getNum();
|
||||||
LOG_INFO("Temperature sensors connected ->", sensors);
|
LOG_INFO("Temperature sensors connected ->", sensors);
|
||||||
//////////////// DEVICES ////////////////
|
//////////////// DEVICES ////////////////
|
||||||
|
|
||||||
|
|||||||
12
src/mqtt.cpp
12
src/mqtt.cpp
@@ -1,7 +1,7 @@
|
|||||||
#include <mqtt.h>
|
#include <mqtt.h>
|
||||||
|
|
||||||
#define STACK_DEPTH 4096
|
#define STACK_DEPTH 4096
|
||||||
#define PRIOTITY 0
|
#define PRIOTITY 2
|
||||||
|
|
||||||
MQTTwrapper::MQTTwrapper() : m_config(Config::getInstance()), m_tcp(NetworkClient()), m_client(PubSubClient(m_tcp)), m_loopHandle(NULL)
|
MQTTwrapper::MQTTwrapper() : m_config(Config::getInstance()), m_tcp(NetworkClient()), m_client(PubSubClient(m_tcp)), m_loopHandle(NULL)
|
||||||
{
|
{
|
||||||
@@ -76,7 +76,8 @@ const bool MQTTwrapper::unsubscribe(topic_t topic)
|
|||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
const bool MQTTwrapper::connected() {
|
const bool MQTTwrapper::connected()
|
||||||
|
{
|
||||||
return m_loopHandle != NULL;
|
return m_loopHandle != NULL;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -146,12 +147,12 @@ void MQTTwrapper::clientLoop(void *params)
|
|||||||
while (client.connected())
|
while (client.connected())
|
||||||
{
|
{
|
||||||
client.loop();
|
client.loop();
|
||||||
vTaskDelay(pdMS_TO_TICKS(loopTime));
|
delay(loopTime);
|
||||||
}
|
}
|
||||||
if (client.state() != MQTT_CONNECTED)
|
if (client.state() != MQTT_CONNECTED)
|
||||||
{
|
{
|
||||||
LOG_ERROR("MQTT disconnect reason ", stateMap.at(client.state()).c_str());
|
LOG_ERROR("MQTT disconnect reason ", stateMap.at(client.state()).c_str());
|
||||||
vTaskDelay(pdMS_TO_TICKS(loopTime * 50));
|
delay(loopTime * 50);
|
||||||
const bool ok = client.connect(clientName.c_str());
|
const bool ok = client.connect(clientName.c_str());
|
||||||
LOG_WARN("MQTT reconnected", ok ? "True" : "False");
|
LOG_WARN("MQTT reconnected", ok ? "True" : "False");
|
||||||
if (ok)
|
if (ok)
|
||||||
@@ -160,7 +161,8 @@ void MQTTwrapper::clientLoop(void *params)
|
|||||||
{
|
{
|
||||||
const std::string &topic(v.first);
|
const std::string &topic(v.first);
|
||||||
LOG_WARN("MQTT resubscribing to", topic.c_str());
|
LOG_WARN("MQTT resubscribing to", topic.c_str());
|
||||||
if(!wrapper->m_client.subscribe(topic.c_str())){
|
if (!wrapper->m_client.subscribe(topic.c_str()))
|
||||||
|
{
|
||||||
LOG_ERROR("Unable to resubscribe to", topic.c_str());
|
LOG_ERROR("Unable to resubscribe to", topic.c_str());
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user