bugID:17646749:[cm] add setup retry
@@ -222,21 +222,25 @@ static int _mqtt_connect(uint32_t timeout)
HAL_GetDeviceName(device_name);
HAL_GetDeviceSecret(device_secret);
- /* Device AUTH */
- if (0 != IOT_SetupConnInfo(product_key, device_name, device_secret, (void **)&pconn_info)) {
- cm_err("IOT_SetupConnInfo failed");
- return -1;
- }
+ ARGUMENT_SANITY_CHECK(strlen(device_name), FAIL_RETURN);
+ ARGUMENT_SANITY_CHECK(strlen(product_key), FAIL_RETURN);
+ iotx_time_init(&timer);
+ utils_time_countdown_ms(&timer, timeout);
+ /* Device AUTH */
+ do {
+ if (0 == IOT_SetupConnInfo(product_key, device_name, device_secret, (void **)&pconn_info)) {
mqtt_param->port = pconn_info->port;
mqtt_param->host = pconn_info->host_name;
mqtt_param->client_id = pconn_info->client_id;
mqtt_param->username = pconn_info->username;
mqtt_param->password = pconn_info->password;
mqtt_param->pub_key = pconn_info->pub_key;
-
- iotx_time_init(&timer);
- utils_time_countdown_ms(&timer, timeout);
+ break;
+ }
+ cm_err("IOT_SetupConnInfo failed");
+ HAL_SleepMs(500);
+ } while (!utils_time_is_expired(&timer));
do {
pclient = IOT_MQTT_Construct((iotx_mqtt_param_t *)_mqtt_conncection->open_params);
@@ -251,6 +255,7 @@ static int _mqtt_connect(uint32_t timeout)
}
return 0;
}
+ HAL_SleepMs(500);
} while (!utils_time_is_expired(&timer));
iotx_cm_event_msg_t event;
