Merge pull request #197 from bobbycar-graz/esp_now_substr_fix

fix substr of esp now receive
This commit is contained in:
Peter Pötzi
2021-12-29 05:41:22 +01:00
committed by GitHub

View File

@ -37,7 +37,7 @@ extern "C" void onReceive(const uint8_t *mac_addr, const uint8_t *data, int data
if (std::string_view::npos != sep_pos)
{
std::string_view msg_type = data_str.substr(0, sep_pos);
std::string_view msg = data_str.substr(sep_pos+1, data_str.length()-3); // - 3 may needs to be converted to sep_pos+1
std::string_view msg = data_str.substr(sep_pos+1, data_str.length()-sep_pos-1);
ESP_LOGD(TAG, "Type: %.*s - Message: %.*s", msg_type.size(), msg_type.data(), msg.size(), msg.data());
message_queue.push_back(esp_now_message_t {