From 74b38547fee6e5f507b1be81ce280ec34bdc80e4 Mon Sep 17 00:00:00 2001
From: Oleg Girko
Date: Wed, 3 Jul 2024 15:51:10 +0000
Subject: [PATCH] Improve portability between different versions of
Arduino-ESP32.
The BLECharacteristic::getValue() method returns std::string in
older versions of Arduino core for the ESP32 and String in newer
versions.
However, the return value is used in a way that both classes support:
using only length() and c_str() methods.
Hence, replacing explicit type name with auto keyword makes the code
compatible with older and newer versions.
Signed-off-by: Oleg Girko
---
src/BLE.cpp | 4 ++--
1 file changed, 2 insertions(+), 2 deletions(-)
diff --git a/src/BLE.cpp b/src/BLE.cpp
index a916557..5f230ff 100644
--- a/src/BLE.cpp
+++ b/src/BLE.cpp
@@ -38,7 +38,7 @@ public:
};
void otaCallback::onWrite(BLECharacteristic *pCharacteristic) {
- String rxData = pCharacteristic->getValue();
+ auto rxData = pCharacteristic->getValue();
if (!updateFlag) { // If it's the first packet of OTA since bootup, begin OTA
// Serial.println("Begin FW Update");
esp_ota_begin(esp_ota_get_next_update_partition(NULL), OTA_SIZE_UNKNOWN,
@@ -127,4 +127,4 @@ bool BLE::begin(const char *localName = "Watchy BLE OTA") {
int BLE::updateStatus() { return status; }
-int BLE::howManyBytes() { return bytesReceived; }
\ No newline at end of file
+int BLE::howManyBytes() { return bytesReceived; }