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

Committer:
AzureIoTClient
Date:
Mon Jun 11 15:39:23 2018 -0700
Revision:
88:248736be106e
Child:
92:97148cf9aa2a
1.2.5

Who changed what in which revision?

UserRevisionLine numberNew contents of line
AzureIoTClient 88:248736be106e 1 // Copyright (c) Microsoft. All rights reserved.
AzureIoTClient 88:248736be106e 2 // Licensed under the MIT license. See LICENSE file in the project root for full license information.
AzureIoTClient 88:248736be106e 3
AzureIoTClient 88:248736be106e 4 #include <stdlib.h>
AzureIoTClient 88:248736be106e 5 #include "azure_c_shared_utility/umock_c_prod.h"
AzureIoTClient 88:248736be106e 6 #include "azure_c_shared_utility/gballoc.h"
AzureIoTClient 88:248736be106e 7
AzureIoTClient 88:248736be106e 8 #include "iothub_client_core.h"
AzureIoTClient 88:248736be106e 9 #include "iothub_device_client.h"
AzureIoTClient 88:248736be106e 10
AzureIoTClient 88:248736be106e 11 IOTHUB_DEVICE_CLIENT_HANDLE IoTHubDeviceClient_CreateFromConnectionString(const char* connectionString, IOTHUB_CLIENT_TRANSPORT_PROVIDER protocol)
AzureIoTClient 88:248736be106e 12 {
AzureIoTClient 88:248736be106e 13 return (IOTHUB_DEVICE_CLIENT_HANDLE)IoTHubClientCore_CreateFromConnectionString(connectionString, protocol);
AzureIoTClient 88:248736be106e 14 }
AzureIoTClient 88:248736be106e 15
AzureIoTClient 88:248736be106e 16 IOTHUB_DEVICE_CLIENT_HANDLE IoTHubDeviceClient_Create(const IOTHUB_CLIENT_CONFIG* config)
AzureIoTClient 88:248736be106e 17 {
AzureIoTClient 88:248736be106e 18 return (IOTHUB_DEVICE_CLIENT_HANDLE)IoTHubClientCore_Create(config);
AzureIoTClient 88:248736be106e 19 }
AzureIoTClient 88:248736be106e 20
AzureIoTClient 88:248736be106e 21 IOTHUB_DEVICE_CLIENT_HANDLE IoTHubDeviceClient_CreateWithTransport(TRANSPORT_HANDLE transportHandle, const IOTHUB_CLIENT_CONFIG* config)
AzureIoTClient 88:248736be106e 22 {
AzureIoTClient 88:248736be106e 23 return (IOTHUB_DEVICE_CLIENT_HANDLE)IoTHubClientCore_CreateWithTransport(transportHandle, config);
AzureIoTClient 88:248736be106e 24 }
AzureIoTClient 88:248736be106e 25
AzureIoTClient 88:248736be106e 26 IOTHUB_DEVICE_CLIENT_HANDLE IoTHubDeviceClient_CreateFromDeviceAuth(const char* iothub_uri, const char* device_id, IOTHUB_CLIENT_TRANSPORT_PROVIDER protocol)
AzureIoTClient 88:248736be106e 27 {
AzureIoTClient 88:248736be106e 28 return (IOTHUB_DEVICE_CLIENT_HANDLE)IoTHubClientCore_CreateFromDeviceAuth(iothub_uri, device_id, protocol);
AzureIoTClient 88:248736be106e 29 }
AzureIoTClient 88:248736be106e 30
AzureIoTClient 88:248736be106e 31 void IoTHubDeviceClient_Destroy(IOTHUB_DEVICE_CLIENT_HANDLE iotHubClientHandle)
AzureIoTClient 88:248736be106e 32 {
AzureIoTClient 88:248736be106e 33 IoTHubClientCore_Destroy((IOTHUB_CLIENT_CORE_HANDLE)iotHubClientHandle);
AzureIoTClient 88:248736be106e 34 }
AzureIoTClient 88:248736be106e 35
AzureIoTClient 88:248736be106e 36 IOTHUB_CLIENT_RESULT IoTHubDeviceClient_SendEventAsync(IOTHUB_DEVICE_CLIENT_HANDLE iotHubClientHandle, IOTHUB_MESSAGE_HANDLE eventMessageHandle, IOTHUB_CLIENT_EVENT_CONFIRMATION_CALLBACK eventConfirmationCallback, void* userContextCallback)
AzureIoTClient 88:248736be106e 37 {
AzureIoTClient 88:248736be106e 38 return IoTHubClientCore_SendEventAsync((IOTHUB_CLIENT_CORE_HANDLE)iotHubClientHandle, eventMessageHandle, eventConfirmationCallback, userContextCallback);
AzureIoTClient 88:248736be106e 39 }
AzureIoTClient 88:248736be106e 40
AzureIoTClient 88:248736be106e 41 IOTHUB_CLIENT_RESULT IoTHubDeviceClient_GetSendStatus(IOTHUB_DEVICE_CLIENT_HANDLE iotHubClientHandle, IOTHUB_CLIENT_STATUS *iotHubClientStatus)
AzureIoTClient 88:248736be106e 42 {
AzureIoTClient 88:248736be106e 43 return IoTHubClientCore_GetSendStatus((IOTHUB_CLIENT_CORE_HANDLE)iotHubClientHandle, iotHubClientStatus);
AzureIoTClient 88:248736be106e 44 }
AzureIoTClient 88:248736be106e 45
AzureIoTClient 88:248736be106e 46 IOTHUB_CLIENT_RESULT IoTHubDeviceClient_SetMessageCallback(IOTHUB_DEVICE_CLIENT_HANDLE iotHubClientHandle, IOTHUB_CLIENT_MESSAGE_CALLBACK_ASYNC messageCallback, void* userContextCallback)
AzureIoTClient 88:248736be106e 47 {
AzureIoTClient 88:248736be106e 48 return IoTHubClientCore_SetMessageCallback((IOTHUB_CLIENT_CORE_HANDLE)iotHubClientHandle, messageCallback, userContextCallback);
AzureIoTClient 88:248736be106e 49 }
AzureIoTClient 88:248736be106e 50
AzureIoTClient 88:248736be106e 51 IOTHUB_CLIENT_RESULT IoTHubDeviceClient_SetConnectionStatusCallback(IOTHUB_DEVICE_CLIENT_HANDLE iotHubClientHandle, IOTHUB_CLIENT_CONNECTION_STATUS_CALLBACK connectionStatusCallback, void * userContextCallback)
AzureIoTClient 88:248736be106e 52 {
AzureIoTClient 88:248736be106e 53 return IoTHubClientCore_SetConnectionStatusCallback((IOTHUB_CLIENT_CORE_HANDLE)iotHubClientHandle, connectionStatusCallback, userContextCallback);
AzureIoTClient 88:248736be106e 54 }
AzureIoTClient 88:248736be106e 55
AzureIoTClient 88:248736be106e 56 IOTHUB_CLIENT_RESULT IoTHubDeviceClient_SetRetryPolicy(IOTHUB_DEVICE_CLIENT_HANDLE iotHubClientHandle, IOTHUB_CLIENT_RETRY_POLICY retryPolicy, size_t retryTimeoutLimitInSeconds)
AzureIoTClient 88:248736be106e 57 {
AzureIoTClient 88:248736be106e 58 return IoTHubClientCore_SetRetryPolicy((IOTHUB_CLIENT_CORE_HANDLE)iotHubClientHandle, retryPolicy, retryTimeoutLimitInSeconds);
AzureIoTClient 88:248736be106e 59 }
AzureIoTClient 88:248736be106e 60
AzureIoTClient 88:248736be106e 61 IOTHUB_CLIENT_RESULT IoTHubDeviceClient_GetRetryPolicy(IOTHUB_DEVICE_CLIENT_HANDLE iotHubClientHandle, IOTHUB_CLIENT_RETRY_POLICY* retryPolicy, size_t* retryTimeoutLimitInSeconds)
AzureIoTClient 88:248736be106e 62 {
AzureIoTClient 88:248736be106e 63 return IoTHubClientCore_GetRetryPolicy((IOTHUB_CLIENT_CORE_HANDLE)iotHubClientHandle, retryPolicy, retryTimeoutLimitInSeconds);
AzureIoTClient 88:248736be106e 64 }
AzureIoTClient 88:248736be106e 65
AzureIoTClient 88:248736be106e 66 IOTHUB_CLIENT_RESULT IoTHubDeviceClient_GetLastMessageReceiveTime(IOTHUB_DEVICE_CLIENT_HANDLE iotHubClientHandle, time_t* lastMessageReceiveTime)
AzureIoTClient 88:248736be106e 67 {
AzureIoTClient 88:248736be106e 68 return IoTHubClientCore_GetLastMessageReceiveTime((IOTHUB_CLIENT_CORE_HANDLE)iotHubClientHandle, lastMessageReceiveTime);
AzureIoTClient 88:248736be106e 69 }
AzureIoTClient 88:248736be106e 70
AzureIoTClient 88:248736be106e 71 IOTHUB_CLIENT_RESULT IoTHubDeviceClient_SetOption(IOTHUB_DEVICE_CLIENT_HANDLE iotHubClientHandle, const char* optionName, const void* value)
AzureIoTClient 88:248736be106e 72 {
AzureIoTClient 88:248736be106e 73 return IoTHubClientCore_SetOption((IOTHUB_CLIENT_CORE_HANDLE)iotHubClientHandle, optionName, value);
AzureIoTClient 88:248736be106e 74 }
AzureIoTClient 88:248736be106e 75
AzureIoTClient 88:248736be106e 76 IOTHUB_CLIENT_RESULT IoTHubDeviceClient_SetDeviceTwinCallback(IOTHUB_DEVICE_CLIENT_HANDLE iotHubClientHandle, IOTHUB_CLIENT_DEVICE_TWIN_CALLBACK deviceTwinCallback, void* userContextCallback)
AzureIoTClient 88:248736be106e 77 {
AzureIoTClient 88:248736be106e 78 return IoTHubClientCore_SetDeviceTwinCallback((IOTHUB_CLIENT_CORE_HANDLE)iotHubClientHandle, deviceTwinCallback, userContextCallback);
AzureIoTClient 88:248736be106e 79 }
AzureIoTClient 88:248736be106e 80
AzureIoTClient 88:248736be106e 81 IOTHUB_CLIENT_RESULT IoTHubDeviceClient_SendReportedState(IOTHUB_DEVICE_CLIENT_HANDLE iotHubClientHandle, const unsigned char* reportedState, size_t size, IOTHUB_CLIENT_REPORTED_STATE_CALLBACK reportedStateCallback, void* userContextCallback)
AzureIoTClient 88:248736be106e 82 {
AzureIoTClient 88:248736be106e 83 return IoTHubClientCore_SendReportedState((IOTHUB_CLIENT_CORE_HANDLE)iotHubClientHandle, reportedState, size, reportedStateCallback, userContextCallback);
AzureIoTClient 88:248736be106e 84 }
AzureIoTClient 88:248736be106e 85
AzureIoTClient 88:248736be106e 86 IOTHUB_CLIENT_RESULT IoTHubDeviceClient_SetDeviceMethodCallback(IOTHUB_DEVICE_CLIENT_HANDLE iotHubClientHandle, IOTHUB_CLIENT_DEVICE_METHOD_CALLBACK_ASYNC deviceMethodCallback, void* userContextCallback)
AzureIoTClient 88:248736be106e 87 {
AzureIoTClient 88:248736be106e 88 return IoTHubClientCore_SetDeviceMethodCallback((IOTHUB_CLIENT_CORE_HANDLE)iotHubClientHandle, deviceMethodCallback, userContextCallback);
AzureIoTClient 88:248736be106e 89 }
AzureIoTClient 88:248736be106e 90
AzureIoTClient 88:248736be106e 91 IOTHUB_CLIENT_RESULT IoTHubDeviceClient_DeviceMethodResponse(IOTHUB_DEVICE_CLIENT_HANDLE iotHubClientHandle, METHOD_HANDLE methodId, const unsigned char* response, size_t respSize, int statusCode)
AzureIoTClient 88:248736be106e 92 {
AzureIoTClient 88:248736be106e 93 return IoTHubClientCore_DeviceMethodResponse((IOTHUB_CLIENT_CORE_HANDLE)iotHubClientHandle, methodId, response, respSize, statusCode);
AzureIoTClient 88:248736be106e 94 }
AzureIoTClient 88:248736be106e 95
AzureIoTClient 88:248736be106e 96 #ifndef DONT_USE_UPLOADTOBLOB
AzureIoTClient 88:248736be106e 97
AzureIoTClient 88:248736be106e 98 IOTHUB_CLIENT_RESULT IoTHubDeviceClient_UploadToBlobAsync(IOTHUB_DEVICE_CLIENT_HANDLE iotHubClientHandle, const char* destinationFileName, const unsigned char* source, size_t size, IOTHUB_CLIENT_FILE_UPLOAD_CALLBACK iotHubClientFileUploadCallback, void* context)
AzureIoTClient 88:248736be106e 99 {
AzureIoTClient 88:248736be106e 100 return IoTHubClientCore_UploadToBlobAsync((IOTHUB_CLIENT_CORE_HANDLE)iotHubClientHandle, destinationFileName, source, size, iotHubClientFileUploadCallback, context);
AzureIoTClient 88:248736be106e 101 }
AzureIoTClient 88:248736be106e 102
AzureIoTClient 88:248736be106e 103 IOTHUB_CLIENT_RESULT IoTHubDeviceClient_UploadMultipleBlocksToBlobAsync(IOTHUB_DEVICE_CLIENT_HANDLE iotHubClientHandle, const char* destinationFileName, IOTHUB_CLIENT_FILE_UPLOAD_GET_DATA_CALLBACK_EX getDataCallbackEx, void* context)
AzureIoTClient 88:248736be106e 104 {
AzureIoTClient 88:248736be106e 105 return IoTHubClientCore_UploadMultipleBlocksToBlobAsync((IOTHUB_CLIENT_CORE_HANDLE)iotHubClientHandle, destinationFileName, NULL, getDataCallbackEx, context);
AzureIoTClient 88:248736be106e 106 }
AzureIoTClient 88:248736be106e 107
AzureIoTClient 88:248736be106e 108 #endif /*DONT_USE_UPLOADTOBLOB*/