/****************************************************************************
- * apps/base/mqtt/main.c
+ * apps/base/mqtt_pub/main.c
*
* MQTT client example using data from onboard TMP101 I2C temperature sensor
*
} else {
uprintf(dbg_uart, "Connection refused: %d\n", response->ret_code);
mqtt_comm_state = MQTT_UNCONNECTED;
+ return -4;
}
break;
}
ret = mqtt_check_publish_response_pkt(response, MQTT_WAITING_PUBACK);
if (ret != 0) {
uprintf(dbg_uart, "Not a connack packet (ret: %d) ... protocol flow error\n", ret);
- return -3;
+ return -5;
+ }
+ if (response->acked_pkt_id != pub_packet_id) {
+ uprintf(dbg_uart, "Not a connack for the right packet (got %d, our is %d) ...\n",
+ response->acked_pkt_id, pub_packet_id);
+ return -6;
}
mqtt_comm_state = MQTT_IDLE;
+ pub_packet_id++;
break;
}
case MQTT_WAITING_PUBREC:
/* Check for received packet on serial line and handle them */
if (packet_ok != NULL) {
int ret = mqtt_handle_packet((char*)packet_ok, UART0, UART0);
+ if (ret != 0) {
+ uprintf(UART0, "Packet handling returned error %d\n", ret);
+ }
packet_ok = NULL;
}
chenillard(250);