Microsoft Azure IoTHub client libraries
Dependents: sht15_remote_monitoring RobotArmDemo iothub_client_sample_amqp f767zi_mqtt ... more
This library implements the Microsoft Azure IoTHub client library. The code is replicated from https://github.com/Azure/azure-iot-sdks
Diff: iothub_client_ll.c
- Revision:
- 46:6a69294b6119
- Parent:
- 45:54c11b1b1407
- Child:
- 47:aaa262b5f898
--- a/iothub_client_ll.c Fri Jul 01 10:42:36 2016 -0700 +++ b/iothub_client_ll.c Mon Jul 18 16:45:01 2016 -0700 @@ -662,11 +662,10 @@ } else { - IOTHUB_CLIENT_LL_HANDLE_DATA* handleData = (IOTHUB_CLIENT_LL_HANDLE_DATA*)iotHubClientHandle; /*Codes_SRS_IOTHUBCLIENT_LL_02_013: [IoTHubClient_SendEventAsync shall add the DLIST waitingToSend a new record cloning the information from eventMessageHandle, eventConfirmationCallback, userContextCallback.]*/ newEntry->callback = eventConfirmationCallback; newEntry->context = userContextCallback; - DList_InsertTailList(&(handleData->waitingToSend), &(newEntry->entry)); + DList_InsertTailList(&(iotHubClientHandle->waitingToSend), &(newEntry->entry)); /*Codes_SRS_IOTHUBCLIENT_LL_02_015: [Otherwise IoTHubClient_LL_SendEventAsync shall succeed and return IOTHUB_CLIENT_OK.] */ result = IOTHUB_CLIENT_OK; } @@ -910,14 +909,40 @@ } else { - /*Codes_SRS_IOTHUBCLIENT_LL_02_038: [Otherwise, IoTHubClient_LL shall call the function _SetOption of the underlying transport and return what that function is returning.] */ - result = handleData->IoTHubTransport_SetOption(handleData->transportHandle, optionName, value); + + /*Codes_SRS_IOTHUBCLIENT_LL_02_099: [ IoTHubClient_LL_SetOption shall return according to the table below ]*/ + IOTHUB_CLIENT_RESULT uploadToBlob_result; +#ifndef DONT_USE_UPLOADTOBLOB + uploadToBlob_result = IoTHubClient_LL_UploadToBlob_SetOption(handleData->uploadToBlobHandle, optionName, value); + if(uploadToBlob_result == IOTHUB_CLIENT_ERROR) + { + LogError("unable to IoTHubClient_LL_UploadToBlob_SetOption"); + result = IOTHUB_CLIENT_ERROR; + } +#else + uploadToBlob_result = IOTHUB_CLIENT_INVALID_ARG; /*harmless value (IOTHUB_CLIENT_INVALID_ARG)in the case when uploadtoblob is not compiled in, otherwise whatever IoTHubClient_LL_UploadToBlob_SetOption returned*/ +#endif /*DONT_USE_UPLOADTOBLOB*/ - if (result != IOTHUB_CLIENT_OK) - { - LogError("underlying transport failed, returned = %s", ENUM_TO_STRING(IOTHUB_CLIENT_RESULT, result)); + + result = + /*based on uploadToBlob_result value this is what happens:*/ + /*IOTHUB_CLIENT_INVALID_ARG always returns what IoTHubTransport_SetOption returns*/ + /*IOTHUB_CLIENT_ERROR always returns IOTHUB_CLIENT_ERROR */ + /*IOTHUB_CLIENT_OK returns OK + IOTHUB_CLIENT_OK if IoTHubTransport_SetOption returns OK or INVALID_ARG + IOTHUB_CLIENT_ERROR if IoTHubTransport_SetOption returns ERROR*/ + + (uploadToBlob_result == IOTHUB_CLIENT_INVALID_ARG) ? handleData->IoTHubTransport_SetOption(handleData->transportHandle, optionName, value) : + (uploadToBlob_result == IOTHUB_CLIENT_ERROR) ? IOTHUB_CLIENT_ERROR : + (handleData->IoTHubTransport_SetOption(handleData->transportHandle, optionName, value) == IOTHUB_CLIENT_ERROR) ? IOTHUB_CLIENT_ERROR : IOTHUB_CLIENT_OK; + + if (result != IOTHUB_CLIENT_OK) + { + LogError("underlying transport failed, returned = %s", ENUM_TO_STRING(IOTHUB_CLIENT_RESULT, result)); + } +#ifndef DONT_USE_UPLOADTOBLOB } - } +#endif } return result; } @@ -939,7 +964,6 @@ } else { - IOTHUB_CLIENT_LL_HANDLE_DATA* handleData = (IOTHUB_CLIENT_LL_HANDLE_DATA*)iotHubClientHandle; result = IoTHubClient_LL_UploadToBlob_Impl(iotHubClientHandle->uploadToBlobHandle, destinationFileName, source, size); } return result;