diff --git a/ESPBMS.ino b/ESPBMS.ino index 72d20c3..9d11b2d 100644 --- a/ESPBMS.ino +++ b/ESPBMS.ino @@ -18,7 +18,7 @@ void setup() { Serial.println("Scanning..."); } -std::__cxx11::string currentName; +char currentName[128]; bool gotBasicInfo; bool gotCellInfo; @@ -97,7 +97,11 @@ void loop() { gotBasicInfo=false; gotCellInfo=false; - currentName=advertisedDevice.getName(); + + std::__cxx11::string deviceName = advertisedDevice.getName(); + strncpy(currentName, deviceName.c_str(), sizeof(currentName) - 1); + currentName[sizeof(currentName) - 1] = '\0'; // Ensure null-termination + while(gotBasicInfo==false || gotCellInfo==false){ // REQUEST BASIC INFO // header status command length data checksum footer