added setBuzz demo test command

This commit is contained in:
2025-07-30 16:26:18 +02:00
parent 1110648978
commit fa1b288f4d
2 changed files with 17 additions and 4 deletions

View File

@@ -9,6 +9,13 @@ namespace commands
esp_restart();
}
const ArduinoJson::JsonDocument Commands::setBuzz(const devices_t &dev, const ArduinoJson::JsonDocument &params)
{
ArduinoJson::JsonDocument response;
dev.buzzer.beep(500, NOTE_Bb);
return response;
}
// CONFIG //
// CONFIG //
const ArduinoJson::JsonDocument Commands::setConfig(const devices_t &dev, const ArduinoJson::JsonDocument &params)
@@ -115,7 +122,7 @@ namespace commands
for (const auto &[name, event] : eventMap)
{
const auto cmd = std::get<0>(event);
response["values"]["name"] = cmd;
response["values"][name] = cmd;
eventNum++;
}
LOG_INFO("getCronJob got [", eventNum, "] events");
@@ -385,7 +392,7 @@ namespace commands
}
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(), "]");
@@ -485,10 +492,10 @@ namespace commands
auto timeDiff = std::chrono::duration_cast<std::chrono::seconds>(ntpTimePoint - rtcTimePoint);
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";
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;
}

View File

@@ -64,6 +64,9 @@ namespace commands
Commands() = delete;
public:
// TEST //
static const ArduinoJson::JsonDocument setBuzz(const devices_t &dev, const ArduinoJson::JsonDocument &params);
// CONFIG //
static const ArduinoJson::JsonDocument setConfig(const devices_t &dev, const ArduinoJson::JsonDocument &params);
static const ArduinoJson::JsonDocument getConfig(const devices_t &dev, const ArduinoJson::JsonDocument &params);
@@ -94,6 +97,9 @@ namespace commands
};
static const std::map<const std::string, Command> s_commandMap = {
{"setBuzz", Commands::setBuzz},
{"setConfig", Commands::setConfig},
{"getConfig", Commands::getConfig},