From cd7a1f0569d5d0fa5c3a3579fb654c01fbec110f Mon Sep 17 00:00:00 2001 From: Martin Vladic Date: Thu, 5 Mar 2020 11:53:28 +0100 Subject: [PATCH] mqtt lock/unlock --- src/eez/mqtt.cpp | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/src/eez/mqtt.cpp b/src/eez/mqtt.cpp index a3d579664..01a1d1e87 100644 --- a/src/eez/mqtt.cpp +++ b/src/eez/mqtt.cpp @@ -21,6 +21,7 @@ #include #if defined(EEZ_PLATFORM_STM32) +#include #include #include #include @@ -371,7 +372,9 @@ void incomingPublishCallback(void** unused, struct mqtt_response_publish *publis bool publish(char *topic, char *payload, bool retain) { #if defined(EEZ_PLATFORM_STM32) g_publishing = true; + LOCK_TCPIP_CORE(); err_t result = mqtt_publish(&g_client, topic, payload, strlen(payload), 0, retain ? 1 : 0, requestCallback, nullptr); + UNLOCK_TCPIP_CORE(); if (result != ERR_OK) { g_publishing = false; if (result != ERR_MEM) { @@ -831,7 +834,9 @@ void tick() { else if (g_connectionState == CONNECTION_STATE_DISCONNECT || g_connectionState == CONNECTION_STATE_RECONNECT) { #if defined(EEZ_PLATFORM_STM32) if (mqtt_client_is_connected(&g_client)) { + LOCK_TCPIP_CORE(); mqtt_disconnect(&g_client); + UNLOCK_TCPIP_CORE(); } #endif