Fixed infinit loop when MQTT broker closed
This commit is contained in:
@@ -30,6 +30,7 @@ static uint32_t color_picker(char*);
|
|||||||
static sFONT* font;
|
static sFONT* font;
|
||||||
static uint16_t xpos;
|
static uint16_t xpos;
|
||||||
static uint16_t ypos;
|
static uint16_t ypos;
|
||||||
|
static uint16_t connection_attempt_counter;
|
||||||
static uint32_t color;
|
static uint32_t color;
|
||||||
static uint32_t bgcolor;
|
static uint32_t bgcolor;
|
||||||
static int inpub_id;
|
static int inpub_id;
|
||||||
@@ -190,8 +191,12 @@ static void mqtt_connection_cb(mqtt_client_t *client, void *arg, mqtt_connection
|
|||||||
} else {
|
} else {
|
||||||
LOG_INFO(TAG, "mqtt_connection_cb: Disconnected, reason: %d", status);
|
LOG_INFO(TAG, "mqtt_connection_cb: Disconnected, reason: %d", status);
|
||||||
|
|
||||||
//try to reconnect
|
while (connection_attempt_counter < 50) {
|
||||||
mosquitto_connect(client);
|
connection_attempt_counter++;
|
||||||
|
//try to reconnect
|
||||||
|
mosquitto_connect(client);
|
||||||
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -230,6 +235,7 @@ void mug_init(void) {
|
|||||||
font = LCD_FONT16;
|
font = LCD_FONT16;
|
||||||
xpos = 50;
|
xpos = 50;
|
||||||
ypos = 50;
|
ypos = 50;
|
||||||
|
connection_attempt_counter = 0;
|
||||||
|
|
||||||
mqtt_client_t *client = mqtt_client_new();
|
mqtt_client_t *client = mqtt_client_new();
|
||||||
if (client != NULL) {
|
if (client != NULL) {
|
||||||
|
|||||||
Reference in New Issue
Block a user