Other Parts Discussed in Thread: CC3200, CC3100, CC3200SDK
Hi,
While using the cc3200 sdk 1.1.0 mqtt library, I come into a problem while testing error handling. The scenario can be easily reproduced by
1. Using mqtt client and set the keepalive value to zero
2. Turn off the MQTT server
3. A timer is used to ask the MQTT client to periodically connect to to the unexisted MQTT server
4. After a few try, a MQP alloc failed error with msg type 0x1 is reported.
5. At the stage, when the MQTT server is up, we are not able to connect to the server any more. We have tried to re-create the MQTT context, by the alloc error still reported. Please let me know how we can release those memory.
The following is the log file and the code we have.
Thanks,
Regards,
Michael
Version: Client LIB 1.0.3, Common LIB 1.1.1.
[MQTTClientTask]MQTT Client lib initialization success
[MQTTClientTask] Create MQTT Context
[StaleCounter]increment counter 1
Recieve event for MQTTQueue 81
[MQTTClient] result = FFFFFFFF
[MQTTClient] Broker connect fail for conn
[MQTTClient] Client disconnect
[StaleCounter]set to STale Counter
Recieve event for MQTTQueue 81
[MQTTClient] result = FFFFFFFF
[MQTTClient] Broker connect fail for conn
[MQTTClient] Client disconnect
[TimerGPIOTASK] Receive GPIO INT
[Motion Counter]set to Motion Counter
[TimerGPIOTASK] Receive GPIO INT
[TimerGPIOTASK] Receive GPIO INT
[StaleCounter]increment counter 0
Recieve event for MQTTQueue 81
MQP alloc failed - msg type 0x01
[MQTTClient] result = FFFFFFFF
[MQTTClient] Broker connect fail for conn
[MQTTClient] Client disconnect
[MQTTClient] delete context <<<<
[StaleCounter]increment counter 1
Recieve event for MQTTQueue 81
[MQTTClientTask] Create MQTT Context <<<<<
[StaleCounter]set to STale Counter
Recieve event for MQTTQueue 81
MQP alloc failed - msg type 0x01 <<<<<
[MQTTClient] result = FFFFFFFF
if(!local_con_conf[0].is_initial){
lRetVal = sl_ExtLib_MqttClientInit(&Mqtt_Client);
if(lRetVal != 0)
{
// lib initialization failed
Report("[MQTTClientTask] MQTT Client lib initialization failed\n\r");
break;
}
else {
local_con_conf[0].is_initial = true;
UART_PRINT("[MQTTClientTask]MQTT Client lib initialization success\n\r");
}
}
if(local_con_conf[0].clt_ctx == NULL) {
UART_PRINT("[MQTTClientTask] Create MQTT Context\n\r");
local_con_conf[0].clt_ctx= sl_ExtLib_MqttClientCtxCreate(&local_con_conf[0].broker_config,
&local_con_conf[0].CallBAcks,
&(local_con_conf[0]));
//
// Set Client ID
//
sl_ExtLib_MqttClientSet((void*)local_con_conf[0].clt_ctx,
SL_MQTT_PARAM_CLIENT_ID,
local_con_conf[0].client_id,
strlen((char*)(local_con_conf[0].client_id)));
}
else if(!local_con_conf[0].is_connected){
signed long result = sl_ExtLib_MqttClientConnect((void*)local_con_conf[0].clt_ctx,
local_con_conf[0].is_clean,
local_con_conf[0].keep_alive_time);
UART_PRINT("[MQTTClient] result = %2X\n\r", result);
if((result & 0xFF) != 0)
{
CLR_STATUS_BIT(g_ulmqttStatus, STATUS_BIT_MQTT_SEND);
UART_PRINT("\n\r[MQTTClient] Broker connect fail for conn \n\r");
sl_ExtLib_MqttClientDisconnect((void*)local_con_conf[0].clt_ctx);
UART_PRINT("[MQTTClient] Client disconnect\n\r");
if(local_con_conf[0].counter < MQTT_MAX_COUNTER)
local_con_conf[0].counter++;
else {
UART_PRINT("[MQTTClient] delete context\n\r");
sl_ExtLib_MqttClientCtxDelete(local_con_conf[0].clt_ctx);
local_con_conf[0].counter = 0;
local_con_conf[0].clt_ctx = NULL;
}
}
else {
local_con_conf[0].is_connected = TRUE;
local_con_conf[0].counter = 0;
}
}