167 ESP_LOGV(TAG,
"Read from serial: %s", this->
buffer_.substr(0, this->buffer_.size() - 2).c_str());
170 ESP_LOGI(TAG,
"Comment: %s", this->
buffer_.substr(0, this->buffer_.size() - 2).c_str());
173 std::string::size_type newlineposn = this->
buffer_.find(
'\n');
174 if (newlineposn <= 1) {
176 ESP_LOGD(TAG,
"Received empty line");
179 if (newlineposn <= 2) {
181 ESP_LOGD(TAG,
"Received ack: %s", this->
buffer_.substr(0, this->buffer_.size() - 2).c_str());
184 if (this->
buffer_.find(
"LensBad") != std::string::npos) {
185 ESP_LOGW(TAG,
"Received LensBad!");
188 if (this->
buffer_.find(
"EmSat") != std::string::npos) {
189 ESP_LOGW(TAG,
"Received EmSat!");
200 ESP_LOGI(TAG,
"Boot detected: %s", this->
buffer_.substr(0, this->buffer_.size() - 2).c_str());
222 std::string::size_type majend = this->
buffer_.find(
'.');
223 std::string::size_type endversion = this->
buffer_.find(
' ', 3);
224 if (majend == std::string::npos || endversion == std::string::npos || majend > endversion) {
225 ESP_LOGW(TAG,
"invalid version string: %s", this->
buffer_.substr(0, this->buffer_.size() - 2).c_str());
227 int major = strtol(this->
buffer_.substr(3, majend - 3).c_str(),
nullptr, 10);
228 int minor = strtol(this->
buffer_.substr(majend + 1, endversion - (majend + 1)).c_str(),
nullptr, 10);
230 if (major > 10 || minor >= 1000 || minor < 0 || major < 0) {
231 ESP_LOGW(TAG,
"invalid version: %s", this->
buffer_.substr(0, this->buffer_.size() - 2).c_str());
234 ESP_LOGI(TAG,
"detected sw version %i", this->
sw_version_);
237 bool is_data_line =
false;
238 for (
int i = 0; i < NUM_SENSORS; i++) {
239 if (this->
sensors_[i] !=
nullptr && this->
buffer_.find(PROTOCOL_NAMES[i]) != std::string::npos) {
245 std::string::size_type tc = this->
buffer_.find(
"TooCold");
246 this->
too_cold_ |= tc != std::string::npos;
248 ESP_LOGD(TAG,
"Received TooCold");
250 for (
int i = 0; i < NUM_SENSORS; i++) {
254 std::string::size_type n = this->
buffer_.find(PROTOCOL_NAMES[i]);
255 if (n == std::string::npos) {
259 if (n == this->
buffer_.find(
't', n)) {
263 n = this->
buffer_.find(
'F', n);
264 if (n == std::string::npos) {
269 n += strlen(PROTOCOL_NAMES[i]);
273 float data = strtof(this->
buffer_.substr(n).c_str(),
nullptr);
275 ESP_LOGD(TAG,
"Received %s: %f", PROTOCOL_NAMES[i], this->
sensors_[i]->get_raw_state());
282 for (
const auto *ignore : IGNORE_STRINGS) {
284 ESP_LOGI(TAG,
"Ignoring %s", this->
buffer_.substr(0, this->buffer_.size() - 2).c_str());
288 ESP_LOGI(TAG,
"Got unknown line: %s", this->
buffer_.c_str());