[BT] Fix BLE MQTT command trigger a reset (#1698)

Problem introduced with the bump of ESP32 platform from 3.5.0 to 6.1.0
This commit is contained in:
Florian authored and GitHub committed 2023-06-26 05:13:41 -05:00
1 parent 7b3b14e254
commit 5ff086a296
3 files changed
+9 -6

No files matched your search

+5 -3
View File
@@ -1361,7 +1361,8 @@ void MQTTtoBTAction(JsonObject& BTdata) {
if (BTdata.containsKey("SBS1")) {
strcpy(action.addr, (const char*)BTdata["mac"]);
action.write = true;
action.value = BTdata["SBS1"].as<std::string>();
std::string val = BTdata["SBS1"].as<std::string>(); // Fix #1694
action.value = val;
action.ttl = 1;
createOrUpdateDevice(action.addr, device_flags_connect,
TheengsDecoder::BLE_ID_NUM::SBS1, 1);
@@ -1397,7 +1398,8 @@ void MQTTtoBTAction(JsonObject& BTdata) {
strcpy(action.addr, (const char*)BTdata["ble_write_address"]);
action.service = NimBLEUUID((const char*)BTdata["ble_write_service"]);
action.characteristic = NimBLEUUID((const char*)BTdata["ble_write_char"]);
action.value = std::string((const char*)BTdata["ble_write_value"]);
std::string val = BTdata["ble_write_value"].as<std::string>(); // Fix #1694
action.value = val;
action.write = true;
Log.trace(F("BLE ACTION Write" CR));
} else if (BTdata.containsKey("ble_read_address") &&
@@ -1464,7 +1466,7 @@ void MQTTtoBT(char* topicOri, JsonObject& BTdata) { // json object decoding
if (BTdata.containsKey("lowpowermode")) {
changelowpowermode((int)BTdata["lowpowermode"]);
}
} else if (cmpToMainTopic(topicOri, subjectMQTTtoBT)) {
MQTTtoBTAction(BTdata);
}
}
+1
View File
@@ -46,6 +46,7 @@ extern int btQueueLengthCount;
/*-----------BT TOPICS & COMPILATION PARAMETERS-----------*/
#define subjectBTtoMQTT "/BTtoMQTT"
#define subjectMQTTtoBTset "/commands/MQTTtoBT/config"
#define subjectMQTTtoBT "/commands/MQTTtoBT"
// Uncomment to send undecoded device data to another gateway device for decoding
// #define MQTTDecodeTopic "undecoded"
#ifndef UseExtDecoder