Skip to content

Commit 6e73a11

Browse files
committed
Add two types, system and alert.
1 parent d5d8b34 commit 6e73a11

File tree

1 file changed

+22
-0
lines changed

1 file changed

+22
-0
lines changed

main/application.cc

Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -466,6 +466,28 @@ void Application::Start() {
466466
thing_manager.Invoke(command);
467467
}
468468
}
469+
} else if (strcmp(type->valuestring, "system") == 0) {
470+
auto command = cJSON_GetObjectItem(root, "command");
471+
if (command != NULL) {
472+
ESP_LOGI(TAG, "System command: %s", command->valuestring);
473+
if (strcmp(command->valuestring, "reboot") == 0) {
474+
// Do a reboot if user requests a OTA update
475+
Schedule([this]() {
476+
Reboot();
477+
});
478+
} else {
479+
ESP_LOGW(TAG, "Unknown system command: %s", command->valuestring);
480+
}
481+
}
482+
} else if (strcmp(type->valuestring, "alert") == 0) {
483+
auto status = cJSON_GetObjectItem(root, "status");
484+
auto message = cJSON_GetObjectItem(root, "message");
485+
auto emotion = cJSON_GetObjectItem(root, "emotion");
486+
if (status != NULL && message != NULL && emotion != NULL) {
487+
Alert(status->valuestring, message->valuestring, emotion->valuestring, Lang::Sounds::P3_VIBRATION);
488+
} else {
489+
ESP_LOGW(TAG, "Alert command requires status, message and emotion");
490+
}
469491
}
470492
});
471493
protocol_->Start();

0 commit comments

Comments
 (0)