Skip to content

Commit

Permalink
mqtt lock/unlock
Browse files Browse the repository at this point in the history
  • Loading branch information
mvladic committed Mar 5, 2020
1 parent a118210 commit cd7a1f0
Showing 1 changed file with 5 additions and 0 deletions.
5 changes: 5 additions & 0 deletions src/eez/mqtt.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@
#include <stdlib.h>

#if defined(EEZ_PLATFORM_STM32)
#include <tcpip.h>
#include <api.h>
#include <mqtt.h>
#include <mqtt_priv.h>
Expand Down Expand Up @@ -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) {
Expand Down Expand Up @@ -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

Expand Down

0 comments on commit cd7a1f0

Please sign in to comment.