Compare commits
3 Commits
f9c5ab86ef
...
6a6931bde0
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
6a6931bde0 | ||
|
|
4aeffc76b0 | ||
|
|
cde86a7f99 |
@@ -23,8 +23,8 @@ build_type = release
|
|||||||
board_build.filesystem = ffat
|
board_build.filesystem = ffat
|
||||||
board_build.partitions = fatfs_partition.csv ; se stai usando uno custom
|
board_build.partitions = fatfs_partition.csv ; se stai usando uno custom
|
||||||
|
|
||||||
#upload_protocol = espota
|
upload_protocol = espota
|
||||||
#upload_port = 10.0.2.139
|
upload_port = 10.0.2.139
|
||||||
|
|
||||||
|
|
||||||
[env:esp32-s3-waveshare8-debug]
|
[env:esp32-s3-waveshare8-debug]
|
||||||
|
|||||||
@@ -397,7 +397,7 @@ namespace commands
|
|||||||
LOG_ERROR("setRainOverride incorrect paramaters");
|
LOG_ERROR("setRainOverride incorrect paramaters");
|
||||||
return response;
|
return response;
|
||||||
}
|
}
|
||||||
s_rainOverride = params["rainOverride"].as<std::string>() == "True" ? true : false;
|
s_rainOverride = params["status"].as<std::string>() == "True" ? true : false;
|
||||||
response["values"]["status"] = "valid";
|
response["values"]["status"] = "valid";
|
||||||
LOG_INFO("setRainOverride [", s_rainOverride ? "True]" : "False]");
|
LOG_INFO("setRainOverride [", s_rainOverride ? "True]" : "False]");
|
||||||
return response;
|
return response;
|
||||||
@@ -503,7 +503,10 @@ namespace commands
|
|||||||
const ArduinoJson::JsonDocument Commands::getRainInfo(const devices_t &dev, const ArduinoJson::JsonDocument ¶ms)
|
const ArduinoJson::JsonDocument Commands::getRainInfo(const devices_t &dev, const ArduinoJson::JsonDocument ¶ms)
|
||||||
{
|
{
|
||||||
ArduinoJson::JsonDocument response;
|
ArduinoJson::JsonDocument response;
|
||||||
LOG_WARN("Comand not yet implemented");
|
const auto rain = !dev.io.digitalInRead(DI::RAIN) ? "True" : "False";
|
||||||
|
response["cmd"] = "getRainInfo";
|
||||||
|
response["values"]["status"] = rain;
|
||||||
|
LOG_INFO("getRainInfo -> ", rain);
|
||||||
return response;
|
return response;
|
||||||
}
|
}
|
||||||
const ArduinoJson::JsonDocument Commands::getIrrigation(const devices_t &dev, const ArduinoJson::JsonDocument ¶ms)
|
const ArduinoJson::JsonDocument Commands::getIrrigation(const devices_t &dev, const ArduinoJson::JsonDocument ¶ms)
|
||||||
@@ -515,8 +518,10 @@ namespace commands
|
|||||||
const ArduinoJson::JsonDocument Commands::getRainOverride(const devices_t &dev, const ArduinoJson::JsonDocument ¶ms)
|
const ArduinoJson::JsonDocument Commands::getRainOverride(const devices_t &dev, const ArduinoJson::JsonDocument ¶ms)
|
||||||
{
|
{
|
||||||
ArduinoJson::JsonDocument response;
|
ArduinoJson::JsonDocument response;
|
||||||
|
const auto ovr = s_rainOverride ? "True" : "False";
|
||||||
response["cmd"] = "getRainOverride";
|
response["cmd"] = "getRainOverride";
|
||||||
response["values"]["rainOverride"] = s_rainOverride ? "True" : "False";
|
response["values"]["rainOverride"] = ovr;
|
||||||
|
LOG_INFO("getRainOverride -> ", ovr);
|
||||||
return response;
|
return response;
|
||||||
}
|
}
|
||||||
const ArduinoJson::JsonDocument Commands::getTimeDrift(const devices_t &dev, const ArduinoJson::JsonDocument ¶ms)
|
const ArduinoJson::JsonDocument Commands::getTimeDrift(const devices_t &dev, const ArduinoJson::JsonDocument ¶ms)
|
||||||
@@ -548,9 +553,7 @@ namespace commands
|
|||||||
response["values"]["status"] = "valid";
|
response["values"]["status"] = "valid";
|
||||||
response["values"]["drift"] = (uint32_t)timeDiff.count();
|
response["values"]["drift"] = (uint32_t)timeDiff.count();
|
||||||
response["values"]["direction"] = "RTC is [" + std::string(direction) + "] NTP time";
|
response["values"]["direction"] = "RTC is [" + std::string(direction) + "] NTP time";
|
||||||
|
|
||||||
LOG_INFO("getTimeDrift -> RTC is [", (int32_t)timeDiff.count(), "] sec, [", std::string(direction).c_str(), "] NTP time");
|
LOG_INFO("getTimeDrift -> RTC is [", (int32_t)timeDiff.count(), "] sec, [", std::string(direction).c_str(), "] NTP time");
|
||||||
|
|
||||||
return response;
|
return response;
|
||||||
}
|
}
|
||||||
// GETTERS //
|
// GETTERS //
|
||||||
|
|||||||
@@ -100,6 +100,7 @@ namespace commands
|
|||||||
{"setRainOverride", Commands::setRainOverride},
|
{"setRainOverride", Commands::setRainOverride},
|
||||||
// GETTERS
|
// GETTERS
|
||||||
{"getHPpower", Commands::getHPpower},
|
{"getHPpower", Commands::getHPpower},
|
||||||
|
{"getRainInfo", Commands::getRainInfo},
|
||||||
{"getInputStatus", Commands::getInputStatus},
|
{"getInputStatus", Commands::getInputStatus},
|
||||||
{"getOutputStatus", Commands::getOutputStatus},
|
{"getOutputStatus", Commands::getOutputStatus},
|
||||||
{"getRainOverride", Commands::getRainOverride},
|
{"getRainOverride", Commands::getRainOverride},
|
||||||
|
|||||||
@@ -237,7 +237,7 @@ const bool Cron::processEvents()
|
|||||||
LOG_INFO("Cron skipping INACTIVE event [", eventName.c_str(), "] next execution time [", drivers::PCF85063::tm2str(eventParams.next).c_str(), "]");
|
LOG_INFO("Cron skipping INACTIVE event [", eventName.c_str(), "] next execution time [", drivers::PCF85063::tm2str(eventParams.next).c_str(), "]");
|
||||||
break;
|
break;
|
||||||
case CronStatus::SKIP:
|
case CronStatus::SKIP:
|
||||||
LOG_INFO("Cron skipping 1 time ACTIVE event [", eventName.c_str(), "] next execution time [", drivers::PCF85063::tm2str(eventParams.next).c_str(), "]");
|
LOG_INFO("Cron skipping one time ACTIVE event [", eventName.c_str(), "] next execution time [", drivers::PCF85063::tm2str(eventParams.next).c_str(), "]");
|
||||||
eventParams.status = CronStatus::ACTIVE;
|
eventParams.status = CronStatus::ACTIVE;
|
||||||
break;
|
break;
|
||||||
default:
|
default:
|
||||||
|
|||||||
13
src/main.cpp
13
src/main.cpp
@@ -36,6 +36,8 @@ void loop()
|
|||||||
uint16_t k(0);
|
uint16_t k(0);
|
||||||
uint8_t sensors(0);
|
uint8_t sensors(0);
|
||||||
bool buzzing(false);
|
bool buzzing(false);
|
||||||
|
NetworkClient logStream;
|
||||||
|
LOG_ATTACH_STREAM(logStream);
|
||||||
|
|
||||||
//////////////// DEVICES ////////////////
|
//////////////// DEVICES ////////////////
|
||||||
// Declared here to keep devices local to the main loop otherwise the kernel crashes //
|
// Declared here to keep devices local to the main loop otherwise the kernel crashes //
|
||||||
@@ -129,6 +131,7 @@ void loop()
|
|||||||
if (!eth.isConnected())
|
if (!eth.isConnected())
|
||||||
{
|
{
|
||||||
led.setColor(led.COLOR_RED);
|
led.setColor(led.COLOR_RED);
|
||||||
|
logStream.stop();
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
if (io.digitalInRead(DI::OTAENABLE)) // Initialize OTA, BLUE
|
if (io.digitalInRead(DI::OTAENABLE)) // Initialize OTA, BLUE
|
||||||
@@ -183,6 +186,16 @@ void loop()
|
|||||||
{
|
{
|
||||||
const uint32_t start(millis());
|
const uint32_t start(millis());
|
||||||
drivers::PCF85063::datetime_t datetime;
|
drivers::PCF85063::datetime_t datetime;
|
||||||
|
|
||||||
|
if (!logStream.connected())
|
||||||
|
{
|
||||||
|
logStream.stop();
|
||||||
|
logStream.clearWriteError();
|
||||||
|
logStream.setConnectionTimeout(100);
|
||||||
|
logStream.connect(conf.m_mqttHost.c_str(), 9876);
|
||||||
|
LOG_WARN("TCP LogStream Connected");
|
||||||
|
}
|
||||||
|
|
||||||
rtc.readDatetime(datetime);
|
rtc.readDatetime(datetime);
|
||||||
const std::string timeStr(drivers::PCF85063::datetime2str(datetime));
|
const std::string timeStr(drivers::PCF85063::datetime2str(datetime));
|
||||||
LOG_INFO("[", k++, "] Loop - Current Datetime UTC", timeStr.c_str());
|
LOG_INFO("[", k++, "] Loop - Current Datetime UTC", timeStr.c_str());
|
||||||
|
|||||||
Reference in New Issue
Block a user