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.c
- Revision:
- 44:33dd78697616
- Parent:
- 43:038d8511e817
- Child:
- 45:54c11b1b1407
diff -r 038d8511e817 -r 33dd78697616 iothub_client.c --- a/iothub_client.c Fri Jun 17 17:02:44 2016 -0700 +++ b/iothub_client.c Tue Jun 21 09:57:27 2016 -0700 @@ -26,12 +26,12 @@ THREAD_HANDLE ThreadHandle; LOCK_HANDLE LockHandle; sig_atomic_t StopThread; -#ifdef USE_UPLOADTOBLOB +#ifndef DONT_USE_UPLOADTOBLOB LIST_HANDLE savedDataToBeCleaned; /*list containing UPLOADTOBLOB_SAVED_DATA*/ #endif } IOTHUB_CLIENT_INSTANCE; -#ifdef USE_UPLOADTOBLOB +#ifndef DONT_USE_UPLOADTOBLOB typedef struct UPLOADTOBLOB_SAVED_DATA_TAG { unsigned char* source; @@ -49,7 +49,7 @@ /*used by unittests only*/ const size_t IoTHubClient_ThreadTerminationOffset = offsetof(IOTHUB_CLIENT_INSTANCE, StopThread); -#ifdef USE_UPLOADTOBLOB +#ifndef DONT_USE_UPLOADTOBLOB /*this function is called from _Destroy and from ScheduleWork_Thread to join finished blobUpload threads and free that memory*/ static void garbageCollectorImpl(IOTHUB_CLIENT_INSTANCE* iotHubClientInstance) { @@ -118,7 +118,7 @@ /* Codes_SRS_IOTHUBCLIENT_01_039: [All calls to IoTHubClient_LL_DoWork shall be protected by the lock created in IotHubClient_Create.] */ IoTHubClient_LL_DoWork(iotHubClientInstance->IoTHubClientLLHandle); -#ifdef USE_UPLOADTOBLOB +#ifndef DONT_USE_UPLOADTOBLOB garbageCollectorImpl(iotHubClientInstance); #endif (void)Unlock(iotHubClientInstance->LockHandle); @@ -204,7 +204,7 @@ } else { -#ifdef USE_UPLOADTOBLOB +#ifndef DONT_USE_UPLOADTOBLOB /*Codes_SRS_IOTHUBCLIENT_02_059: [ IoTHubClient_CreateFromConnectionString shall create a LIST_HANDLE containing THREAD_HANDLE (created by future calls to IoTHubClient_UploadToBlobAsync). ]*/ if ((result->savedDataToBeCleaned = list_create()) == NULL) { @@ -222,7 +222,7 @@ if (result->IoTHubClientLLHandle == NULL) { /* Codes_SRS_IOTHUBCLIENT_12_010: [If IoTHubClient_LL_CreateFromConnectionString fails then IoTHubClient_CreateFromConnectionString shall do clean - up and return NULL] */ -#ifdef USE_UPLOADTOBLOB +#ifndef DONT_USE_UPLOADTOBLOB list_destroy(result->savedDataToBeCleaned); #endif Lock_Deinit(result->LockHandle); @@ -262,7 +262,7 @@ } else { -#ifdef USE_UPLOADTOBLOB +#ifndef DONT_USE_UPLOADTOBLOB /*Codes_SRS_IOTHUBCLIENT_02_060: [ IoTHubClient_Create shall create a LIST_HANDLE containing THREAD_HANDLE (created by future calls to IoTHubClient_UploadToBlobAsync). ]*/ if ((result->savedDataToBeCleaned = list_create()) == NULL) { @@ -282,7 +282,7 @@ /* Codes_SRS_IOTHUBCLIENT_01_003: [If IoTHubClient_LL_Create fails, then IoTHubClient_Create shall return NULL.] */ /* Codes_SRS_IOTHUBCLIENT_01_031: [If IoTHubClient_Create fails, all resources allocated by it shall be freed.] */ Lock_Deinit(result->LockHandle); -#ifdef USE_UPLOADTOBLOB +#ifndef DONT_USE_UPLOADTOBLOB list_destroy(result->savedDataToBeCleaned); #endif free(result); @@ -322,7 +322,7 @@ } else { -#ifdef USE_UPLOADTOBLOB +#ifndef DONT_USE_UPLOADTOBLOB /*Codes_SRS_IOTHUBCLIENT_02_073: [ IoTHubClient_CreateWithTransport shall create a LIST_HANDLE that shall be used by IoTHubClient_UploadToBlobAsync. ]*/ if ((result->savedDataToBeCleaned = list_create()) == NULL) { @@ -343,7 +343,7 @@ { LogError("unable to IoTHubTransport_GetLock"); /*Codes_SRS_IOTHUBCLIENT_17_006: [ If IoTHubTransport_GetLock fails, then IoTHubClient_CreateWithTransport shall return NULL. ]*/ -#ifdef USE_UPLOADTOBLOB +#ifndef DONT_USE_UPLOADTOBLOB list_destroy(result->savedDataToBeCleaned); #endif free(result); @@ -365,7 +365,7 @@ { LogError("unable to IoTHubTransport_GetLLTransport"); /*Codes_SRS_IOTHUBCLIENT_17_004: [ If IoTHubTransport_GetLLTransport fails, then IoTHubClient_CreateWithTransport shall return NULL. ]*/ -#ifdef USE_UPLOADTOBLOB +#ifndef DONT_USE_UPLOADTOBLOB list_destroy(result->savedDataToBeCleaned); #endif free(result); @@ -376,7 +376,7 @@ if (Lock(transportLock) != LOCK_OK) { LogError("unable to Lock"); -#ifdef USE_UPLOADTOBLOB +#ifndef DONT_USE_UPLOADTOBLOB list_destroy(result->savedDataToBeCleaned); #endif free(result); @@ -391,7 +391,7 @@ LogError("unable to IoTHubClient_LL_CreateWithTransport"); /*Codes_SRS_IOTHUBCLIENT_17_008: [ If IoTHubClient_LL_CreateWithTransport fails, then IoTHubClient_Create shall return NULL. ]*/ /*Codes_SRS_IOTHUBCLIENT_17_009: [ If IoTHubClient_LL_CreateWithTransport fails, all resources allocated by it shall be freed. ]*/ -#ifdef USE_UPLOADTOBLOB +#ifndef DONT_USE_UPLOADTOBLOB list_destroy(result->savedDataToBeCleaned); #endif free(result); @@ -429,7 +429,7 @@ LogError("unable to Lock - - will still proceed to try to end the thread without locking"); } -#ifdef USE_UPLOADTOBLOB +#ifndef DONT_USE_UPLOADTOBLOB /*Codes_SRS_IOTHUBCLIENT_02_069: [ IoTHubClient_Destroy shall free all data created by IoTHubClient_UploadToBlobAsync ]*/ /*wait for all uploading threads to finish*/ while (list_get_head_item(iotHubClientInstance->savedDataToBeCleaned) != NULL) @@ -456,7 +456,7 @@ /* Codes_SRS_IOTHUBCLIENT_01_006: [That includes destroying the IoTHubClient_LL instance by calling IoTHubClient_LL_Destroy.] */ IoTHubClient_LL_Destroy(iotHubClientInstance->IoTHubClientLLHandle); -#ifdef USE_UPLOADTOBLOB +#ifndef DONT_USE_UPLOADTOBLOB if (iotHubClientInstance->savedDataToBeCleaned != NULL) { list_destroy(iotHubClientInstance->savedDataToBeCleaned); @@ -697,7 +697,7 @@ return result; } -#ifdef USE_UPLOADTOBLOB +#ifndef DONT_USE_UPLOADTOBLOB static int uploadingThread(void *data) { UPLOADTOBLOB_SAVED_DATA* savedData = (UPLOADTOBLOB_SAVED_DATA*)data; @@ -743,7 +743,7 @@ } #endif -#ifdef USE_UPLOADTOBLOB +#ifndef DONT_USE_UPLOADTOBLOB IOTHUB_CLIENT_RESULT IoTHubClient_UploadToBlobAsync(IOTHUB_CLIENT_HANDLE iotHubClientHandle, const char* destinationFileName, const unsigned char* source, size_t size, IOTHUB_CLIENT_FILE_UPLOAD_CALLBACK iotHubClientFileUploadCallback, void* context) { IOTHUB_CLIENT_RESULT result; @@ -895,4 +895,4 @@ } return result; } -#endif /*USE_UPLOADTOBLOB*/ +#endif /*DONT_USE_UPLOADTOBLOB*/