forked from xiaozhi/xiaozhi-esp32
sending part of IoT states
This commit is contained in:
@@ -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);
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user