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 uint16_t xpos;
|
||||
static uint16_t ypos;
|
||||
static uint16_t connection_attempt_counter;
|
||||
static uint32_t color;
|
||||
static uint32_t bgcolor;
|
||||
static int inpub_id;
|
||||
@@ -190,8 +191,12 @@ static void mqtt_connection_cb(mqtt_client_t *client, void *arg, mqtt_connection
|
||||
} else {
|
||||
LOG_INFO(TAG, "mqtt_connection_cb: Disconnected, reason: %d", status);
|
||||
|
||||
//try to reconnect
|
||||
mosquitto_connect(client);
|
||||
while (connection_attempt_counter < 50) {
|
||||
connection_attempt_counter++;
|
||||
//try to reconnect
|
||||
mosquitto_connect(client);
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
@@ -230,6 +235,7 @@ void mug_init(void) {
|
||||
font = LCD_FONT16;
|
||||
xpos = 50;
|
||||
ypos = 50;
|
||||
connection_attempt_counter = 0;
|
||||
|
||||
mqtt_client_t *client = mqtt_client_new();
|
||||
if (client != NULL) {
|
||||
|
||||
Reference in New Issue
Block a user