mirror of
https://github.com/MrUnknownDE/OpenIris-ESPIDF.git
synced 2026-04-19 14:33:45 +02:00
Rewrite commands to nlohmann-json
This commit is contained in:
@@ -1,86 +1,17 @@
|
||||
#include "camera_commands.hpp"
|
||||
|
||||
std::optional<UpdateCameraConfigPayload> parseUpdateCameraPayload(std::string_view jsonPayload)
|
||||
CommandResult updateCameraCommand(std::shared_ptr<DependencyRegistry> registry, const nlohmann::json &json)
|
||||
{
|
||||
UpdateCameraConfigPayload payload;
|
||||
cJSON *parsedJson = cJSON_Parse(jsonPayload.data());
|
||||
|
||||
if (parsedJson == nullptr)
|
||||
return std::nullopt;
|
||||
|
||||
cJSON *vflipObject = cJSON_GetObjectItem(parsedJson, "vflip");
|
||||
cJSON *hrefObject = cJSON_GetObjectItem(parsedJson, "href");
|
||||
cJSON *framesize = cJSON_GetObjectItem(parsedJson, "framesize");
|
||||
cJSON *quality = cJSON_GetObjectItem(parsedJson, "quality");
|
||||
cJSON *brightness = cJSON_GetObjectItem(parsedJson, "brightness");
|
||||
|
||||
if (vflipObject != nullptr)
|
||||
payload.vflip = vflipObject->valueint;
|
||||
if (hrefObject != nullptr)
|
||||
payload.href = hrefObject->valueint;
|
||||
if (framesize != nullptr)
|
||||
payload.framesize = framesize->valueint;
|
||||
if (quality != nullptr)
|
||||
payload.quality = quality->valueint;
|
||||
if (brightness != nullptr)
|
||||
payload.brightness = brightness->valueint;
|
||||
|
||||
cJSON_Delete(parsedJson);
|
||||
return payload;
|
||||
}
|
||||
|
||||
std::optional<RestartCameraPayload> parseRestartCameraPayload(std::string_view jsonPayload)
|
||||
{
|
||||
RestartCameraPayload payload;
|
||||
cJSON *parsedJson = cJSON_Parse(jsonPayload.data());
|
||||
|
||||
if (parsedJson == nullptr)
|
||||
return std::nullopt;
|
||||
|
||||
cJSON *mode = cJSON_GetObjectItem(parsedJson, "mode");
|
||||
|
||||
if (mode == nullptr)
|
||||
{
|
||||
cJSON_Delete(parsedJson);
|
||||
}
|
||||
|
||||
payload.mode = (bool)mode->valueint;
|
||||
|
||||
cJSON_Delete(parsedJson);
|
||||
|
||||
return payload;
|
||||
}
|
||||
|
||||
CommandResult updateCameraCommand(std::shared_ptr<DependencyRegistry> registry, std::string_view jsonPayload)
|
||||
{
|
||||
auto payload = parseUpdateCameraPayload(jsonPayload);
|
||||
if (!payload.has_value())
|
||||
{
|
||||
return CommandResult::getErrorResult("Invalid payload");
|
||||
}
|
||||
auto updatedConfig = payload.value();
|
||||
auto payload = json.get<UpdateCameraConfigPayload>();
|
||||
|
||||
std::shared_ptr<ProjectConfig> projectConfig = registry->resolve<ProjectConfig>(DependencyType::project_config);
|
||||
auto oldConfig = projectConfig->getCameraConfig();
|
||||
projectConfig->setCameraConfig(
|
||||
updatedConfig.vflip.has_value() ? updatedConfig.vflip.value() : oldConfig.vflip,
|
||||
updatedConfig.framesize.has_value() ? updatedConfig.framesize.value() : oldConfig.framesize,
|
||||
updatedConfig.href.has_value() ? updatedConfig.href.value() : oldConfig.href,
|
||||
updatedConfig.quality.has_value() ? updatedConfig.quality.value() : oldConfig.quality,
|
||||
updatedConfig.brightness.has_value() ? updatedConfig.brightness.value() : oldConfig.brightness);
|
||||
payload.vflip.has_value() ? payload.vflip.value() : oldConfig.vflip,
|
||||
payload.framesize.has_value() ? payload.framesize.value() : oldConfig.framesize,
|
||||
payload.href.has_value() ? payload.href.value() : oldConfig.href,
|
||||
payload.quality.has_value() ? payload.quality.value() : oldConfig.quality,
|
||||
payload.brightness.has_value() ? payload.brightness.value() : oldConfig.brightness);
|
||||
|
||||
return CommandResult::getSuccessResult("Config updated");
|
||||
}
|
||||
|
||||
CommandResult restartCameraCommand(std::shared_ptr<DependencyRegistry> registry, std::string_view jsonPayload)
|
||||
{
|
||||
auto payload = parseRestartCameraPayload(jsonPayload);
|
||||
if (!payload.has_value())
|
||||
{
|
||||
return CommandResult::getErrorResult("Invalid payload");
|
||||
}
|
||||
|
||||
std::shared_ptr<CameraManager> cameraManager = registry->resolve<CameraManager>(DependencyType::camera_manager);
|
||||
cameraManager->resetCamera(payload.value().mode);
|
||||
return CommandResult::getSuccessResult("Camera restarted");
|
||||
}
|
||||
@@ -4,17 +4,14 @@
|
||||
#include <memory>
|
||||
#include <string>
|
||||
#include <optional>
|
||||
#include <cJSON.h>
|
||||
#include "CommandResult.hpp"
|
||||
#include "CommandSchema.hpp"
|
||||
#include "DependencyRegistry.hpp"
|
||||
#include <CameraManager.hpp>
|
||||
#include <nlohmann-json.hpp>
|
||||
|
||||
std::optional<UpdateCameraConfigPayload> parseUpdateCameraPayload(std::string_view jsonPayload);
|
||||
CommandResult updateCameraCommand(std::shared_ptr<DependencyRegistry> registry, std::string_view jsonPayload);
|
||||
CommandResult updateCameraCommand(std::shared_ptr<DependencyRegistry> registry, const nlohmann::json &json);
|
||||
|
||||
std::optional<RestartCameraPayload> parseRestartCameraPayload(std::string_view jsonPayload);
|
||||
CommandResult restartCameraCommand(std::shared_ptr<DependencyRegistry> registry, std::string_view jsonPayload);
|
||||
#endif
|
||||
|
||||
// add cropping command
|
||||
@@ -1,27 +1,5 @@
|
||||
#include "config_commands.hpp"
|
||||
|
||||
std::optional<ResetConfigPayload> parseResetConfigCommandPayload(std::string_view jsonPayload)
|
||||
{
|
||||
ResetConfigPayload payload;
|
||||
cJSON *parsedJson = cJSON_Parse(jsonPayload.data());
|
||||
|
||||
if (parsedJson == nullptr)
|
||||
return std::nullopt;
|
||||
|
||||
cJSON *section = cJSON_GetObjectItem(parsedJson, "section");
|
||||
|
||||
if (section == nullptr)
|
||||
{
|
||||
cJSON_Delete(parsedJson);
|
||||
return std::nullopt;
|
||||
}
|
||||
|
||||
payload.section = std::string(section->valuestring);
|
||||
|
||||
cJSON_Delete(parsedJson);
|
||||
return payload;
|
||||
}
|
||||
|
||||
CommandResult saveConfigCommand(std::shared_ptr<DependencyRegistry> registry)
|
||||
{
|
||||
std::shared_ptr<ProjectConfig> projectConfig = registry->resolve<ProjectConfig>(DependencyType::project_config);
|
||||
@@ -38,29 +16,27 @@ CommandResult getConfigCommand(std::shared_ptr<DependencyRegistry> registry)
|
||||
return CommandResult::getSuccessResult(configRepresentation);
|
||||
}
|
||||
|
||||
CommandResult resetConfigCommand(std::shared_ptr<DependencyRegistry> registry, std::string_view jsonPayload)
|
||||
CommandResult resetConfigCommand(std::shared_ptr<DependencyRegistry> registry, const nlohmann::json &json)
|
||||
{
|
||||
std::array<std::string, 4> supported_sections = {
|
||||
"all",
|
||||
};
|
||||
|
||||
auto payload = parseResetConfigCommandPayload(jsonPayload);
|
||||
|
||||
if (!payload.has_value())
|
||||
if (!json.contains("section"))
|
||||
{
|
||||
return CommandResult::getErrorResult("Invalid payload or missing section");
|
||||
return CommandResult::getErrorResult("Invalid payload - missing section");
|
||||
}
|
||||
|
||||
auto sectionPayload = payload.value();
|
||||
auto section = json["section"].get<std::string>();
|
||||
|
||||
if (std::find(supported_sections.begin(), supported_sections.end(), sectionPayload.section) == supported_sections.end())
|
||||
if (std::find(supported_sections.begin(), supported_sections.end(), section) == supported_sections.end())
|
||||
{
|
||||
return CommandResult::getErrorResult("Selected section is unsupported");
|
||||
}
|
||||
|
||||
// we cannot match on string, and making a map would be overkill right now, sooo
|
||||
// todo, add more granual control for other sections, like only reset camera, or only reset wifi
|
||||
if (sectionPayload.section == "all")
|
||||
// todo, add more granular control for other sections, like only reset camera, or only reset wifi
|
||||
if (section == "all")
|
||||
{
|
||||
std::shared_ptr<ProjectConfig> projectConfig = registry->resolve<ProjectConfig>(DependencyType::project_config);
|
||||
projectConfig->reset();
|
||||
|
||||
@@ -2,13 +2,12 @@
|
||||
#include <memory>
|
||||
#include <string>
|
||||
#include <optional>
|
||||
#include <cJSON.h>
|
||||
#include "CommandResult.hpp"
|
||||
#include "CommandSchema.hpp"
|
||||
#include "DependencyRegistry.hpp"
|
||||
#include <nlohmann-json.hpp>
|
||||
|
||||
CommandResult saveConfigCommand(std::shared_ptr<DependencyRegistry> registry);
|
||||
CommandResult getConfigCommand(std::shared_ptr<DependencyRegistry> registry);
|
||||
|
||||
std::optional<ResetConfigPayload> parseresetConfigCommandPayload(std::string_view jsonPayload);
|
||||
CommandResult resetConfigCommand(std::shared_ptr<DependencyRegistry> registry, std::string_view jsonPayload);
|
||||
CommandResult resetConfigCommand(std::shared_ptr<DependencyRegistry> registry, const nlohmann::json &json);
|
||||
@@ -4,23 +4,14 @@
|
||||
#include "esp_mac.h"
|
||||
#include <cstdio>
|
||||
|
||||
// Implementation inspired by SummerSigh work, initial PR opened in openiris repo, adapted to this rewrite
|
||||
CommandResult setDeviceModeCommand(std::shared_ptr<DependencyRegistry> registry, std::string_view jsonPayload)
|
||||
CommandResult setDeviceModeCommand(std::shared_ptr<DependencyRegistry> registry, const nlohmann::json &json)
|
||||
{
|
||||
const auto parsedJson = cJSON_Parse(jsonPayload.data());
|
||||
if (parsedJson == nullptr)
|
||||
if (!json.contains("mode") || !json["mode"].is_number_integer())
|
||||
{
|
||||
return CommandResult::getErrorResult("Invalid payload");
|
||||
return CommandResult::getErrorResult("Invalid payload - missing or unsupported mode");
|
||||
}
|
||||
|
||||
const auto modeObject = cJSON_GetObjectItem(parsedJson, "mode");
|
||||
if (modeObject == nullptr)
|
||||
{
|
||||
return CommandResult::getErrorResult("Invalid payload - missing mode");
|
||||
}
|
||||
|
||||
const auto mode = modeObject->valueint;
|
||||
|
||||
const auto mode = json["mode"].get<int>();
|
||||
if (mode < 0 || mode > 2)
|
||||
{
|
||||
return CommandResult::getErrorResult("Invalid payload - unsupported mode");
|
||||
@@ -29,19 +20,11 @@ CommandResult setDeviceModeCommand(std::shared_ptr<DependencyRegistry> registry,
|
||||
const auto projectConfig = registry->resolve<ProjectConfig>(DependencyType::project_config);
|
||||
projectConfig->setDeviceMode(static_cast<StreamingMode>(mode));
|
||||
|
||||
cJSON_Delete(parsedJson);
|
||||
|
||||
return CommandResult::getSuccessResult("Device mode set");
|
||||
}
|
||||
|
||||
CommandResult updateOTACredentialsCommand(std::shared_ptr<DependencyRegistry> registry, std::string_view jsonPayload)
|
||||
CommandResult updateOTACredentialsCommand(std::shared_ptr<DependencyRegistry> registry, const nlohmann::json &json)
|
||||
{
|
||||
const auto parsedJson = cJSON_Parse(jsonPayload.data());
|
||||
|
||||
if (parsedJson == nullptr)
|
||||
{
|
||||
return CommandResult::getErrorResult("Invalid payload");
|
||||
}
|
||||
|
||||
const auto projectConfig = registry->resolve<ProjectConfig>(DependencyType::project_config);
|
||||
const auto oldDeviceConfig = projectConfig->getDeviceConfig();
|
||||
@@ -49,48 +32,39 @@ CommandResult updateOTACredentialsCommand(std::shared_ptr<DependencyRegistry> re
|
||||
auto OTAPassword = oldDeviceConfig.OTAPassword;
|
||||
auto OTAPort = oldDeviceConfig.OTAPort;
|
||||
|
||||
if (const auto OTALoginObject = cJSON_GetObjectItem(parsedJson, "login"); OTALoginObject != nullptr)
|
||||
if (json.contains("login") && json["login"].is_string())
|
||||
{
|
||||
if (const auto newLogin = OTALoginObject->valuestring; strcmp(newLogin, "") != 0)
|
||||
if (const auto newLogin = json["login"].get<std::string>(); strcmp(newLogin.c_str(), "") != 0)
|
||||
{
|
||||
OTALogin = newLogin;
|
||||
}
|
||||
}
|
||||
|
||||
if (const auto OTAPasswordObject = cJSON_GetObjectItem(parsedJson, "password"); OTAPasswordObject != nullptr)
|
||||
if (json.contains("password") && json["password"].is_string())
|
||||
{
|
||||
OTAPassword = OTAPasswordObject->valuestring;
|
||||
OTAPassword = json["password"].get<std::string>();
|
||||
}
|
||||
|
||||
if (const auto OTAPortObject = cJSON_GetObjectItem(parsedJson, "port"); OTAPortObject != nullptr)
|
||||
if (json.contains("port") && json["port"].is_number_integer())
|
||||
{
|
||||
if (const auto newPort = OTAPortObject->valueint; newPort >= 82)
|
||||
if (const auto newPort = json["port"].get<int>(); newPort >= 82)
|
||||
{
|
||||
OTAPort = newPort;
|
||||
}
|
||||
}
|
||||
|
||||
cJSON_Delete(parsedJson);
|
||||
|
||||
projectConfig->setOTAConfig(OTALogin, OTAPassword, OTAPort);
|
||||
return CommandResult::getSuccessResult("OTA Config set");
|
||||
}
|
||||
|
||||
CommandResult updateLEDDutyCycleCommand(std::shared_ptr<DependencyRegistry> registry, std::string_view jsonPayload)
|
||||
CommandResult updateLEDDutyCycleCommand(std::shared_ptr<DependencyRegistry> registry, const nlohmann::json &json)
|
||||
{
|
||||
const auto parsedJson = cJSON_Parse(jsonPayload.data());
|
||||
if (parsedJson == nullptr)
|
||||
{
|
||||
return CommandResult::getErrorResult("Invalid payload");
|
||||
}
|
||||
|
||||
const auto dutyCycleObject = cJSON_GetObjectItem(parsedJson, "dutyCycle");
|
||||
if (dutyCycleObject == nullptr)
|
||||
if (!json.contains("dutyCycle") || !json["dutyCycle"].is_number_integer())
|
||||
{
|
||||
return CommandResult::getErrorResult("Invalid payload - missing dutyCycle");
|
||||
}
|
||||
|
||||
const auto dutyCycle = dutyCycleObject->valueint;
|
||||
const auto dutyCycle = json["dutyCycle"].get<int>();
|
||||
|
||||
if (dutyCycle < 0 || dutyCycle > 100)
|
||||
{
|
||||
@@ -107,8 +81,6 @@ CommandResult updateLEDDutyCycleCommand(std::shared_ptr<DependencyRegistry> regi
|
||||
ledMgr->setExternalLEDDutyCycle(static_cast<uint8_t>(dutyCycle));
|
||||
}
|
||||
|
||||
cJSON_Delete(parsedJson);
|
||||
|
||||
return CommandResult::getSuccessResult("LED duty cycle set");
|
||||
}
|
||||
|
||||
@@ -145,34 +117,28 @@ CommandResult startStreamingCommand()
|
||||
return CommandResult::getSuccessResult("Streaming starting");
|
||||
}
|
||||
|
||||
CommandResult switchModeCommand(std::shared_ptr<DependencyRegistry> registry, std::string_view jsonPayload)
|
||||
CommandResult switchModeCommand(std::shared_ptr<DependencyRegistry> registry, const nlohmann::json &json)
|
||||
{
|
||||
const auto parsedJson = cJSON_Parse(jsonPayload.data());
|
||||
if (parsedJson == nullptr)
|
||||
{
|
||||
return CommandResult::getErrorResult("Invalid payload");
|
||||
}
|
||||
|
||||
const auto modeObject = cJSON_GetObjectItem(parsedJson, "mode");
|
||||
if (modeObject == nullptr)
|
||||
if (!json.contains("mode") || !json["mode"].is_string())
|
||||
{
|
||||
return CommandResult::getErrorResult("Invalid payload - missing mode");
|
||||
}
|
||||
|
||||
const char *modeStr = modeObject->valuestring;
|
||||
auto modeStr = json["mode"].get<std::string>();
|
||||
StreamingMode newMode;
|
||||
|
||||
ESP_LOGI("[DEVICE_COMMANDS]", "Switch mode command received with mode: %s", modeStr);
|
||||
ESP_LOGI("[DEVICE_COMMANDS]", "Switch mode command received with mode: %s", modeStr.c_str());
|
||||
|
||||
if (strcmp(modeStr, "uvc") == 0)
|
||||
if (modeStr == "uvc")
|
||||
{
|
||||
newMode = StreamingMode::UVC;
|
||||
}
|
||||
else if (strcmp(modeStr, "wifi") == 0)
|
||||
else if (modeStr == "wifi")
|
||||
{
|
||||
newMode = StreamingMode::WIFI;
|
||||
}
|
||||
else if (strcmp(modeStr, "setup") == 0 || strcmp(modeStr, "auto") == 0)
|
||||
else if (modeStr == "setup" || modeStr == "auto"))
|
||||
{
|
||||
newMode = StreamingMode::SETUP;
|
||||
}
|
||||
@@ -185,8 +151,6 @@ CommandResult switchModeCommand(std::shared_ptr<DependencyRegistry> registry, st
|
||||
ESP_LOGI("[DEVICE_COMMANDS]", "Setting device mode to: %d", (int)newMode);
|
||||
projectConfig->setDeviceMode(newMode);
|
||||
|
||||
cJSON_Delete(parsedJson);
|
||||
|
||||
return CommandResult::getSuccessResult("Device mode switched, restart to apply");
|
||||
}
|
||||
|
||||
|
||||
@@ -3,22 +3,22 @@
|
||||
#include "OpenIrisTasks.hpp"
|
||||
#include "DependencyRegistry.hpp"
|
||||
#include "esp_timer.h"
|
||||
#include "cJSON.h"
|
||||
#include "main_globals.hpp"
|
||||
|
||||
#include <format>
|
||||
#include <string>
|
||||
#include <nlohmann-json.hpp>
|
||||
|
||||
CommandResult updateOTACredentialsCommand(std::shared_ptr<DependencyRegistry> registry, std::string_view jsonPayload);
|
||||
CommandResult updateOTACredentialsCommand(std::shared_ptr<DependencyRegistry> registry, const nlohmann::json &json);
|
||||
|
||||
CommandResult updateLEDDutyCycleCommand(std::shared_ptr<DependencyRegistry> registry, std::string_view jsonPayload);
|
||||
CommandResult updateLEDDutyCycleCommand(std::shared_ptr<DependencyRegistry> registry, const nlohmann::json &json);
|
||||
CommandResult getLEDDutyCycleCommand(std::shared_ptr<DependencyRegistry> registry);
|
||||
|
||||
CommandResult restartDeviceCommand();
|
||||
|
||||
CommandResult startStreamingCommand();
|
||||
|
||||
CommandResult switchModeCommand(std::shared_ptr<DependencyRegistry> registry, std::string_view jsonPayload);
|
||||
CommandResult switchModeCommand(std::shared_ptr<DependencyRegistry> registry, const nlohmann::json &json);
|
||||
|
||||
CommandResult getDeviceModeCommand(std::shared_ptr<DependencyRegistry> registry);
|
||||
|
||||
|
||||
@@ -1,33 +1,13 @@
|
||||
#include "mdns_commands.hpp"
|
||||
|
||||
std::optional<MDNSPayload> parseMDNSCommandPayload(std::string_view jsonPayload)
|
||||
CommandResult setMDNSCommand(std::shared_ptr<DependencyRegistry> registry, const nlohmann::json &json)
|
||||
{
|
||||
MDNSPayload payload;
|
||||
cJSON *parsedJson = cJSON_Parse(jsonPayload.data());
|
||||
if (parsedJson == nullptr)
|
||||
return std::nullopt;
|
||||
|
||||
cJSON *hostnameObject = cJSON_GetObjectItem(parsedJson, "hostname");
|
||||
|
||||
if (hostnameObject == nullptr)
|
||||
{
|
||||
cJSON_Delete(parsedJson);
|
||||
return std::nullopt;
|
||||
}
|
||||
|
||||
payload.hostname = std::string(hostnameObject->valuestring);
|
||||
cJSON_Delete(parsedJson);
|
||||
return payload;
|
||||
}
|
||||
|
||||
CommandResult setMDNSCommand(std::shared_ptr<DependencyRegistry> registry, std::string_view jsonPayload)
|
||||
{
|
||||
auto payload = parseMDNSCommandPayload(jsonPayload);
|
||||
if (!payload.has_value())
|
||||
return CommandResult::getErrorResult("Invalid payload");
|
||||
const auto payload = json.get<MDNSPayload>();
|
||||
if (payload.hostname.empty())
|
||||
return CommandResult::getErrorResult("Invalid payload - empty hostname");
|
||||
|
||||
std::shared_ptr<ProjectConfig> projectConfig = registry->resolve<ProjectConfig>(DependencyType::project_config);
|
||||
projectConfig->setMDNSConfig(payload.value().hostname);
|
||||
projectConfig->setMDNSConfig(payload.hostname);
|
||||
|
||||
return CommandResult::getSuccessResult("Config updated");
|
||||
}
|
||||
|
||||
@@ -2,11 +2,10 @@
|
||||
#include <memory>
|
||||
#include <string>
|
||||
#include <optional>
|
||||
#include <cJSON.h>
|
||||
#include "CommandResult.hpp"
|
||||
#include "CommandSchema.hpp"
|
||||
#include "DependencyRegistry.hpp"
|
||||
#include <nlohmann-json.hpp>
|
||||
|
||||
std::optional<MDNSPayload> parseMDNSCommandPayload(std::string_view jsonPayload);
|
||||
CommandResult setMDNSCommand(std::shared_ptr<DependencyRegistry> registry, std::string_view jsonPayload);
|
||||
CommandResult setMDNSCommand(std::shared_ptr<DependencyRegistry> registry, const nlohmann::json &json);
|
||||
CommandResult getMDNSNameCommand(std::shared_ptr<DependencyRegistry> registry);
|
||||
@@ -14,29 +14,24 @@ CommandResult scanNetworksCommand(std::shared_ptr<DependencyRegistry> registry)
|
||||
|
||||
auto networks = wifiManager->ScanNetworks();
|
||||
|
||||
cJSON *root = cJSON_CreateObject();
|
||||
cJSON *networksArray = cJSON_CreateArray();
|
||||
cJSON_AddItemToObject(root, "networks", networksArray);
|
||||
nlohmann::json result;
|
||||
std::vector<nlohmann::json> networksJson;
|
||||
|
||||
for (const auto &network : networks)
|
||||
{
|
||||
cJSON *networkObject = cJSON_CreateObject();
|
||||
cJSON_AddStringToObject(networkObject, "ssid", network.ssid.c_str());
|
||||
cJSON_AddNumberToObject(networkObject, "channel", network.channel);
|
||||
cJSON_AddNumberToObject(networkObject, "rssi", network.rssi);
|
||||
nlohmann::json networkItem;
|
||||
networkItem["ssid"] = network.ssid;
|
||||
networkItem["channel"] = network.channel;
|
||||
networkItem["rssi"] = network.rssi;
|
||||
char mac_str[18];
|
||||
sprintf(mac_str, "%02x:%02x:%02x:%02x:%02x:%02x",
|
||||
network.mac[0], network.mac[1], network.mac[2],
|
||||
network.mac[3], network.mac[4], network.mac[5]);
|
||||
cJSON_AddStringToObject(networkObject, "mac_address", mac_str);
|
||||
cJSON_AddNumberToObject(networkObject, "auth_mode", network.auth_mode);
|
||||
cJSON_AddItemToArray(networksArray, networkObject);
|
||||
networkItem["mac_address"] = mac_str;
|
||||
networkItem["auth_mode"] = network.auth_mode;
|
||||
networksJson.push_back(networkItem);
|
||||
}
|
||||
|
||||
char *json_string = cJSON_PrintUnformatted(root);
|
||||
printf("%s\n", json_string);
|
||||
cJSON_Delete(root);
|
||||
free(json_string);
|
||||
|
||||
return CommandResult::getSuccessResult("Networks scanned");
|
||||
result["networks"] = networksJson;
|
||||
return CommandResult::getSuccessResult(result);
|
||||
}
|
||||
@@ -4,9 +4,9 @@
|
||||
#include "CommandResult.hpp"
|
||||
#include "DependencyRegistry.hpp"
|
||||
#include "esp_log.h"
|
||||
#include <cJSON.h>
|
||||
#include <wifiManager.hpp>
|
||||
#include <string>
|
||||
#include <nlohmann-json.hpp>
|
||||
|
||||
CommandResult scanNetworksCommand(std::shared_ptr<DependencyRegistry> registry);
|
||||
|
||||
|
||||
@@ -7,27 +7,19 @@ CommandResult PingCommand()
|
||||
return CommandResult::getSuccessResult("pong");
|
||||
};
|
||||
|
||||
CommandResult PauseCommand(std::string_view jsonPayload)
|
||||
CommandResult PauseCommand(const nlohmann::json &json)
|
||||
{
|
||||
PausePayload payload;
|
||||
// pause by default if this command gets executed, even if the payload was invalid
|
||||
payload.pause = true;
|
||||
auto pause = true;
|
||||
|
||||
cJSON *root = cJSON_Parse(std::string(jsonPayload).c_str());
|
||||
if (root)
|
||||
if (json.contains("pause") && json["pause"].is_boolean())
|
||||
{
|
||||
cJSON *pauseItem = cJSON_GetObjectItem(root, "pause");
|
||||
if (pauseItem && cJSON_IsBool(pauseItem))
|
||||
{
|
||||
payload.pause = cJSON_IsTrue(pauseItem);
|
||||
}
|
||||
cJSON_Delete(root);
|
||||
pause = json["pause"].get<bool>();
|
||||
}
|
||||
|
||||
ESP_LOGI(TAG, "Pause command received: %s", payload.pause ? "true" : "false");
|
||||
ESP_LOGI(TAG, "Pause command received: %s", pause ? "true" : "false");
|
||||
|
||||
setStartupPaused(payload.pause);
|
||||
if (payload.pause)
|
||||
setStartupPaused(pause);
|
||||
if (pause)
|
||||
{
|
||||
ESP_LOGI(TAG, "Startup paused - device will remain in configuration mode");
|
||||
return CommandResult::getSuccessResult("Startup paused");
|
||||
|
||||
@@ -3,12 +3,11 @@
|
||||
|
||||
#include <string>
|
||||
#include "CommandResult.hpp"
|
||||
#include "CommandSchema.hpp"
|
||||
#include "main_globals.hpp"
|
||||
#include "esp_log.h"
|
||||
#include <cJSON.h>
|
||||
#include <nlohmann-json.hpp>
|
||||
|
||||
CommandResult PingCommand();
|
||||
CommandResult PauseCommand(std::string_view jsonPayload);
|
||||
CommandResult PauseCommand(const nlohmann::json &json);
|
||||
|
||||
#endif
|
||||
@@ -2,212 +2,76 @@
|
||||
#include "esp_netif.h"
|
||||
#include "sdkconfig.h"
|
||||
|
||||
std::optional<WifiPayload> parseSetWiFiCommandPayload(std::string_view jsonPayload)
|
||||
{
|
||||
WifiPayload payload;
|
||||
cJSON *parsedJson = cJSON_Parse(jsonPayload.data());
|
||||
|
||||
if (parsedJson == nullptr)
|
||||
return std::nullopt;
|
||||
|
||||
const cJSON *networkName = cJSON_GetObjectItem(parsedJson, "name");
|
||||
const cJSON *ssidPtr = cJSON_GetObjectItem(parsedJson, "ssid");
|
||||
const cJSON *passwordPtr = cJSON_GetObjectItem(parsedJson, "password");
|
||||
const cJSON *channelPtr = cJSON_GetObjectItem(parsedJson, "channel");
|
||||
const cJSON *powerPtr = cJSON_GetObjectItem(parsedJson, "power");
|
||||
|
||||
if (ssidPtr == nullptr)
|
||||
{
|
||||
// without an SSID we can't do anything
|
||||
cJSON_Delete(parsedJson);
|
||||
return std::nullopt;
|
||||
}
|
||||
|
||||
if (networkName == nullptr)
|
||||
payload.networkName = "main";
|
||||
else
|
||||
payload.networkName = std::string(networkName->valuestring);
|
||||
|
||||
payload.ssid = std::string(ssidPtr->valuestring);
|
||||
|
||||
if (passwordPtr == nullptr)
|
||||
payload.password = "";
|
||||
else
|
||||
payload.password = std::string(passwordPtr->valuestring);
|
||||
|
||||
if (channelPtr == nullptr)
|
||||
payload.channel = 0;
|
||||
else
|
||||
payload.channel = channelPtr->valueint;
|
||||
|
||||
if (powerPtr == nullptr)
|
||||
payload.power = 0;
|
||||
else
|
||||
payload.power = powerPtr->valueint;
|
||||
|
||||
cJSON_Delete(parsedJson);
|
||||
return payload;
|
||||
}
|
||||
|
||||
std::optional<deleteNetworkPayload> parseDeleteWifiCommandPayload(std::string_view jsonPayload)
|
||||
{
|
||||
deleteNetworkPayload payload;
|
||||
auto *parsedJson = cJSON_Parse(jsonPayload.data());
|
||||
|
||||
if (parsedJson == nullptr)
|
||||
return std::nullopt;
|
||||
|
||||
const auto *networkName = cJSON_GetObjectItem(parsedJson, "name");
|
||||
if (networkName == nullptr)
|
||||
{
|
||||
cJSON_Delete(parsedJson);
|
||||
return std::nullopt;
|
||||
}
|
||||
|
||||
payload.networkName = std::string(networkName->valuestring);
|
||||
|
||||
cJSON_Delete(parsedJson);
|
||||
return payload;
|
||||
}
|
||||
|
||||
std::optional<UpdateWifiPayload> parseUpdateWifiCommandPayload(std::string_view jsonPayload)
|
||||
{
|
||||
UpdateWifiPayload payload;
|
||||
cJSON *parsedJson = cJSON_Parse(jsonPayload.data());
|
||||
|
||||
if (parsedJson == nullptr)
|
||||
return std::nullopt;
|
||||
|
||||
const cJSON *networkName = cJSON_GetObjectItem(parsedJson, "name");
|
||||
if (networkName == nullptr)
|
||||
{
|
||||
cJSON_Delete(parsedJson);
|
||||
return std::nullopt;
|
||||
}
|
||||
|
||||
payload.networkName = std::string(networkName->valuestring);
|
||||
|
||||
const auto *ssidObject = cJSON_GetObjectItem(parsedJson, "ssid");
|
||||
const auto *passwordObject = cJSON_GetObjectItem(parsedJson, "password");
|
||||
const auto *channelObject = cJSON_GetObjectItem(parsedJson, "channel");
|
||||
const auto *powerObject = cJSON_GetObjectItem(parsedJson, "power");
|
||||
|
||||
if (ssidObject != nullptr && (strcmp(ssidObject->valuestring, "") == 0))
|
||||
{
|
||||
// we need ssid to actually connect
|
||||
cJSON_Delete(parsedJson);
|
||||
return std::nullopt;
|
||||
}
|
||||
|
||||
if (ssidObject != nullptr)
|
||||
payload.ssid = std::string(ssidObject->valuestring);
|
||||
|
||||
if (passwordObject != nullptr)
|
||||
payload.password = std::string(passwordObject->valuestring);
|
||||
|
||||
if (channelObject != nullptr)
|
||||
payload.channel = channelObject->valueint;
|
||||
|
||||
if (powerObject != nullptr)
|
||||
payload.power = powerObject->valueint;
|
||||
|
||||
cJSON_Delete(parsedJson);
|
||||
return payload;
|
||||
}
|
||||
|
||||
std::optional<UpdateAPWiFiPayload> parseUpdateAPWiFiCommandPayload(const std::string_view jsonPayload)
|
||||
{
|
||||
UpdateAPWiFiPayload payload;
|
||||
cJSON *parsedJson = cJSON_Parse(jsonPayload.data());
|
||||
|
||||
if (parsedJson == nullptr)
|
||||
{
|
||||
return std::nullopt;
|
||||
}
|
||||
|
||||
const cJSON *ssidObject = cJSON_GetObjectItem(parsedJson, "ssid");
|
||||
const cJSON *passwordObject = cJSON_GetObjectItem(parsedJson, "password");
|
||||
const cJSON *channelObject = cJSON_GetObjectItem(parsedJson, "channel");
|
||||
|
||||
if (ssidObject != nullptr)
|
||||
payload.ssid = std::string(ssidObject->valuestring);
|
||||
|
||||
if (passwordObject != nullptr)
|
||||
payload.password = std::string(passwordObject->valuestring);
|
||||
|
||||
if (channelObject != nullptr)
|
||||
payload.channel = channelObject->valueint;
|
||||
|
||||
cJSON_Delete(parsedJson);
|
||||
return payload;
|
||||
}
|
||||
|
||||
CommandResult setWiFiCommand(std::shared_ptr<DependencyRegistry> registry, std::string_view jsonPayload)
|
||||
CommandResult setWiFiCommand(std::shared_ptr<DependencyRegistry> registry, const nlohmann::json &json)
|
||||
{
|
||||
#if !CONFIG_GENERAL_ENABLE_WIRELESS
|
||||
return CommandResult::getErrorResult("Not supported by current firmware");
|
||||
return CommandResult::getErrorResult("Not supported by current firmware");
|
||||
#endif
|
||||
const auto payload = parseSetWiFiCommandPayload(jsonPayload);
|
||||
|
||||
if (!payload.has_value())
|
||||
auto payload = json.get<WifiPayload>();
|
||||
if (payload.name.empty())
|
||||
{
|
||||
return CommandResult::getErrorResult("Invalid payload");
|
||||
payload.name = std::string("main");
|
||||
}
|
||||
|
||||
if (payload.ssid.empty())
|
||||
{
|
||||
return CommandResult::getErrorResult("Invalid payload: missing SSID");
|
||||
}
|
||||
const auto wifiConfig = payload.value();
|
||||
|
||||
std::shared_ptr<ProjectConfig> projectConfig = registry->resolve<ProjectConfig>(DependencyType::project_config);
|
||||
projectConfig->setWifiConfig(
|
||||
wifiConfig.networkName,
|
||||
wifiConfig.ssid,
|
||||
wifiConfig.password,
|
||||
wifiConfig.channel,
|
||||
wifiConfig.power);
|
||||
payload.name,
|
||||
payload.ssid,
|
||||
payload.password,
|
||||
payload.channel,
|
||||
payload.power);
|
||||
|
||||
return CommandResult::getSuccessResult("Config updated");
|
||||
}
|
||||
|
||||
CommandResult deleteWiFiCommand(std::shared_ptr<DependencyRegistry> registry, std::string_view jsonPayload)
|
||||
CommandResult deleteWiFiCommand(std::shared_ptr<DependencyRegistry> registry, const nlohmann::json &json)
|
||||
{
|
||||
#if !CONFIG_GENERAL_ENABLE_WIRELESS
|
||||
return CommandResult::getErrorResult("Not supported by current firmware");
|
||||
return CommandResult::getErrorResult("Not supported by current firmware");
|
||||
#endif
|
||||
const auto payload = parseDeleteWifiCommandPayload(jsonPayload);
|
||||
if (!payload.has_value())
|
||||
|
||||
const auto payload = json.get<deleteNetworkPayload>();
|
||||
if (payload.name.empty())
|
||||
return CommandResult::getErrorResult("Invalid payload");
|
||||
|
||||
auto projectConfig = registry->resolve<ProjectConfig>(DependencyType::project_config);
|
||||
|
||||
projectConfig->deleteWifiConfig(payload.value().networkName);
|
||||
projectConfig->deleteWifiConfig(payload.name);
|
||||
return CommandResult::getSuccessResult("Config updated");
|
||||
}
|
||||
|
||||
CommandResult updateWiFiCommand(std::shared_ptr<DependencyRegistry> registry, std::string_view jsonPayload)
|
||||
CommandResult updateWiFiCommand(std::shared_ptr<DependencyRegistry> registry, const nlohmann::json &json)
|
||||
{
|
||||
#if !CONFIG_GENERAL_ENABLE_WIRELESS
|
||||
return CommandResult::getErrorResult("Not supported by current firmware");
|
||||
return CommandResult::getErrorResult("Not supported by current firmware");
|
||||
#endif
|
||||
const auto payload = parseUpdateWifiCommandPayload(jsonPayload);
|
||||
if (!payload.has_value())
|
||||
{
|
||||
return CommandResult::getErrorResult("Invalid payload");
|
||||
}
|
||||
|
||||
auto updatedConfig = payload.value();
|
||||
auto payload = json.get<UpdateWifiPayload>();
|
||||
if (payload.name.empty())
|
||||
{
|
||||
return CommandResult::getErrorResult("Invalid payload - missing network name");
|
||||
}
|
||||
|
||||
auto projectConfig = registry->resolve<ProjectConfig>(DependencyType::project_config);
|
||||
auto storedNetworks = projectConfig->getWifiConfigs();
|
||||
if (const auto networkToUpdate = std::ranges::find_if(
|
||||
storedNetworks,
|
||||
[&](auto &network){ return network.name == updatedConfig.networkName; }
|
||||
);
|
||||
storedNetworks,
|
||||
[&](auto &network)
|
||||
{ return network.name == payload.name; });
|
||||
networkToUpdate != storedNetworks.end())
|
||||
{
|
||||
projectConfig->setWifiConfig(
|
||||
updatedConfig.networkName,
|
||||
updatedConfig.ssid.has_value() ? updatedConfig.ssid.value() : networkToUpdate->ssid,
|
||||
updatedConfig.password.has_value() ? updatedConfig.password.value() : networkToUpdate->password,
|
||||
updatedConfig.channel.has_value() ? updatedConfig.channel.value() : networkToUpdate->channel,
|
||||
updatedConfig.power.has_value() ? updatedConfig.power.value() : networkToUpdate->power);
|
||||
payload.name,
|
||||
payload.ssid.has_value() ? payload.ssid.value() : networkToUpdate->ssid,
|
||||
payload.password.has_value() ? payload.password.value() : networkToUpdate->password,
|
||||
payload.channel.has_value() ? payload.channel.value() : networkToUpdate->channel,
|
||||
payload.power.has_value() ? payload.power.value() : networkToUpdate->power);
|
||||
|
||||
return CommandResult::getSuccessResult("Config updated");
|
||||
}
|
||||
@@ -215,113 +79,99 @@ CommandResult updateWiFiCommand(std::shared_ptr<DependencyRegistry> registry, st
|
||||
return CommandResult::getErrorResult("Requested network does not exist");
|
||||
}
|
||||
|
||||
CommandResult updateAPWiFiCommand(std::shared_ptr<DependencyRegistry> registry, std::string_view jsonPayload)
|
||||
CommandResult updateAPWiFiCommand(std::shared_ptr<DependencyRegistry> registry, const nlohmann::json &json)
|
||||
{
|
||||
#if !CONFIG_GENERAL_ENABLE_WIRELESS
|
||||
return CommandResult::getErrorResult("Not supported by current firmware");
|
||||
return CommandResult::getErrorResult("Not supported by current firmware");
|
||||
#endif
|
||||
const auto payload = parseUpdateAPWiFiCommandPayload(jsonPayload);
|
||||
|
||||
if (!payload.has_value())
|
||||
return CommandResult::getErrorResult("Invalid payload");
|
||||
|
||||
auto updatedConfig = payload.value();
|
||||
const auto payload = json.get<UpdateAPWiFiPayload>();
|
||||
|
||||
auto projectConfig = registry->resolve<ProjectConfig>(DependencyType::project_config);
|
||||
const auto previousAPConfig = projectConfig->getAPWifiConfig();
|
||||
|
||||
projectConfig->setAPWifiConfig(
|
||||
updatedConfig.ssid.has_value() ? updatedConfig.ssid.value() : previousAPConfig.ssid,
|
||||
updatedConfig.password.has_value() ? updatedConfig.password.value() : previousAPConfig.password,
|
||||
updatedConfig.channel.has_value() ? updatedConfig.channel.value() : previousAPConfig.channel);
|
||||
payload.ssid.has_value() ? payload.ssid.value() : previousAPConfig.ssid,
|
||||
payload.password.has_value() ? payload.password.value() : previousAPConfig.password,
|
||||
payload.channel.has_value() ? payload.channel.value() : previousAPConfig.channel);
|
||||
|
||||
return CommandResult::getSuccessResult("Config updated");
|
||||
}
|
||||
|
||||
CommandResult getWiFiStatusCommand(std::shared_ptr<DependencyRegistry> registry) {
|
||||
CommandResult getWiFiStatusCommand(std::shared_ptr<DependencyRegistry> registry)
|
||||
{
|
||||
#if !CONFIG_GENERAL_ENABLE_WIRELESS
|
||||
return CommandResult::getErrorResult("Not supported by current firmware");
|
||||
#endif
|
||||
|
||||
auto wifiManager = registry->resolve<WiFiManager>(DependencyType::wifi_manager);
|
||||
if (!wifiManager) {
|
||||
return CommandResult::getErrorResult("Not supported by current firmware");
|
||||
auto projectConfig = registry->resolve<ProjectConfig>(DependencyType::project_config);
|
||||
|
||||
auto wifiState = wifiManager->GetCurrentWiFiState();
|
||||
auto networks = projectConfig->getWifiConfigs();
|
||||
nlohmann::json result;
|
||||
|
||||
switch (wifiState)
|
||||
{
|
||||
case WiFiState_e::WiFiState_NotInitialized:
|
||||
result["status"] = "not_initialized";
|
||||
break;
|
||||
case WiFiState_e::WiFiState_Initialized:
|
||||
result["status"] = "initialized";
|
||||
break;
|
||||
case WiFiState_e::WiFiState_ReadyToConnect:
|
||||
result["status"] = "ready";
|
||||
break;
|
||||
case WiFiState_e::WiFiState_Connecting:
|
||||
result["status"] = "connecting";
|
||||
break;
|
||||
case WiFiState_e::WiFiState_WaitingForIp:
|
||||
result["status"] = "waiting_for_ip";
|
||||
break;
|
||||
case WiFiState_e::WiFiState_Connected:
|
||||
result["status"] = "connected";
|
||||
break;
|
||||
case WiFiState_e::WiFiState_Disconnected:
|
||||
result["status"] = "disconnected";
|
||||
break;
|
||||
case WiFiState_e::WiFiState_Error:
|
||||
result["status"] = "error";
|
||||
break;
|
||||
}
|
||||
auto projectConfig = registry->resolve<ProjectConfig>(DependencyType::project_config);
|
||||
|
||||
// Get current WiFi state
|
||||
auto wifiState = wifiManager->GetCurrentWiFiState();
|
||||
auto networks = projectConfig->getWifiConfigs();
|
||||
|
||||
cJSON* statusJson = cJSON_CreateObject();
|
||||
|
||||
// Add WiFi state
|
||||
const char* stateStr = "unknown";
|
||||
switch(wifiState) {
|
||||
case WiFiState_e::WiFiState_NotInitialized:
|
||||
stateStr = "not_initialized";
|
||||
break;
|
||||
case WiFiState_e::WiFiState_Initialized:
|
||||
stateStr = "initialized";
|
||||
break;
|
||||
case WiFiState_e::WiFiState_ReadyToConnect:
|
||||
stateStr = "ready";
|
||||
break;
|
||||
case WiFiState_e::WiFiState_Connecting:
|
||||
stateStr = "connecting";
|
||||
break;
|
||||
case WiFiState_e::WiFiState_WaitingForIp:
|
||||
stateStr = "waiting_for_ip";
|
||||
break;
|
||||
case WiFiState_e::WiFiState_Connected:
|
||||
stateStr = "connected";
|
||||
break;
|
||||
case WiFiState_e::WiFiState_Disconnected:
|
||||
stateStr = "disconnected";
|
||||
break;
|
||||
case WiFiState_e::WiFiState_Error:
|
||||
stateStr = "error";
|
||||
break;
|
||||
|
||||
if (wifiState == WiFiState_e::WiFiState_Connected)
|
||||
{
|
||||
// Get IP address from ESP32
|
||||
esp_netif_ip_info_t ip_info;
|
||||
esp_netif_t *netif = esp_netif_get_handle_from_ifkey("WIFI_STA_DEF");
|
||||
if (netif && esp_netif_get_ip_info(netif, &ip_info) == ESP_OK)
|
||||
{
|
||||
char ip_str[16];
|
||||
sprintf(ip_str, IPSTR, IP2STR(&ip_info.ip));
|
||||
result["ip_address"] = ip_str;
|
||||
}
|
||||
cJSON_AddStringToObject(statusJson, "status", stateStr);
|
||||
cJSON_AddNumberToObject(statusJson, "networks_configured", networks.size());
|
||||
|
||||
// Add IP info if connected
|
||||
if (wifiState == WiFiState_e::WiFiState_Connected) {
|
||||
// Get IP address from ESP32
|
||||
esp_netif_ip_info_t ip_info;
|
||||
esp_netif_t* netif = esp_netif_get_handle_from_ifkey("WIFI_STA_DEF");
|
||||
if (netif && esp_netif_get_ip_info(netif, &ip_info) == ESP_OK) {
|
||||
char ip_str[16];
|
||||
sprintf(ip_str, IPSTR, IP2STR(&ip_info.ip));
|
||||
cJSON_AddStringToObject(statusJson, "ip_address", ip_str);
|
||||
}
|
||||
}
|
||||
|
||||
char* statusString = cJSON_PrintUnformatted(statusJson);
|
||||
std::string result(statusString);
|
||||
free(statusString);
|
||||
cJSON_Delete(statusJson);
|
||||
|
||||
return CommandResult::getSuccessResult(result);
|
||||
}
|
||||
|
||||
return CommandResult::getSuccessResult(result);
|
||||
}
|
||||
|
||||
CommandResult connectWiFiCommand(std::shared_ptr<DependencyRegistry> registry) {
|
||||
CommandResult connectWiFiCommand(std::shared_ptr<DependencyRegistry> registry)
|
||||
{
|
||||
#if !CONFIG_GENERAL_ENABLE_WIRELESS
|
||||
return CommandResult::getErrorResult("Not supported by current firmware");
|
||||
#endif
|
||||
|
||||
auto wifiManager = registry->resolve<WiFiManager>(DependencyType::wifi_manager);
|
||||
if (!wifiManager) {
|
||||
return CommandResult::getErrorResult("Not supported by current firmware");
|
||||
auto projectConfig = registry->resolve<ProjectConfig>(DependencyType::project_config);
|
||||
|
||||
auto networks = projectConfig->getWifiConfigs();
|
||||
if (networks.empty())
|
||||
{
|
||||
return CommandResult::getErrorResult("No WiFi networks configured");
|
||||
}
|
||||
auto projectConfig = registry->resolve<ProjectConfig>(DependencyType::project_config);
|
||||
|
||||
auto networks = projectConfig->getWifiConfigs();
|
||||
if (networks.empty()) {
|
||||
return CommandResult::getErrorResult("No WiFi networks configured");
|
||||
}
|
||||
|
||||
// Trigger WiFi connection attempt
|
||||
wifiManager->TryConnectToStoredNetworks();
|
||||
|
||||
return CommandResult::getSuccessResult("WiFi connection attempt started");
|
||||
|
||||
// Trigger WiFi connection attempt
|
||||
wifiManager->TryConnectToStoredNetworks();
|
||||
|
||||
return CommandResult::getSuccessResult("WiFi connection attempt started");
|
||||
}
|
||||
|
||||
@@ -4,22 +4,18 @@
|
||||
#include <memory>
|
||||
#include <string>
|
||||
#include <optional>
|
||||
#include <cJSON.h>
|
||||
#include "CommandResult.hpp"
|
||||
#include "CommandSchema.hpp"
|
||||
#include "DependencyRegistry.hpp"
|
||||
#include <nlohmann-json.hpp>
|
||||
|
||||
std::optional<WifiPayload> parseSetWiFiCommandPayload(std::string_view jsonPayload);
|
||||
CommandResult setWiFiCommand(std::shared_ptr<DependencyRegistry> registry, std::string_view jsonPayload);
|
||||
CommandResult setWiFiCommand(std::shared_ptr<DependencyRegistry> registry, const nlohmann::json &json);
|
||||
|
||||
std::optional<deleteNetworkPayload> parseDeleteWifiCommandPayload(std::string_view jsonPayload);
|
||||
CommandResult deleteWiFiCommand(std::shared_ptr<DependencyRegistry> registry, std::string_view jsonPayload);
|
||||
CommandResult deleteWiFiCommand(std::shared_ptr<DependencyRegistry> registry, const nlohmann::json &json);
|
||||
|
||||
std::optional<UpdateWifiPayload> parseUpdateWifiCommandPayload(std::string_view jsonPayload);
|
||||
CommandResult updateWiFiCommand(std::shared_ptr<DependencyRegistry> registry, std::string_view jsonPayload);
|
||||
CommandResult updateWiFiCommand(std::shared_ptr<DependencyRegistry> registry, const nlohmann::json &json);
|
||||
|
||||
std::optional<UpdateAPWiFiPayload> parseUpdateAPWiFiCommandPayload(std::string_view jsonPayload);
|
||||
CommandResult updateAPWiFiCommand(std::shared_ptr<DependencyRegistry> registry, std::string_view jsonPayload);
|
||||
CommandResult updateAPWiFiCommand(std::shared_ptr<DependencyRegistry> registry, const nlohmann::json &json);
|
||||
|
||||
CommandResult getWiFiStatusCommand(std::shared_ptr<DependencyRegistry> registry);
|
||||
CommandResult connectWiFiCommand(std::shared_ptr<DependencyRegistry> registry);
|
||||
|
||||
Reference in New Issue
Block a user