From c3829c180e174987240c12c17bd0010b1a958e78 Mon Sep 17 00:00:00 2001 From: James Date: Thu, 25 Apr 2024 22:26:53 +0100 Subject: [PATCH] fix --- ESPBMS.ino | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) 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