169 ESP_LOGV(TAG,
"Read from serial: %s", this->
buffer_.substr(0, this->buffer_.size() - 2).c_str());
172 ESP_LOGI(TAG,
"Comment: %s", this->
buffer_.substr(0, this->buffer_.size() - 2).c_str());
175 std::string::size_type newlineposn = this->
buffer_.find(
'\n');
176 if (newlineposn <= 1) {
178 ESP_LOGD(TAG,
"Received empty line");
181 if (newlineposn <= 2) {
183 ESP_LOGD(TAG,
"Received ack: %s", this->
buffer_.substr(0, this->buffer_.size() - 2).c_str());
186 if (this->
buffer_.find(
"LensBad") != std::string::npos) {
187 ESP_LOGW(TAG,
"Received LensBad!");
190 if (this->
buffer_.find(
"EmSat") != std::string::npos) {
191 ESP_LOGW(TAG,
"Received EmSat!");
202 ESP_LOGI(TAG,
"Boot detected: %s", this->
buffer_.substr(0, this->buffer_.size() - 2).c_str());
224 std::string::size_type majend = this->
buffer_.find(
'.');
225 std::string::size_type endversion = this->
buffer_.find(
' ', 3);
226 if (majend == std::string::npos || endversion == std::string::npos || majend > endversion) {
227 ESP_LOGW(TAG,
"invalid version string: %s", this->
buffer_.substr(0, this->buffer_.size() - 2).c_str());
229 int major = strtol(this->
buffer_.substr(3, majend - 3).c_str(),
nullptr, 10);
230 int minor = strtol(this->
buffer_.substr(majend + 1, endversion - (majend + 1)).c_str(),
nullptr, 10);
232 if (major > 10 || minor >= 1000 || minor < 0 || major < 0) {
233 ESP_LOGW(TAG,
"invalid version: %s", this->
buffer_.substr(0, this->buffer_.size() - 2).c_str());
236 ESP_LOGI(TAG,
"detected sw version %i", this->
sw_version_);
239 bool is_data_line =
false;
240 for (
int i = 0; i < NUM_SENSORS; i++) {
241 if (this->
sensors_[i] !=
nullptr && this->
buffer_.find(PROTOCOL_NAMES[i]) != std::string::npos) {
247 std::string::size_type tc = this->
buffer_.find(
"TooCold");
248 this->
too_cold_ |= tc != std::string::npos;
250 ESP_LOGD(TAG,
"Received TooCold");
252 for (
int i = 0; i < NUM_SENSORS; i++) {
256 std::string::size_type n = this->
buffer_.find(PROTOCOL_NAMES[i]);
257 if (n == std::string::npos) {
261 if (n == this->
buffer_.find(
't', n)) {
265 n = this->
buffer_.find(
'F', n);
266 if (n == std::string::npos) {
271 n += strlen(PROTOCOL_NAMES[i]);
275 float data = strtof(this->
buffer_.substr(n).c_str(),
nullptr);
277 ESP_LOGD(TAG,
"Received %s: %f", PROTOCOL_NAMES[i], this->
sensors_[i]->get_raw_state());
284 for (
const auto *ignore : IGNORE_STRINGS) {
286 ESP_LOGI(TAG,
"Ignoring %s", this->
buffer_.substr(0, this->buffer_.size() - 2).c_str());
290 ESP_LOGI(TAG,
"Got unknown line: %s", this->
buffer_.c_str());