Microsoft Azure IoTHub client HTTP transport
Dependents: iothub_client_sample_http simplesample_http temp_sensor_anomaly
This library implements the HTTP transport for Microsoft Azure IoTHub client. The code is replicated from https://github.com/Azure/azure-iot-sdks
Diff: iothubtransporthttp.c
- Revision:
- 1:2ba812f3d9b7
- Parent:
- 0:fa2b00dcd9d4
- Child:
- 2:ff9104b866b8
--- a/iothubtransporthttp.c Tue Sep 15 21:57:19 2015 -0700 +++ b/iothubtransporthttp.c Tue Sep 15 22:25:44 2015 -0700 @@ -45,7 +45,7 @@ IoTHubTransportHttp_Subscribe, /*pfIoTHubTransport_Subscribe IoTHubTransport_Subscribe; */ IoTHubTransportHttp_Unsubscribe, /*pfIoTHubTransport_Unsubscribe IoTHubTransport_Unsubscribe; */ IoTHubTransportHttp_DoWork, /*pfIoTHubTransport_DoWork IoTHubTransport_DoWork; */ - IoTHubTransportHttp_GetSendStatus /* pfIoTHubTransport_GetSendStatus IoTHubTransport_GetSendStatus */ + IoTHubTransportHttp_GetSendStatus /* pfIoTHubTransport_GetSendStatus IoTHubTransport_GetSendStatus */ }; const void* IoTHubTransportHttp_ProvideTransportInterface(void) @@ -425,36 +425,36 @@ LogError("invalid arg (configuration is missing)\r\n"); result = NULL; } - else if (config->upperConfig == NULL) - { - LogError("invalid arg (upperConfig is NULL)\r\n"); - result = NULL; - } - else if (config->waitingToSend == NULL) - { - LogError("invalid arg (waitingToSend is NULL)\r\n"); - result = NULL; - } - else if (config->upperConfig->protocol == NULL) - { - LogError("invalid arg (protocol is NULL)\r\n"); - result = NULL; - } - else if (config->upperConfig->deviceId == NULL) - { - LogError("invalid arg (deviceId is NULL)\r\n"); - result = NULL; - } - else if (config->upperConfig->iotHubName == NULL) - { - LogError("invalid arg (iotHubName is NULL)\r\n"); - result = NULL; - } - else if (config->upperConfig->iotHubSuffix == NULL) - { - LogError("invalid arg (iotHubSuffix is NULL)\r\n"); - result = NULL; - } + else if (config->upperConfig == NULL) + { + LogError("invalid arg (upperConfig is NULL)\r\n"); + result = NULL; + } + else if (config->waitingToSend == NULL) + { + LogError("invalid arg (waitingToSend is NULL)\r\n"); + result = NULL; + } + else if (config->upperConfig->protocol == NULL) + { + LogError("invalid arg (protocol is NULL)\r\n"); + result = NULL; + } + else if (config->upperConfig->deviceId == NULL) + { + LogError("invalid arg (deviceId is NULL)\r\n"); + result = NULL; + } + else if (config->upperConfig->iotHubName == NULL) + { + LogError("invalid arg (iotHubName is NULL)\r\n"); + result = NULL; + } + else if (config->upperConfig->iotHubSuffix == NULL) + { + LogError("invalid arg (iotHubSuffix is NULL)\r\n"); + result = NULL; + } else if (config->upperConfig->deviceKey == NULL) { LogError("invalid arg (deviceKey is NULL)\r\n"); @@ -1184,8 +1184,8 @@ -requestType: POST -relativePath: abandon relative path begin (as created by _Create) + value of ETag + "/abandon?api-version=2015-08-15-preview" - requestHttpHeadersHandle: an HTTP headers instance containing the following - Authorization: " " - If-Match: value of ETag + Authorization: " " + If-Match: value of ETag - requestContent: NULL - statusCode: a pointer to unsigned int which might be examined for logging - responseHeadearsHandle: NULL @@ -1194,8 +1194,8 @@ -requestType: DELETE -relativePath: abandon relative path begin + value of ETag + "?api-version=2015-08-15-preview" - requestHttpHeadersHandle: an HTTP headers instance containing the following - Authorization: " " - If-Match: value of ETag + Authorization: " " + If-Match: value of ETag - requestContent: NULL - statusCode: a pointer to unsigned int which might be used by logging - responseHeadearsHandle: NULL @@ -1204,8 +1204,8 @@ -requestType: DELETE -relativePath: abandon relative path begin + value of ETag +"?api-version=2015-08-15-preview" + "&reject" - requestHttpHeadersHandle: an HTTP headers instance containing the following - Authorization: " " - If-Match: value of ETag + Authorization: " " + If-Match: value of ETag - requestContent: NULL - statusCode: a pointer to unsigned int which might be used by logging - responseHeadearsHandle: NULL @@ -1514,38 +1514,38 @@ IOTHUB_CLIENT_RESULT IoTHubTransportHttp_GetSendStatus(TRANSPORT_HANDLE handle, IOTHUB_CLIENT_STATUS *iotHubClientStatus) { - IOTHUB_CLIENT_RESULT result; + IOTHUB_CLIENT_RESULT result; - /* Codes_SRS_IOTHUBTRANSPORTTHTTP_09_001: [IoTHubTransportHttp_GetSendStatus shall return IOTHUB_CLIENT_INVALID_ARG if called with NULL parameter] */ - if (handle == NULL) - { - result = IOTHUB_CLIENT_INVALID_ARG; - LogError("Invalid handle to IoTHubClient HTTP transport instance.\r\n"); - } - else if (iotHubClientStatus == NULL) - { - result = IOTHUB_CLIENT_INVALID_ARG; - LogError("Invalid pointer to output parameter IOTHUB_CLIENT_STATUS.\r\n"); - } - else - { - HTTPTRANSPORT_HANDLE_DATA* handleData = (HTTPTRANSPORT_HANDLE_DATA*)handle; + /* Codes_SRS_IOTHUBTRANSPORTTHTTP_09_001: [IoTHubTransportHttp_GetSendStatus shall return IOTHUB_CLIENT_INVALID_ARG if called with NULL parameter] */ + if (handle == NULL) + { + result = IOTHUB_CLIENT_INVALID_ARG; + LogError("Invalid handle to IoTHubClient HTTP transport instance.\r\n"); + } + else if (iotHubClientStatus == NULL) + { + result = IOTHUB_CLIENT_INVALID_ARG; + LogError("Invalid pointer to output parameter IOTHUB_CLIENT_STATUS.\r\n"); + } + else + { + HTTPTRANSPORT_HANDLE_DATA* handleData = (HTTPTRANSPORT_HANDLE_DATA*)handle; - /* Codes_SRS_IOTHUBTRANSPORTTHTTP_09_002: [IoTHubTransportHttp_GetSendStatus shall return IOTHUB_CLIENT_OK and status IOTHUB_CLIENT_SEND_STATUS_IDLE if there are currently no event items to be sent or being sent] */ - if (!DList_IsListEmpty(handleData->waitingToSend)) - { - *iotHubClientStatus = IOTHUB_CLIENT_SEND_STATUS_BUSY; - } - /* Codes_SRS_IOTHUBTRANSPORTTHTTP_09_003: [IoTHubTransportHttp_GetSendStatus shall return IOTHUB_CLIENT_OK and status IOTHUB_CLIENT_SEND_STATUS_BUSY if there are currently event items to be sent or being sent] */ - else - { - *iotHubClientStatus = IOTHUB_CLIENT_SEND_STATUS_IDLE; - } + /* Codes_SRS_IOTHUBTRANSPORTTHTTP_09_002: [IoTHubTransportHttp_GetSendStatus shall return IOTHUB_CLIENT_OK and status IOTHUB_CLIENT_SEND_STATUS_IDLE if there are currently no event items to be sent or being sent] */ + if (!DList_IsListEmpty(handleData->waitingToSend)) + { + *iotHubClientStatus = IOTHUB_CLIENT_SEND_STATUS_BUSY; + } + /* Codes_SRS_IOTHUBTRANSPORTTHTTP_09_003: [IoTHubTransportHttp_GetSendStatus shall return IOTHUB_CLIENT_OK and status IOTHUB_CLIENT_SEND_STATUS_BUSY if there are currently event items to be sent or being sent] */ + else + { + *iotHubClientStatus = IOTHUB_CLIENT_SEND_STATUS_IDLE; + } - result = IOTHUB_CLIENT_OK; - } + result = IOTHUB_CLIENT_OK; + } - return result; + return result; } IOTHUB_CLIENT_RESULT IoTHubTransportHttp_SetOption(TRANSPORT_HANDLE handle, const char* option, const void* value) @@ -1566,15 +1566,15 @@ else { HTTPTRANSPORT_HANDLE_DATA* handleData = (HTTPTRANSPORT_HANDLE_DATA*)handle; - /*Codes_SRS_IOTHUBTRANSPORTTHTTP_02_097: ["SetBatching"] */ - if (strcmp("SetBatching", option) == 0) + /*Codes_SRS_IOTHUBTRANSPORTTHTTP_02_097: ["Batching"] */ + if (strcmp("Batching", option) == 0) { /*Codes_SRS_IOTHUBTRANSPORTTHTTP_02_083: [If optionName is an option handled by IoTHubTransportHttp then it shall be set.] */ handleData->doBatchedTransfers = *(bool*)value; result = IOTHUB_CLIENT_OK; } - /*Codes_SRS_IOTHUBTRANSPORTTHTTP_02_114: ["GetMinimumPollingTime"] */ - else if (strcmp("GetMinimumPollingTime", option) == 0) + /*Codes_SRS_IOTHUBTRANSPORTTHTTP_02_114: ["MinimumPollingTime"] */ + else if (strcmp("MinimumPollingTime", option) == 0) { handleData->getMinimumPollingTime = *(unsigned int*)value; result = IOTHUB_CLIENT_OK;