added setBuzz demo test command
This commit is contained in:
@@ -9,6 +9,13 @@ namespace commands
|
|||||||
esp_restart();
|
esp_restart();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
const ArduinoJson::JsonDocument Commands::setBuzz(const devices_t &dev, const ArduinoJson::JsonDocument ¶ms)
|
||||||
|
{
|
||||||
|
ArduinoJson::JsonDocument response;
|
||||||
|
dev.buzzer.beep(500, NOTE_Bb);
|
||||||
|
return response;
|
||||||
|
}
|
||||||
|
|
||||||
// CONFIG //
|
// CONFIG //
|
||||||
// CONFIG //
|
// CONFIG //
|
||||||
const ArduinoJson::JsonDocument Commands::setConfig(const devices_t &dev, const ArduinoJson::JsonDocument ¶ms)
|
const ArduinoJson::JsonDocument Commands::setConfig(const devices_t &dev, const ArduinoJson::JsonDocument ¶ms)
|
||||||
@@ -115,7 +122,7 @@ namespace commands
|
|||||||
for (const auto &[name, event] : eventMap)
|
for (const auto &[name, event] : eventMap)
|
||||||
{
|
{
|
||||||
const auto cmd = std::get<0>(event);
|
const auto cmd = std::get<0>(event);
|
||||||
response["values"]["name"] = cmd;
|
response["values"][name] = cmd;
|
||||||
eventNum++;
|
eventNum++;
|
||||||
}
|
}
|
||||||
LOG_INFO("getCronJob got [", eventNum, "] events");
|
LOG_INFO("getCronJob got [", eventNum, "] events");
|
||||||
@@ -385,7 +392,7 @@ namespace commands
|
|||||||
}
|
}
|
||||||
|
|
||||||
response["values"]["status"] = "valid";
|
response["values"]["status"] = "valid";
|
||||||
response["status"]["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["status"]["time"].as<std::string>().c_str(), "]");
|
||||||
|
|
||||||
@@ -485,10 +492,10 @@ namespace commands
|
|||||||
auto timeDiff = std::chrono::duration_cast<std::chrono::seconds>(ntpTimePoint - rtcTimePoint);
|
auto timeDiff = std::chrono::duration_cast<std::chrono::seconds>(ntpTimePoint - rtcTimePoint);
|
||||||
auto direction = timeDiff.count() >= 0 ? "BEYOND" : "AHEAD";
|
auto direction = timeDiff.count() >= 0 ? "BEYOND" : "AHEAD";
|
||||||
|
|
||||||
response["values"]["drift"] = (uint32_t)timeDiff.count();
|
response["values"]["drift"] = (int32_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 [", (uint32_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;
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -64,6 +64,9 @@ namespace commands
|
|||||||
Commands() = delete;
|
Commands() = delete;
|
||||||
|
|
||||||
public:
|
public:
|
||||||
|
// TEST //
|
||||||
|
static const ArduinoJson::JsonDocument setBuzz(const devices_t &dev, const ArduinoJson::JsonDocument ¶ms);
|
||||||
|
|
||||||
// CONFIG //
|
// CONFIG //
|
||||||
static const ArduinoJson::JsonDocument setConfig(const devices_t &dev, const ArduinoJson::JsonDocument ¶ms);
|
static const ArduinoJson::JsonDocument setConfig(const devices_t &dev, const ArduinoJson::JsonDocument ¶ms);
|
||||||
static const ArduinoJson::JsonDocument getConfig(const devices_t &dev, const ArduinoJson::JsonDocument ¶ms);
|
static const ArduinoJson::JsonDocument getConfig(const devices_t &dev, const ArduinoJson::JsonDocument ¶ms);
|
||||||
@@ -94,6 +97,9 @@ namespace commands
|
|||||||
};
|
};
|
||||||
|
|
||||||
static const std::map<const std::string, Command> s_commandMap = {
|
static const std::map<const std::string, Command> s_commandMap = {
|
||||||
|
|
||||||
|
{"setBuzz", Commands::setBuzz},
|
||||||
|
|
||||||
{"setConfig", Commands::setConfig},
|
{"setConfig", Commands::setConfig},
|
||||||
{"getConfig", Commands::getConfig},
|
{"getConfig", Commands::getConfig},
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user