minor fixes
This commit is contained in:
@@ -209,7 +209,7 @@ namespace commands
|
|||||||
const ArduinoJson::JsonDocument Commands::resetHPcounters(const devices_t &dev, const ArduinoJson::JsonDocument ¶ms)
|
const ArduinoJson::JsonDocument Commands::resetHPcounters(const devices_t &dev, const ArduinoJson::JsonDocument ¶ms)
|
||||||
{
|
{
|
||||||
ArduinoJson::JsonDocument response;
|
ArduinoJson::JsonDocument response;
|
||||||
response["cmd"] = "setHPlimit";
|
response["cmd"] = "resetHPcounters";
|
||||||
response["values"]["status"] = "valid";
|
response["values"]["status"] = "valid";
|
||||||
dev.seneca.resetPartialCounters();
|
dev.seneca.resetPartialCounters();
|
||||||
return response;
|
return response;
|
||||||
@@ -439,7 +439,7 @@ namespace commands
|
|||||||
|
|
||||||
response["values"]["status"] = "valid";
|
response["values"]["status"] = "valid";
|
||||||
response["values"]["time"] = rtc.getTimeStr();
|
response["values"]["time"] = rtc.getTimeStr();
|
||||||
LOG_INFO("setTimeNTP -> RTC is [", response["status"]["time"].as<std::string>().c_str(), "]");
|
LOG_INFO("setTimeNTP -> RTC is [", response["values"]["time"].as<std::string>().c_str(), "]");
|
||||||
return response;
|
return response;
|
||||||
}
|
}
|
||||||
// SETTERS //
|
// SETTERS //
|
||||||
|
|||||||
@@ -24,8 +24,9 @@ const bool Cron::loadEvents()
|
|||||||
}
|
}
|
||||||
|
|
||||||
std::string buf;
|
std::string buf;
|
||||||
ArduinoJson::serializeJsonPretty(cronFileContent, buf);
|
ArduinoJson::serializeJson(cronFileContent, buf);
|
||||||
LOG_INFO("Cron loadEvents loaded cronjobs.json\n", buf.c_str());
|
LOG_INFO("Cron loadEvents loaded cronjobs.json");
|
||||||
|
LOG_INFO(buf.c_str());
|
||||||
|
|
||||||
ArduinoJson::JsonArray cronjobList = cronFileContent.as<JsonArray>();
|
ArduinoJson::JsonArray cronjobList = cronFileContent.as<JsonArray>();
|
||||||
LOG_INFO("Cron loadEvents loaded [", cronjobList.size(), "] events");
|
LOG_INFO("Cron loadEvents loaded [", cronjobList.size(), "] events");
|
||||||
@@ -70,8 +71,9 @@ const bool Cron::storeEvents()
|
|||||||
}
|
}
|
||||||
|
|
||||||
std::string buf;
|
std::string buf;
|
||||||
ArduinoJson::serializeJsonPretty(cronFileContent, buf);
|
ArduinoJson::serializeJson(cronFileContent, buf);
|
||||||
LOG_INFO("Cron storeEvents generated cronjobs.json\n", buf.c_str());
|
LOG_INFO("Cron storeEvents generated cronjobs.json");
|
||||||
|
LOG_INFO(buf.c_str());
|
||||||
|
|
||||||
ArduinoJson::serializeJson(cronFileContent, cronFile);
|
ArduinoJson::serializeJson(cronFileContent, cronFile);
|
||||||
cronFile.close();
|
cronFile.close();
|
||||||
@@ -181,7 +183,11 @@ void Cron::startCron()
|
|||||||
if (!m_cronTaskHandle)
|
if (!m_cronTaskHandle)
|
||||||
{
|
{
|
||||||
LOG_INFO("Cron starting loop");
|
LOG_INFO("Cron starting loop");
|
||||||
xTaskCreatePinnedToCore(cronLoop, "cronLoop", STACK_DEPTH, this, PRIORITY, &m_cronTaskHandle, PROCESS_CORE);
|
if (xTaskCreatePinnedToCore(cronLoop, "cronLoop", STACK_DEPTH, this, PRIORITY, &m_cronTaskHandle, PROCESS_CORE) != pdPASS)
|
||||||
|
{
|
||||||
|
LOG_ERROR("Cron failed to start loop");
|
||||||
|
m_cronTaskHandle = NULL;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -3,6 +3,7 @@
|
|||||||
#define STACK_DEPTH 8192
|
#define STACK_DEPTH 8192
|
||||||
#define BUFFER_SIZE 2048
|
#define BUFFER_SIZE 2048
|
||||||
#define PRIORITY 2
|
#define PRIORITY 2
|
||||||
|
#define PROCESS_CORE 1
|
||||||
|
|
||||||
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)
|
||||||
{
|
{
|
||||||
@@ -27,7 +28,11 @@ const bool MQTTwrapper::connect()
|
|||||||
LOG_INFO("MQTT client connected to", m_config.m_mqttHost.c_str());
|
LOG_INFO("MQTT client connected to", m_config.m_mqttHost.c_str());
|
||||||
if (m_loopHandle == NULL)
|
if (m_loopHandle == NULL)
|
||||||
{
|
{
|
||||||
xTaskCreate(clientLoop, "mqttLoop", STACK_DEPTH, this, PRIORITY, &m_loopHandle);
|
if (xTaskCreatePinnedToCore(clientLoop, "mqttLoop", STACK_DEPTH, this, PRIORITY, &m_loopHandle, PROCESS_CORE) != pdPASS)
|
||||||
|
{
|
||||||
|
m_loopHandle = NULL;
|
||||||
|
return false;
|
||||||
|
}
|
||||||
m_client.setCallback(MQTTwrapper::callback);
|
m_client.setCallback(MQTTwrapper::callback);
|
||||||
}
|
}
|
||||||
return true;
|
return true;
|
||||||
|
|||||||
@@ -2,6 +2,7 @@
|
|||||||
|
|
||||||
#define STACK_DEPTH 4096
|
#define STACK_DEPTH 4096
|
||||||
#define TASK_PRIORITY 2
|
#define TASK_PRIORITY 2
|
||||||
|
#define PROCESS_CORE 1
|
||||||
|
|
||||||
OTA::OTA(const devices_t &dev) : m_dev(dev), m_taskHandle(NULL), m_updating(false), m_prevPercent(0)
|
OTA::OTA(const devices_t &dev) : m_dev(dev), m_taskHandle(NULL), m_updating(false), m_prevPercent(0)
|
||||||
{
|
{
|
||||||
@@ -26,10 +27,11 @@ void OTA::begin()
|
|||||||
ArduinoOTA.onEnd(s_onEnd);
|
ArduinoOTA.onEnd(s_onEnd);
|
||||||
ArduinoOTA.onProgress(s_onProgress);
|
ArduinoOTA.onProgress(s_onProgress);
|
||||||
ArduinoOTA.onError(s_onError);
|
ArduinoOTA.onError(s_onError);
|
||||||
if (xTaskCreate(handle, "otaUpdate", STACK_DEPTH, this, TASK_PRIORITY, &m_taskHandle) != pdPASS)
|
if (xTaskCreatePinnedToCore(handle, "otaUpdate", STACK_DEPTH, this, TASK_PRIORITY, &m_taskHandle, PROCESS_CORE) != pdPASS)
|
||||||
{
|
{
|
||||||
m_taskHandle = NULL;
|
m_taskHandle = NULL;
|
||||||
LOG_ERROR("OTA failed to create handle task");
|
LOG_ERROR("OTA failed to create handle task");
|
||||||
|
return;
|
||||||
}
|
}
|
||||||
ArduinoOTA.begin(); // start the OTA server
|
ArduinoOTA.begin(); // start the OTA server
|
||||||
m_dev.led.blinkAlternate(100, 100, m_dev.led.COLOR_ORANGE, m_dev.led.COLOR_SKYBLUE);
|
m_dev.led.blinkAlternate(100, 100, m_dev.led.COLOR_ORANGE, m_dev.led.COLOR_SKYBLUE);
|
||||||
@@ -72,6 +74,7 @@ void OTA::onProgress(const uint32_t progress, const uint32_t total)
|
|||||||
m_prevPercent = percent;
|
m_prevPercent = percent;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void OTA::onStart()
|
void OTA::onStart()
|
||||||
{
|
{
|
||||||
LOG_WARN("OTA update started");
|
LOG_WARN("OTA update started");
|
||||||
@@ -81,6 +84,7 @@ void OTA::onStart()
|
|||||||
m_dev.led.setEnforce(true);
|
m_dev.led.setEnforce(true);
|
||||||
m_prevPercent = 0;
|
m_prevPercent = 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
void OTA::onEnd()
|
void OTA::onEnd()
|
||||||
{
|
{
|
||||||
LOG_WARN("OTA update end");
|
LOG_WARN("OTA update end");
|
||||||
@@ -89,6 +93,7 @@ void OTA::onEnd()
|
|||||||
m_dev.led.blinkAlternate(50, 50, m_dev.led.COLOR_GREEN, m_dev.led.COLOR_YELLOW);
|
m_dev.led.blinkAlternate(50, 50, m_dev.led.COLOR_GREEN, m_dev.led.COLOR_YELLOW);
|
||||||
m_dev.led.setEnforce(true);
|
m_dev.led.setEnforce(true);
|
||||||
}
|
}
|
||||||
|
|
||||||
void OTA::onError(const ota_error_t err)
|
void OTA::onError(const ota_error_t err)
|
||||||
{
|
{
|
||||||
LOG_ERROR("OTA Error [", err, "]");
|
LOG_ERROR("OTA Error [", err, "]");
|
||||||
|
|||||||
Reference in New Issue
Block a user