forked from xiaozhi/xiaozhi-esp32
Add two types, system and alert.
This commit is contained in:
@@ -466,6 +466,28 @@ void Application::Start() {
|
|||||||
thing_manager.Invoke(command);
|
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();
|
protocol_->Start();
|
||||||
|
|||||||
Reference in New Issue
Block a user