robot arm demo team / Mbed 2 deprecated RobotArmDemo Featured

Dependencies:   AX-12A Dynamixel mbed iothub_client EthernetInterface NTPClient ConfigFile SDFileSystem iothub_amqp_transport mbed-rtos proton-c-mbed wolfSSL

Embed: (wiki syntax)

« Back to documentation index

Show/hide line numbers iothub_mod_client.h Source File

iothub_mod_client.h

00001 // Copyright (c) Microsoft. All rights reserved.
00002 // Licensed under the MIT license. See LICENSE file in the project root for full license information.
00003 
00004 // iothub_mod_client.h : modified version of iothub_client.h
00005 
00006 /** @file iothub_client.h
00007 *   @brief Extends the IoTHubCLient_LL module with additional features.
00008 *
00009 *   @details IoTHubClient is a module that extends the IoTHubCLient_LL
00010 *            module with 2 features:
00011 *               - scheduling the work for the IoTHubCLient from a  
00012 *                 thread, so that the user does not need to create their
00013 *                 own thread
00014 *               - thread-safe APIs
00015 */
00016 
00017 #ifndef IOTHUB_MOD_CLIENT_H
00018 
00019 #include "iothub_client_ll.h"
00020 
00021 #ifdef __cplusplus
00022 extern "C"
00023 {
00024 #endif
00025 
00026     typedef void* IOTHUB_CLIENT_HANDLE;
00027 
00028     typedef void (*IOTHUB_CLIENT_SEND_CALLBACK)(IOTHUB_CLIENT_HANDLE iotHubClientHandle, void* userContextCallback);
00029 
00030     /**
00031     * @brief    Creates a IoT Hub client for communication with an existing
00032     *           IoT Hub using the specified connection string parameter.
00033     *
00034     * @param    connectionString    Pointer to a character string
00035     * @param    protocol            Function pointer for protocol implementation
00036     *
00037     *           Sample connection string:
00038     *               <blockquote>
00039     *                   <pre>HostName=[IoT Hub name goes here].[IoT Hub suffix goes here, e.g., private.azure-devices-int.net];DeviceId=[Device ID goes here];SharedAccessKey=[Device key goes here];</pre>
00040     *               </blockquote>
00041     *
00042     * @return   A non-NULL @c IOTHUB_CLIENT_HANDLE value that is used when
00043     *           invoking other functions for IoT Hub client and @c NULL on failure.
00044     */
00045     extern IOTHUB_CLIENT_HANDLE IoTHubClient_Mod_CreateFromConnectionString(const char* connectionString, IOTHUB_CLIENT_TRANSPORT_PROVIDER protocol);
00046 
00047     /**
00048     * @brief    Creates a IoT Hub client for communication with an existing IoT
00049     *           Hub using the specified parameters.
00050     *
00051     * @param    config  Pointer to an @c IOTHUB_CLIENT_CONFIG structure
00052     *
00053     *           The API does not allow sharing of a connection across multiple
00054     *           devices. This is a blocking call.
00055     *
00056     * @return   A non-NULL @c IOTHUB_CLIENT_HANDLE value that is used when
00057     *           invoking other functions for IoT Hub client and @c NULL on failure.
00058     */
00059     extern IOTHUB_CLIENT_HANDLE IoTHubClient_Mod_Create(const IOTHUB_CLIENT_CONFIG* config);
00060 
00061     /**
00062     * @brief    Disposes of resources allocated by the IoT Hub client. This is a
00063     *           blocking call.
00064     *
00065     * @param    iotHubClientHandle  The handle created by a call to the create function.
00066     */
00067     extern void IoTHubClient_Mod_Destroy(IOTHUB_CLIENT_HANDLE iotHubClientHandle);
00068 
00069     /**
00070     * @brief    Asynchronous call to send the message specified by @p eventMessageHandle.
00071     *
00072     * @param    iotHubClientHandle          The handle created by a call to the create function.
00073     * @param    eventMessageHandle          The handle to an IoT Hub message.
00074     * @param    eventConfirmationCallback   The callback specified by the device for receiving
00075     *                                       confirmation of the delivery of the IoT Hub message.
00076     *                                       This callback can be expected to invoke the
00077     *                                       ::IoTHubClient_SendEventAsync function for the
00078     *                                       same message in an attempt to retry sending a failing
00079     *                                       message. The user can specify a @c NULL value here to
00080     *                                       indicate that no callback is required.
00081     * @param    userContextCallback         User specified context that will be provided to the
00082     *                                       callback. This can be @c NULL.
00083     *
00084     *           @b NOTE: The application behavior is undefined if the user calls
00085     *           the ::IoTHubClient_Destroy function from within any callback.
00086     *
00087     * @return   IOTHUB_CLIENT_OK upon success or an error code upon failure.
00088     */
00089     extern IOTHUB_CLIENT_RESULT IoTHubClient_Mod_SendEventAsync(IOTHUB_CLIENT_HANDLE iotHubClientHandle, IOTHUB_MESSAGE_HANDLE eventMessageHandle, IOTHUB_CLIENT_EVENT_CONFIRMATION_CALLBACK eventConfirmationCallback, void* userContextCallback);
00090 
00091     /**
00092     * @brief    This function returns the current sending status for IoTHubClient.
00093     *
00094     * @param    iotHubClientHandle      The handle created by a call to the create function.
00095     * @param    iotHubClientStatus      The sending state is populated at the address pointed
00096     *                                   at by this parameter. The value will be set to
00097     *                                   @c IOTHUBCLIENT_SENDSTATUS_IDLE if there is currently
00098     *                                   no item to be sent and @c IOTHUBCLIENT_SENDSTATUS_BUSY
00099     *                                   if there are.
00100     *
00101     * @return   IOTHUB_CLIENT_OK upon success or an error code upon failure.
00102     */
00103     extern IOTHUB_CLIENT_RESULT IoTHubClient_Mod_GetSendStatus(IOTHUB_CLIENT_HANDLE iotHubClientHandle, IOTHUB_CLIENT_STATUS *iotHubClientStatus);
00104 
00105     /**
00106     * @brief    Sets up the message callback to be invoked when IoT Hub issues a
00107     *           message to the device. This is a blocking call.
00108     *
00109     * @param    iotHubClientHandle          The handle created by a call to the create function.
00110     * @param    messageCallback             The callback specified by the device for receiving
00111     *                                       messages from IoT Hub.
00112     * @param    userContextCallback         User specified context that will be provided to the
00113     *                                       callback. This can be @c NULL.
00114     *
00115     *           @b NOTE: The application behavior is undefined if the user calls
00116     *           the ::IoTHubClient_Destroy function from within any callback.
00117     *
00118     * @return   IOTHUB_CLIENT_OK upon success or an error code upon failure.
00119     */
00120     extern IOTHUB_CLIENT_RESULT IoTHubClient_Mod_SetMessageCallback(IOTHUB_CLIENT_HANDLE iotHubClientHandle, IOTHUB_CLIENT_MESSAGE_CALLBACK_ASYNC messageCallback, void* userContextCallback);
00121 
00122     /**
00123     * @brief    Sets up the  callback to be invoked from IoT Hub worker thread.
00124     *           Can call SendAsync from here without blocking on lock. 
00125     *
00126     * @param    iotHubClientHandle          The handle created by a call to the create function.
00127     * @param    sendCallback                The callback specified by the device for sending
00128     *                                       messages to IoT Hub.
00129     * @param    userContextCallback         User specified context that will be provided to the
00130     *                                       callback. This can be @c NULL.
00131     *
00132     *           @b NOTE: The application behavior is undefined if the user calls
00133     *           the ::IoTHubClient_Destroy function from within any callback.
00134     *
00135     * @return   IOTHUB_CLIENT_OK upon success or an error code upon failure.
00136     */
00137     extern IOTHUB_CLIENT_RESULT IoTHubClient_Mod_SetSendCallback(IOTHUB_CLIENT_HANDLE iotHubClientHandle, IOTHUB_CLIENT_SEND_CALLBACK messageCallback, void* userContextCallback);
00138 
00139     /**
00140     * @brief    This function returns in the out parameter @p lastMessageReceiveTime
00141     *           what was the value of the @c time function when the last message was
00142     *           received at the client.
00143     *
00144     * @param    iotHubClientHandle              The handle created by a call to the create function.
00145     * @param    lastMessageReceiveTime          Out parameter containing the value of @c time function
00146     *                                           when the last message was received.
00147     *
00148     * @return   IOTHUB_CLIENT_OK upon success or an error code upon failure.
00149     */
00150     extern IOTHUB_CLIENT_RESULT IoTHubClient_Mod_GetLastMessageReceiveTime(IOTHUB_CLIENT_HANDLE iotHubClientHandle, time_t* lastMessageReceiveTime);
00151 
00152     /**
00153     * @brief    This API sets a runtime option identified by parameter @p optionName
00154     *           to a value pointed to by @p value. @p optionName and the data type
00155     *           @p value is pointing to are specific for every option.
00156     *
00157     * @param    iotHubClientHandle  The handle created by a call to the create function.
00158     * @param    optionName          Name of the option.
00159     * @param    value               The value.
00160     *
00161     *           The options that can be set via this API are:
00162     *               - @b timeout - the maximum time in milliseconds a communication is
00163     *                 allowed to use. @p value is a pointer to an @c unsigned @c int with
00164     *                 the timeout value in milliseconds. This is only supported for the HTTP
00165     *                 protocol as of now. When the HTTP protocol uses CURL, the meaning of
00166     *                 the parameter is <em>total request time</em>. When the HTTP protocol uses
00167     *                 winhttp, the meaning is the same as the @c dwSendTimeout and
00168     *                 @c dwReceiveTimeout parameters of the
00169     *                 <a href="https://msdn.microsoft.com/en-us/library/windows/desktop/aa384116(v=vs.85).aspx">
00170     *                 WinHttpSetTimeouts</a> API.
00171     *               - @b CURLOPT_LOW_SPEED_LIMIT - only available for HTTP protocol and only
00172     *                 when CURL is used. It has the same meaning as CURL's option with the same
00173     *                 name. @p value is pointer to a long.
00174     *               - @b CURLOPT_LOW_SPEED_TIME - only available for HTTP protocol and only
00175     *                 when CURL is used. It has the same meaning as CURL's option with the same
00176     *                 name. @p value is pointer to a long.
00177     *               - @b CURLOPT_FORBID_REUSE - only available for HTTP protocol and only
00178     *                 when CURL is used. It has the same meaning as CURL's option with the same
00179     *                 name. @p value is pointer to a long.
00180     *               - @b CURLOPT_FRESH_CONNECT - only available for HTTP protocol and only
00181     *                 when CURL is used. It has the same meaning as CURL's option with the same
00182     *                 name. @p value is pointer to a long.
00183     *               - @b CURLOPT_VERBOSE - only available for HTTP protocol and only
00184     *                 when CURL is used. It has the same meaning as CURL's option with the same
00185     *                 name. @p value is pointer to a long.
00186     *
00187     * @return   IOTHUB_CLIENT_OK upon success or an error code upon failure.
00188     */
00189     extern IOTHUB_CLIENT_RESULT IoTHubClient_Mod_SetOption(IOTHUB_CLIENT_HANDLE iotHubClientHandle, const char* optionName, const void* value);
00190 
00191 #ifdef __cplusplus
00192 }
00193 #endif
00194 
00195 #endif /* IOTHUB_CLIENT_H */