Merge branch 'master' of https://github.com/0110/PlantCtrl
This commit is contained in:
@@ -9,9 +9,19 @@ void log(int level, String message, int statusCode)
|
||||
{
|
||||
String buffer;
|
||||
StaticJsonDocument<200> doc;
|
||||
// Read the current time
|
||||
time_t now; // this is the epoch
|
||||
tm tm; // the structure tm holds time information in a more convient way
|
||||
doc["level"] = level;
|
||||
doc["message"] = message;
|
||||
doc["statusCode"] = statusCode;
|
||||
time(&now);
|
||||
localtime_r(&now, &tm);
|
||||
if (tm.tm_year > (2021 - 1970)) { /* Only add the time, if we have at least 2021 */
|
||||
doc["time"] = String(String(1900 + tm.tm_year) + "-" + String(tm.tm_mon + 1) + "-" + String(tm.tm_mday) +
|
||||
" " + String(tm.tm_hour) + ":" + String(tm.tm_min) + ":" + String(tm.tm_sec));
|
||||
}
|
||||
|
||||
serializeJson(doc, buffer);
|
||||
if (mAliveWasRead)
|
||||
{
|
||||
@@ -84,4 +94,4 @@ void startMQTTRoundtripTest(){
|
||||
Homie.getMqttClient()
|
||||
.subscribe(backupTopic, 2);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@@ -209,7 +209,7 @@ void readOneWireSensors()
|
||||
continue;
|
||||
}
|
||||
|
||||
char buf[sizeof(ds18b20Address) * 2];
|
||||
char buf[(sizeof(ds18b20Address) * 2)+1]; /* additional byte for trailing terminator */
|
||||
snprintf(buf, sizeof(buf), "%.2X%.2X%.2X%.2X%.2X%.2X%.2X%.2X",
|
||||
ds18b20Address[0],
|
||||
ds18b20Address[1],
|
||||
@@ -658,12 +658,9 @@ void pumpActiveLoop()
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* @brief Startup function
|
||||
* Is called once, the controller is started
|
||||
*/
|
||||
void setup()
|
||||
void safeSetup()
|
||||
{
|
||||
throw std::runtime_error("Shit happened");
|
||||
/* reduce power consumption */
|
||||
setCpuFrequencyMhz(80);
|
||||
|
||||
@@ -848,6 +845,26 @@ void setup()
|
||||
setupFinishedTimestamp = millis();
|
||||
}
|
||||
|
||||
/**
|
||||
* @brief Startup function
|
||||
* Is called once, the controller is started
|
||||
*/
|
||||
void setup()
|
||||
{
|
||||
try
|
||||
{
|
||||
safeSetup();
|
||||
}
|
||||
catch (const std::exception &e)
|
||||
{
|
||||
Serial.printf("Exception thrown: \"%s\"", e.what());
|
||||
}
|
||||
catch (...)
|
||||
{
|
||||
Serial.println("Other exception thrown.");
|
||||
}
|
||||
}
|
||||
|
||||
void selfTest()
|
||||
{
|
||||
|
||||
|
Reference in New Issue
Block a user