reenable error counter and indentation
This commit is contained in:
14
mqtt.c
14
mqtt.c
@@ -36,7 +36,7 @@ void messageArrived(MessageData* md)
|
|||||||
void mqtt_pub(Client* mqtt_client, char * mqtt_topic, char * mqtt_msg, int mqtt_msg_len)
|
void mqtt_pub(Client* mqtt_client, char * mqtt_topic, char * mqtt_msg, int mqtt_msg_len)
|
||||||
{
|
{
|
||||||
//static uint32_t mqtt_pub_count = 0;
|
//static uint32_t mqtt_pub_count = 0;
|
||||||
//static uint8_t mqtt_err_cnt = 0;
|
static uint8_t mqtt_err_cnt = 0;
|
||||||
int32_t mqtt_rc;
|
int32_t mqtt_rc;
|
||||||
|
|
||||||
//printf(">>MQTT pub msg nr%lu ", ++mqtt_pub_count);
|
//printf(">>MQTT pub msg nr%lu ", ++mqtt_pub_count);
|
||||||
@@ -49,18 +49,18 @@ void mqtt_pub(Client* mqtt_client, char * mqtt_topic, char * mqtt_msg, int mqtt_
|
|||||||
//Analize MQTT publish result (for MQTT failover mode)
|
//Analize MQTT publish result (for MQTT failover mode)
|
||||||
if (mqtt_rc == SUCCESSS)
|
if (mqtt_rc == SUCCESSS)
|
||||||
{
|
{
|
||||||
//mqtt_err_cnt = 0;
|
mqtt_err_cnt = 0;
|
||||||
//printf(" - OK\r\n");
|
//printf(" - OK\r\n");
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
|
//while(1);
|
||||||
|
//Reboot device after 20 continuous errors (~ 20sec)
|
||||||
|
if(mqtt_err_cnt++ > 10)
|
||||||
|
{
|
||||||
printf("mqtt pub - ERROR\r\n");
|
printf("mqtt pub - ERROR\r\n");
|
||||||
printf("Connection with MQTT Broker was lost!!\r\nReboot the board..\r\n");
|
printf("Connection with MQTT Broker was lost!!\r\nReboot the board..\r\n");
|
||||||
while(1);
|
while(1);
|
||||||
//Reboot device after 20 continuous errors (~ 20sec)
|
}
|
||||||
//if(mqtt_err_cnt++ > 20)
|
|
||||||
//{
|
|
||||||
// while(1);
|
|
||||||
//}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user