Azure IoT C SDK
iothub_client_core_common.h
Go to the documentation of this file.
1 // Copyright (c) Microsoft. All rights reserved.
2 // Licensed under the MIT license. See LICENSE file in the project root for full license information.
3 
9 #ifndef IOTHUB_CLIENT_CORE_COMMON_H
10 #define IOTHUB_CLIENT_CORE_COMMON_H
11 
12 #include "azure_macro_utils/macro_utils.h"
13 #include "umock_c/umock_c_prod.h"
14 
15 #include "iothub_transport_ll.h"
16 #include "iothub_message.h"
17 
18 #ifdef __cplusplus
19 extern "C"
20 {
21 #endif
22 
25 typedef enum { FILE_UPLOAD_OK, FILE_UPLOAD_ERROR } IOTHUB_CLIENT_FILE_UPLOAD_RESULT;
29  typedef void(*IOTHUB_CLIENT_FILE_UPLOAD_CALLBACK)(IOTHUB_CLIENT_FILE_UPLOAD_RESULT result, void* userContextCallback);
30 
38 typedef struct IOTHUB_CLIENT_LL_UPLOADTOBLOB_CONTEXT_STRUCT* IOTHUB_CLIENT_LL_UPLOADTOBLOB_CONTEXT_HANDLE;
39 
42 typedef enum { IOTHUB_CLIENT_OK, IOTHUB_CLIENT_INVALID_ARG, IOTHUB_CLIENT_ERROR, IOTHUB_CLIENT_INVALID_SIZE, IOTHUB_CLIENT_INDEFINITE_TIME } IOTHUB_CLIENT_RESULT;
59  typedef void(*IOTHUB_METHOD_INVOKE_CALLBACK)(IOTHUB_CLIENT_RESULT result, int responseStatus, unsigned char* responsePayload, size_t responsePayloadSize, void* context);
60 
63 typedef enum { IOTHUB_CLIENT_RETRY_NONE, IOTHUB_CLIENT_RETRY_IMMEDIATE, IOTHUB_CLIENT_RETRY_INTERVAL, IOTHUB_CLIENT_RETRY_LINEAR_BACKOFF, IOTHUB_CLIENT_RETRY_EXPONENTIAL_BACKOFF, IOTHUB_CLIENT_RETRY_EXPONENTIAL_BACKOFF_WITH_JITTER, IOTHUB_CLIENT_RETRY_RANDOM } IOTHUB_CLIENT_RETRY_POLICY;
65  /* IOTHUBTRANSPORT_CONFIG_TAG is internal only and should not be documented. */
66  struct IOTHUBTRANSPORT_CONFIG_TAG;
67  typedef struct IOTHUBTRANSPORT_CONFIG_TAG IOTHUBTRANSPORT_CONFIG;
73 typedef enum { IOTHUB_CLIENT_SEND_STATUS_IDLE, IOTHUB_CLIENT_SEND_STATUS_BUSY } IOTHUB_CLIENT_STATUS;
75  /* IOTHUB_IDENTITY_TYPE and IOTHUB_IDENTITY_TYPE are internal only and should not be documented. */
76 typedef enum { IOTHUB_TYPE_TELEMETRY, IOTHUB_TYPE_DEVICE_TWIN, IOTHUB_TYPE_DEVICE_METHODS, IOTHUB_TYPE_EVENT_QUEUE } IOTHUB_IDENTITY_TYPE;
77 typedef enum { IOTHUB_PROCESS_OK, IOTHUB_PROCESS_ERROR, IOTHUB_PROCESS_NOT_CONNECTED, IOTHUB_PROCESS_CONTINUE } IOTHUB_PROCESS_ITEM_RESULT;
81 typedef enum { IOTHUBMESSAGE_ACCEPTED, IOTHUBMESSAGE_REJECTED, IOTHUBMESSAGE_ABANDONED, IOTHUBMESSAGE_ASYNC_ACK } IOTHUBMESSAGE_DISPOSITION_RESULT;
83  /* IOTHUB_CLIENT_IOTHUB_METHOD_STATUS is not used by IoT Hub client and should not be documented. */
84 typedef enum { IOTHUB_CLIENT_IOTHUB_METHOD_STATUS_SUCCESS, IOTHUB_CLIENT_IOTHUB_METHOD_STATUS_ERROR } IOTHUB_CLIENT_IOTHUB_METHOD_STATUS;
90 typedef enum { IOTHUB_CLIENT_CONFIRMATION_OK, IOTHUB_CLIENT_CONFIRMATION_BECAUSE_DESTROY, IOTHUB_CLIENT_CONFIRMATION_MESSAGE_TIMEOUT, IOTHUB_CLIENT_CONFIRMATION_ERROR } IOTHUB_CLIENT_CONFIRMATION_RESULT;
99 typedef enum { IOTHUB_CLIENT_CONNECTION_AUTHENTICATED, IOTHUB_CLIENT_CONNECTION_UNAUTHENTICATED } IOTHUB_CLIENT_CONNECTION_STATUS;
150 typedef enum { IOTHUB_CLIENT_CONNECTION_EXPIRED_SAS_TOKEN, IOTHUB_CLIENT_CONNECTION_DEVICE_DISABLED, IOTHUB_CLIENT_CONNECTION_BAD_CREDENTIAL, IOTHUB_CLIENT_CONNECTION_RETRY_EXPIRED, IOTHUB_CLIENT_CONNECTION_NO_NETWORK, IOTHUB_CLIENT_CONNECTION_COMMUNICATION_ERROR, IOTHUB_CLIENT_CONNECTION_OK, IOTHUB_CLIENT_CONNECTION_NO_PING_RESPONSE, IOTHUB_CLIENT_CONNECTION_QUOTA_EXCEEDED } IOTHUB_CLIENT_CONNECTION_STATUS_REASON;
155 typedef enum { IOTHUB_CLIENT_PROPERTY_PAYLOAD_ALL, IOTHUB_CLIENT_PROPERTY_PAYLOAD_WRITABLE_UPDATES } IOTHUB_CLIENT_PROPERTY_PAYLOAD_TYPE;
157  /* TRANSPORT_TYPE is internal only and should not be documented. */
158 typedef enum { TRANSPORT_LL /*LL comes from "LowLevel" */, TRANSPORT_THREADED } TRANSPORT_TYPE;
163 typedef enum { DEVICE_TWIN_UPDATE_COMPLETE, DEVICE_TWIN_UPDATE_PARTIAL } DEVICE_TWIN_UPDATE_STATE;
170  typedef void(*IOTHUB_CLIENT_EVENT_CONFIRMATION_CALLBACK)(IOTHUB_CLIENT_CONFIRMATION_RESULT result, void* userContextCallback);
171 
180 
190 
201  typedef void(*IOTHUB_CLIENT_DEVICE_TWIN_CALLBACK)(DEVICE_TWIN_UPDATE_STATE update_state, const unsigned char* payLoad, size_t size, void* userContextCallback);
202 
209  typedef void(*IOTHUB_CLIENT_REPORTED_STATE_CALLBACK)(int status_code, void* userContextCallback);
210 
227  typedef int(*IOTHUB_CLIENT_DEVICE_METHOD_CALLBACK_ASYNC)(const char* method_name, const unsigned char* payload, size_t size, unsigned char** response, size_t* response_size, void* userContextCallback);
228 
230  /* IOTHUB_CLIENT_INBOUND_DEVICE_METHOD_CALLBACK is internal only and should not be documented. */
231  typedef int(*IOTHUB_CLIENT_INBOUND_DEVICE_METHOD_CALLBACK)(const char* method_name, const unsigned char* payload, size_t size, METHOD_HANDLE method_id, void* userContextCallback);
237 typedef enum { IOTHUB_CLIENT_FILE_UPLOAD_GET_DATA_OK, IOTHUB_CLIENT_FILE_UPLOAD_GET_DATA_ABORT } IOTHUB_CLIENT_FILE_UPLOAD_GET_DATA_RESULT;
241  typedef void(*IOTHUB_CLIENT_FILE_UPLOAD_GET_DATA_CALLBACK)(IOTHUB_CLIENT_FILE_UPLOAD_RESULT result, unsigned char const ** data, size_t* size, void* context);
242 
260  typedef IOTHUB_CLIENT_FILE_UPLOAD_GET_DATA_RESULT(*IOTHUB_CLIENT_FILE_UPLOAD_GET_DATA_CALLBACK_EX)(IOTHUB_CLIENT_FILE_UPLOAD_RESULT result, unsigned char const ** data, size_t* size, void* context);
261 
263  typedef struct IOTHUB_CLIENT_CONFIG_TAG
264  {
269  IOTHUB_CLIENT_TRANSPORT_PROVIDER protocol;
270 
272  const char* deviceId;
273 
276  const char* deviceKey;
277 
280  const char* deviceSasToken;
281 
283  const char* iotHubName;
284 
286  const char* iotHubSuffix;
287 
291 
293  typedef struct IOTHUB_CLIENT_DEVICE_CONFIG_TAG
294  {
299  IOTHUB_CLIENT_TRANSPORT_PROVIDER protocol;
300 
303 
305  const char* deviceId;
306 
309  const char* deviceKey;
310 
313  const char* deviceSasToken;
315 
317  #define IOTHUB_CLIENT_COMMAND_REQUEST_STRUCT_VERSION_1 1
318 
320  typedef struct IOTHUB_CLIENT_COMMAND_REQUEST_TAG
321  {
325  const char* componentName;
327  const char* commandName;
329  const unsigned char* payload;
333 
335  #define IOTHUB_CLIENT_COMMAND_RESPONSE_STRUCT_VERSION_1 1
336 
338  typedef struct IOTHUB_CLIENT_COMMAND_RESPONSE_TAG
339  {
344  unsigned char* payload;
350 
359  const IOTHUB_CLIENT_COMMAND_REQUEST* commandRequest,
360  IOTHUB_CLIENT_COMMAND_RESPONSE* commandResponse,
361  void* userContextCallback);
362 
370  typedef void(*IOTHUB_CLIENT_TELEMETRY_CALLBACK)(IOTHUB_CLIENT_CONFIRMATION_RESULT result, void* userContextCallback);
371 
381  typedef void(*IOTHUB_CLIENT_PROPERTY_ACKNOWLEDGED_CALLBACK)(int statusCode, void* userContextCallback);
382 
394  const unsigned char* payload,
395  size_t payloadLength,
396  void* userContextCallback);
397 
398 #ifdef __cplusplus
399 }
400 #endif
401 
402 #endif /* IOTHUB_CLIENT_CORE_COMMON_H */
void(* IOTHUB_CLIENT_PROPERTY_ACKNOWLEDGED_CALLBACK)(int statusCode, void *userContextCallback)
Function callback application implements to receive acknowledgements of properties sent from the clie...
Definition: iothub_client_core_common.h:381
void(* IOTHUB_CLIENT_FILE_UPLOAD_CALLBACK)(IOTHUB_CLIENT_FILE_UPLOAD_RESULT result, void *userContextCallback)
Deprecated callback mechanism for uploading data to a blob.
Definition: iothub_client_core_common.h:29
IOTHUB_CLIENT_FILE_UPLOAD_GET_DATA_RESULT(* IOTHUB_CLIENT_FILE_UPLOAD_GET_DATA_CALLBACK_EX)(IOTHUB_CLIENT_FILE_UPLOAD_RESULT result, unsigned char const **data, size_t *size, void *context)
Signature of the callback that the application implements to process IoT Hub client SDK requesting ad...
Definition: iothub_client_core_common.h:260
IOTHUB_CLIENT_CONNECTION_STATUS_REASON
Enumeration passed to the application callback indicating reason that connection was unsuccessful.
Definition: iothub_client_core_common.h:150
void(* IOTHUB_CLIENT_FILE_UPLOAD_GET_DATA_CALLBACK)(IOTHUB_CLIENT_FILE_UPLOAD_RESULT result, unsigned char const **data, size_t *size, void *context)
Deprecated callback mechanism for uploading data to a blob.
Definition: iothub_client_core_common.h:241
void(* IOTHUB_CLIENT_TELEMETRY_CALLBACK)(IOTHUB_CLIENT_CONFIRMATION_RESULT result, void *userContextCallback)
Function callback application implements to receive notifications when IoT Hub acknowledges telemetry...
Definition: iothub_client_core_common.h:370
IOTHUB_CLIENT_FILE_UPLOAD_GET_DATA_RESULT
Return value applications use in their implementation of IOTHUB_CLIENT_FILE_UPLOAD_GET_DATA_CALLBACK_...
Definition: iothub_client_core_common.h:237
void(* IOTHUB_CLIENT_DEVICE_TWIN_CALLBACK)(DEVICE_TWIN_UPDATE_STATE update_state, const unsigned char *payLoad, size_t size, void *userContextCallback)
Signature of the callback that the application implements to process data received from an IoT Hub de...
Definition: iothub_client_core_common.h:201
IOTHUB_CLIENT_RETRY_POLICY
Enumeration specifying the retry strategy the IoT Hub client should use.
Definition: iothub_client_core_common.h:63
void(* IOTHUB_CLIENT_COMMAND_CALLBACK_ASYNC)(const IOTHUB_CLIENT_COMMAND_REQUEST *commandRequest, IOTHUB_CLIENT_COMMAND_RESPONSE *commandResponse, void *userContextCallback)
Function callback application implements to process an incoming command from IoT Hub.
Definition: iothub_client_core_common.h:358
void(* IOTHUB_CLIENT_EVENT_CONFIRMATION_CALLBACK)(IOTHUB_CLIENT_CONFIRMATION_RESULT result, void *userContextCallback)
Signature of the callback that the application implements to process acknowledgement or failures when...
Definition: iothub_client_core_common.h:170
DEVICE_TWIN_UPDATE_STATE
Enumeration passed to application callback to receive IoT Hub device or module twin data indicating w...
Definition: iothub_client_core_common.h:163
IOTHUB_CLIENT_FILE_UPLOAD_RESULT
Enumeration specifying the status of a file upload operation.
Definition: iothub_client_core_common.h:25
IOTHUBMESSAGE_DISPOSITION_RESULT
Enumeration returned by application callbacks that receive cloud-to-device messages.
Definition: iothub_client_core_common.h:81
void(* IOTHUB_METHOD_INVOKE_CALLBACK)(IOTHUB_CLIENT_RESULT result, int responseStatus, unsigned char *responsePayload, size_t responsePayloadSize, void *context)
Signature of the callback that the application implements to receive notifications of module initiate...
Definition: iothub_client_core_common.h:59
void(* IOTHUB_CLIENT_REPORTED_STATE_CALLBACK)(int status_code, void *userContextCallback)
Signature of the callback that the application implements to receive notifications of device or modul...
Definition: iothub_client_core_common.h:209
IOTHUB_CLIENT_CONFIRMATION_RESULT
Enumeration passed to the application's callback to process the success or failure of telemetry initi...
Definition: iothub_client_core_common.h:90
int(* IOTHUB_CLIENT_DEVICE_METHOD_CALLBACK_ASYNC)(const char *method_name, const unsigned char *payload, size_t size, unsigned char **response, size_t *response_size, void *userContextCallback)
Signature of the callback that the application implements to receive incoming device or module method...
Definition: iothub_client_core_common.h:227
void(* IOTHUB_CLIENT_PROPERTIES_RECEIVED_CALLBACK)(IOTHUB_CLIENT_PROPERTY_PAYLOAD_TYPE payloadType, const unsigned char *payload, size_t payloadLength, void *userContextCallback)
Function callback application implements to process properties received from IoT Hub.
Definition: iothub_client_core_common.h:392
void(* IOTHUB_CLIENT_CONNECTION_STATUS_CALLBACK)(IOTHUB_CLIENT_CONNECTION_STATUS result, IOTHUB_CLIENT_CONNECTION_STATUS_REASON reason, void *userContextCallback)
Signature of the callback that the application implements to process connection status changes betwee...
Definition: iothub_client_core_common.h:179
IOTHUBMESSAGE_DISPOSITION_RESULT(* IOTHUB_CLIENT_MESSAGE_CALLBACK_ASYNC)(IOTHUB_MESSAGE_HANDLE message, void *userContextCallback)
Signature of the callback that the application implements to process incoming cloud-to-device message...
Definition: iothub_client_core_common.h:189
struct IOTHUB_CLIENT_LL_UPLOADTOBLOB_CONTEXT_STRUCT * IOTHUB_CLIENT_LL_UPLOADTOBLOB_CONTEXT_HANDLE
Definition: iothub_client_core_common.h:38
IOTHUB_CLIENT_CONNECTION_STATUS
Enumeration passed to the application callback indicating connection status changes to IoT Hub.
Definition: iothub_client_core_common.h:99
IOTHUB_CLIENT_RESULT
Enumeration specifying the status of calls to IoT Hub client.
Definition: iothub_client_core_common.h:42
IOTHUB_CLIENT_PROPERTY_PAYLOAD_TYPE
Enumeration passed to IoT Hub device and module client property update callbacks to indicate whether ...
Definition: iothub_client_core_common.h:155
IOTHUB_CLIENT_STATUS
Enumeration returned by the GetSendStatus family of APIs (e.g. IoTHubDeviceClient_LL_GetSendStatus())...
Definition: iothub_client_core_common.h:73
The IoTHub_Message component encapsulates one message that can be transferred by an IoT hub client.
struct IOTHUB_MESSAGE_HANDLE_DATA_TAG * IOTHUB_MESSAGE_HANDLE
Handle representing an IoT Hub message.
Definition: iothub_message.h:32
This struct specifies parameters of an incoming command request.
Definition: iothub_client_core_common.h:321
const char * commandName
Name of the command associated with this request.
Definition: iothub_client_core_common.h:327
const unsigned char * payload
Raw payload of the request. This is NOT guaranteed to be a \0 terminated string.
Definition: iothub_client_core_common.h:329
int structVersion
Version of the structure. Currently the SDK sets this to IOTHUB_CLIENT_COMMAND_REQUEST_STRUCT_VERSION...
Definition: iothub_client_core_common.h:323
size_t payloadLength
Number of bytes of payload.
Definition: iothub_client_core_common.h:331
const char * componentName
Name of the component associated with this request. If this is targeting the root component,...
Definition: iothub_client_core_common.h:325
This struct specifies parameters of an outgoing command response.
Definition: iothub_client_core_common.h:339
size_t payloadLength
Number of bytes application is returning in payload. This should not include the terminating null.
Definition: iothub_client_core_common.h:346
unsigned char * payload
Response generated by the callback that will be sent to IoT Hub. This must be allocated using malloc(...
Definition: iothub_client_core_common.h:344
int structVersion
Version of the structure. Currently must be IOTHUB_CLIENT_COMMAND_RESPONSE_STRUCT_VERSION_1.
Definition: iothub_client_core_common.h:341
int statusCode
Status code of the command to return to the IoT Hub service. This maps to an HTTP style status code.
Definition: iothub_client_core_common.h:348
This struct specifies IoT Hub client configuration.
Definition: iothub_client_core_common.h:264
const char * iotHubName
The IoT Hub name to which the device is connecting.
Definition: iothub_client_core_common.h:283
const char * deviceId
A string that identifies the device.
Definition: iothub_client_core_common.h:272
const char * deviceKey
The device key used to authenticate the device. If neither deviceSasToken nor deviceKey is present th...
Definition: iothub_client_core_common.h:276
const char * protocolGatewayHostName
Optional gateway host to connect to (instead of directly to IoT Hub). Can be NULL.
Definition: iothub_client_core_common.h:289
const char * deviceSasToken
The device SAS Token used to authenticate the device in place of device key. If neither deviceSasToke...
Definition: iothub_client_core_common.h:280
IOTHUB_CLIENT_TRANSPORT_PROVIDER protocol
A function pointer that is passed into IoTHubDeviceClient_CreateWithTransport() or IoTHubDeviceClient...
Definition: iothub_client_core_common.h:269
const char * iotHubSuffix
IoT Hub suffix goes here, e.g., private.azure-devices-int.net.
Definition: iothub_client_core_common.h:286
This struct specifies IoT Hub client device configuration.
Definition: iothub_client_core_common.h:294
const char * deviceId
A string that identifies the device.
Definition: iothub_client_core_common.h:305
void * transportHandle
a transport handle implementing the protocol
Definition: iothub_client_core_common.h:302
const char * deviceSasToken
The device SAS Token used to authenticate the device in place of device key. x509 authentication is i...
Definition: iothub_client_core_common.h:313
IOTHUB_CLIENT_TRANSPORT_PROVIDER protocol
A function pointer that is passed into the IoTHubClientCreate API. A function definition for AMQP is ...
Definition: iothub_client_core_common.h:299
const char * deviceKey
The device key used to authenticate the device. x509 authentication is is not supported for multiplex...
Definition: iothub_client_core_common.h:309