From d4103ee7554e22fbc80a1f49e5d57e9892a80f0a Mon Sep 17 00:00:00 2001 From: sqozz Date: Thu, 19 Sep 2024 00:47:37 +0200 Subject: [PATCH] Remove SOURCELIST parser --- tw7100.cpp | 28 +--------------------------- 1 file changed, 1 insertion(+), 27 deletions(-) diff --git a/tw7100.cpp b/tw7100.cpp index dbc03d4..b1bbdad 100644 --- a/tw7100.cpp +++ b/tw7100.cpp @@ -98,7 +98,7 @@ std::vector pwr_on_query_cmds{ // Information "SIGNAL?", -// "SOURCELIST?" // Pushed on demand if sensor value is empty (e.g. after boot-up) +// "SOURCELIST?" // Parser present in git history but removed until esphome can update selects after api connections are established // "SOURCELISTA?", // same as SOURCELIST "LOGTO?", // produces ERR // "SNO?" // Pushed on demand if sensor value is empty (e.g. after boot-up) @@ -121,9 +121,6 @@ void tw7100Component::update() { if (this->serial_->state.length() < 1) { cmd_queue.push_back("SNO?"); } - if (sourcelist.empty()) { - cmd_queue.push_back("SOURCELIST?"); - } for (auto &cmd : pwr_on_query_cmds) { cmd_queue.push_back(cmd); } @@ -236,29 +233,6 @@ void tw7100Component::update_sensor(std::pair data) { auto call = luminance_select_->make_call(); call.set_option(luminance_select_->luminance[value_string]); call.perform(); - } else if (cmd == "SOURCELIST") { - std::string unparsed_result = value_string; - int first_token_end; - int second_token_end; - - uint8_t parse_rounds = 0; // safety fallback if data contains unexpected content - do { - first_token_end = unparsed_result.find(" "); - second_token_end = unparsed_result.find(" ", first_token_end+1); - ESP_LOGV(TAG, "first_token_end: %i, second_token_end: %i, unparsed_result.length(): %li", first_token_end, second_token_end, unparsed_result.length() ); - - std::string key_string = unparsed_result.substr(0, first_token_end); - std::string value = unparsed_result.substr(first_token_end+1, second_token_end-first_token_end-1); - int key = std::stoi(key_string, nullptr, 16); - sourcelist[key] = value; - ESP_LOGV(TAG, "Added %s with key %i(0x%02x) to sourcelist", value.c_str(), key, key); - - unparsed_result.erase(0, second_token_end+1); - ESP_LOGV(TAG, "rest string: %s", unparsed_result.c_str()); - - parse_rounds+=1; - } while (second_token_end > 0 && parse_rounds <= 50); - // TODO: if we exceed parse_rounds we most likely encountered a critical issue, inform user somehow } else if (cmd == "SNO") { serial_->publish_state(value_string); } else if (cmd == "BTAUDIO") {