diff --git a/main/application.cc b/main/application.cc index 6d4292c6..c223054f 100644 --- a/main/application.cc +++ b/main/application.cc @@ -466,6 +466,28 @@ void Application::Start() { thing_manager.Invoke(command); } } + } else if (strcmp(type->valuestring, "system") == 0) { + auto command = cJSON_GetObjectItem(root, "command"); + if (command != NULL) { + ESP_LOGI(TAG, "System command: %s", command->valuestring); + if (strcmp(command->valuestring, "reboot") == 0) { + // Do a reboot if user requests a OTA update + Schedule([this]() { + Reboot(); + }); + } else { + ESP_LOGW(TAG, "Unknown system command: %s", command->valuestring); + } + } + } else if (strcmp(type->valuestring, "alert") == 0) { + auto status = cJSON_GetObjectItem(root, "status"); + auto message = cJSON_GetObjectItem(root, "message"); + auto emotion = cJSON_GetObjectItem(root, "emotion"); + if (status != NULL && message != NULL && emotion != NULL) { + Alert(status->valuestring, message->valuestring, emotion->valuestring, Lang::Sounds::P3_VIBRATION); + } else { + ESP_LOGW(TAG, "Alert command requires status, message and emotion"); + } } }); protocol_->Start();