- Timestamp:
- Jun 22, 2021, 9:00:19 PM (3 years ago)
- Location:
- azure_iot_hub_f767zi/trunk/azure_iot_sdk/provisioning_client/src
- Files:
-
- 3 edited
Legend:
- Unmodified
- Added
- Removed
-
azure_iot_hub_f767zi/trunk/azure_iot_sdk/provisioning_client/src/prov_device_client.c
r457 r464 15 15 16 16 #define DO_WORK_FREQ_DEFAULT 1 17 18 static const char* const OPTION_DO_WORK_FREQUENCY_IN_MS = "do_work_freq_ms";19 17 20 18 typedef struct PROV_DEVICE_INSTANCE_TAG … … 260 258 { 261 259 /* Codes_SRS_PROV_DEVICE_CLIENT_41_001: [ If parameter `optionName` is `OPTION_DO_WORK_FREQUENCY_IN_MS` then `IoTHubClientCore_SetOption` shall set `do_work_freq_ms` parameter of `prov_device_instance` ] */ 262 if (strcmp( OPTION_DO_WORK_FREQUENCY_IN_MS, optionName) == 0)260 if (strcmp(PROV_OPTION_DO_WORK_FREQUENCY_IN_MS, optionName) == 0) 263 261 { 264 262 prov_device_instance->do_work_freq_ms = *((uint16_t *)value); -
azure_iot_hub_f767zi/trunk/azure_iot_sdk/provisioning_client/src/prov_device_ll_client.c
r457 r464 93 93 TICK_COUNTER_HANDLE tick_counter; 94 94 95 tickcounter_ms_t status_throttle;95 tickcounter_ms_t last_send_time_ms; 96 96 tickcounter_ms_t timeout_value; 97 uint32_t retry_after_value;97 size_t retry_after_ms; 98 98 99 99 uint8_t prov_timeout; … … 784 784 PROV_INSTANCE_INFO* prov_info = (PROV_INSTANCE_INFO*)user_ctx; 785 785 786 prov_info->retry_after_ value = retry_interval;786 prov_info->retry_after_ms = (size_t)retry_interval * 1000; // retry_interval is in seconds. 787 787 788 788 switch (transport_status) … … 880 880 /* Codes_SRS_PROV_CLIENT_07_028: [ CLIENT_STATE_READY is the initial state after the object is created which will send a uhttp_client_open call to the http endpoint. ] */ 881 881 result->prov_state = CLIENT_STATE_READY; 882 result->retry_after_ value = PROV_GET_THROTTLE_TIME;882 result->retry_after_ms = PROV_GET_THROTTLE_TIME * 1000; 883 883 result->prov_transport_protocol = protocol(); 884 884 result->error_reason = PROV_DEVICE_RESULT_OK; … … 931 931 { 932 932 // Ensure that we are passed the throttling time and send on the first send 933 (void)tickcounter_get_current_ms(result->tick_counter, &result-> status_throttle);934 result-> status_throttle += (result->retry_after_value * 1000);933 (void)tickcounter_get_current_ms(result->tick_counter, &result->last_send_time_ms); 934 result->last_send_time_ms += result->retry_after_ms; 935 935 } 936 936 } … … 1119 1119 if (prov_info->is_connected || prov_info->prov_state == CLIENT_STATE_ERROR) 1120 1120 { 1121 tickcounter_ms_t current_time = 0; 1122 1121 1123 switch (prov_info->prov_state) 1122 1124 { 1123 1125 case CLIENT_STATE_REGISTER_SEND: 1124 /* Codes_SRS_PROV_CLIENT_07_013: [ CLIENT_STATE_REGISTER_SEND which shall construct an initial call to the service with endorsement information ] */1125 if (prov_info->prov_transport_protocol->prov_transport_register(prov_info->transport_handle, prov_transport_process_json_reply, prov_transport_create_json_payload, prov_info) != 0)1126 {1127 LogError("Failure registering device");1128 if (prov_info->error_reason == PROV_DEVICE_RESULT_OK)1129 {1130 prov_info->error_reason = PROV_DEVICE_RESULT_TRANSPORT;1131 }1132 prov_info->prov_state = CLIENT_STATE_ERROR;1133 }1134 else1135 {1136 (void)tickcounter_get_current_ms(prov_info->tick_counter, &prov_info->timeout_value);1137 prov_info->prov_state = CLIENT_STATE_REGISTER_SENT;1138 }1139 break;1140 1141 case CLIENT_STATE_STATUS_SEND:1142 {1143 tickcounter_ms_t current_time = 0;1144 1126 if (tickcounter_get_current_ms(prov_info->tick_counter, ¤t_time) != 0) 1145 1127 { … … 1150 1132 else 1151 1133 { 1152 if ((current_time - prov_info->status_throttle) / 1000 > prov_info->retry_after_value) 1134 if ((current_time - prov_info->last_send_time_ms) > prov_info->retry_after_ms) 1135 { 1136 /* Codes_SRS_PROV_CLIENT_07_013: [ CLIENT_STATE_REGISTER_SEND which shall construct an initial call to the service with endorsement information ] */ 1137 if (prov_info->prov_transport_protocol->prov_transport_register(prov_info->transport_handle, prov_transport_process_json_reply, prov_transport_create_json_payload, prov_info) != 0) 1138 { 1139 LogError("Failure registering device"); 1140 if (prov_info->error_reason == PROV_DEVICE_RESULT_OK) 1141 { 1142 prov_info->error_reason = PROV_DEVICE_RESULT_TRANSPORT; 1143 } 1144 prov_info->prov_state = CLIENT_STATE_ERROR; 1145 } 1146 else 1147 { 1148 (void)tickcounter_get_current_ms(prov_info->tick_counter, &prov_info->timeout_value); 1149 prov_info->prov_state = CLIENT_STATE_REGISTER_SENT; 1150 } 1151 prov_info->last_send_time_ms = current_time; 1152 } 1153 } 1154 break; 1155 1156 case CLIENT_STATE_STATUS_SEND: 1157 { 1158 if (tickcounter_get_current_ms(prov_info->tick_counter, ¤t_time) != 0) 1159 { 1160 LogError("Failure getting the current time"); 1161 prov_info->error_reason = PROV_DEVICE_RESULT_ERROR; 1162 prov_info->prov_state = CLIENT_STATE_ERROR; 1163 } 1164 else 1165 { 1166 if ((current_time - prov_info->last_send_time_ms) > prov_info->retry_after_ms) 1153 1167 { 1154 1168 /* Codes_SRS_PROV_CLIENT_07_026: [ Upon receiving the reply of the CLIENT_STATE_URL_REQ_SEND message from iothub_client shall process the the reply of the CLIENT_STATE_URL_REQ_SEND state ] */ … … 1172 1186 } 1173 1187 } 1174 prov_info-> status_throttle= current_time;1188 prov_info->last_send_time_ms = current_time; 1175 1189 } 1176 1190 } … … 1183 1197 if (prov_info->prov_timeout > 0) 1184 1198 { 1185 tickcounter_ms_t current_time = 0;1186 1199 (void)tickcounter_get_current_ms(prov_info->tick_counter, ¤t_time); 1187 1200 if ((current_time - prov_info->timeout_value) / 1000 > prov_info->prov_timeout) … … 1279 1292 if (value == NULL) 1280 1293 { 1281 LogError("setting proxy options");1294 LogError("setting PROV_OPTION_TIMEOUT option"); 1282 1295 result = PROV_DEVICE_RESULT_ERROR; 1283 1296 } -
azure_iot_hub_f767zi/trunk/azure_iot_sdk/provisioning_client/src/prov_transport_mqtt_common.c
r457 r464 320 320 if (memcmp(MQTT_TOPIC_STATUS_PREFIX, topic_resp, status_pos) == 0) 321 321 { 322 // If the status code is > 429 then this is a transient error322 // If the status code is >= 429 then this is a transient error 323 323 long status_code = atol(topic_resp + status_pos); 324 324 if (status_code >= PROV_STATUS_CODE_TRANSIENT_ERROR)
Note:
See TracChangeset
for help on using the changeset viewer.