sending part of IoT states

This commit is contained in:
Xiaoxia
2025-03-08 04:04:40 +08:00
parent b8bf6bea2e
commit 8267f59a6a
5 changed files with 33 additions and 16 deletions

View File

@@ -383,10 +383,12 @@ void Application::Start() {
protocol_->server_sample_rate(), codec->output_sample_rate());
}
SetDecodeSampleRate(protocol_->server_sample_rate());
// IoT device descriptors
last_iot_states_.clear();
auto& thing_manager = iot::ThingManager::GetInstance();
protocol_->SendIotDescriptors(thing_manager.GetDescriptorsJson());
std::string states;
if (thing_manager.GetStatesJson(states, false)) {
protocol_->SendIotStates(states);
}
});
protocol_->OnAudioChannelClosed([this, &board]() {
board.SetPowerSaveMode(true);
@@ -789,9 +791,8 @@ void Application::SetDecodeSampleRate(int sample_rate) {
void Application::UpdateIotStates() {
auto& thing_manager = iot::ThingManager::GetInstance();
auto states = thing_manager.GetStatesJson();
if (states != last_iot_states_) {
last_iot_states_ = states;
std::string states;
if (thing_manager.GetStatesJson(states, true)) {
protocol_->SendIotStates(states);
}
}