From 776ed6568d3c4af2fd514d9a2a7c1b386a5eab44 Mon Sep 17 00:00:00 2001 From: Florian Date: Tue, 17 Sep 2024 08:29:36 -0400 Subject: [PATCH] [BT] Fix crash when sending multiple BT commands at the same time (#2059) Co-authored-by: Florian <1technophile@users.noreply.github.com> --- main/ZgatewayBT.ino | 10 ++++++++-- 1 file changed, 8 insertions(+), 2 deletions(-) diff --git a/main/ZgatewayBT.ino b/main/ZgatewayBT.ino index cd4cf86..765f54c 100644 --- a/main/ZgatewayBT.ino +++ b/main/ZgatewayBT.ino @@ -1551,8 +1551,14 @@ void MQTTtoBT(char* topicOri, JsonObject& BTdata) { // json object decoding BTConfig_fromJson(BTdata); } else if (cmpToMainTopic(topicOri, subjectMQTTtoBT)) { - KnownBTActions(BTdata); - MQTTtoBTAction(BTdata); + if (xSemaphoreTake(semaphoreBLEOperation, pdMS_TO_TICKS(5000)) == pdTRUE) { + KnownBTActions(BTdata); + MQTTtoBTAction(BTdata); + xSemaphoreGive(semaphoreBLEOperation); + } else { + Log.error(F("BLE busy - command not sent" CR)); + gatewayState = GatewayState::ERROR; + } } } #endif