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
blob.h@85:de16c0a8a196, 2018-03-20 (annotated)
- Committer:
- AzureIoTClient
- Date:
- Tue Mar 20 10:29:00 2018 -0700
- Revision:
- 85:de16c0a8a196
- Parent:
- 82:f94e6bed4495
1.2.1
Who changed what in which revision?
User | Revision | Line number | New contents of line |
---|---|---|---|
AzureIoTClient | 42:448eecc3676e | 1 | // Copyright (c) Microsoft. All rights reserved. |
AzureIoTClient | 42:448eecc3676e | 2 | // Licensed under the MIT license. See LICENSE file in the project root for full license information. |
AzureIoTClient | 42:448eecc3676e | 3 | |
AzureIoTClient | 42:448eecc3676e | 4 | /** @file blob.h |
AzureIoTClient | 42:448eecc3676e | 5 | * @brief Contains blob APIs needed for File Upload feature of IoTHub client. |
AzureIoTClient | 42:448eecc3676e | 6 | * |
AzureIoTClient | 42:448eecc3676e | 7 | * @details IoTHub client needs to upload a byte array by using blob storage API |
AzureIoTClient | 42:448eecc3676e | 8 | * IoTHub service provides the complete SAS URI to execute a PUT request |
AzureIoTClient | 42:448eecc3676e | 9 | * that will upload the data. |
AzureIoTClient | 42:448eecc3676e | 10 | * |
AzureIoTClient | 42:448eecc3676e | 11 | */ |
AzureIoTClient | 42:448eecc3676e | 12 | |
AzureIoTClient | 42:448eecc3676e | 13 | #ifndef BLOB_H |
AzureIoTClient | 42:448eecc3676e | 14 | #define BLOB_H |
AzureIoTClient | 42:448eecc3676e | 15 | |
AzureIoTClient | 42:448eecc3676e | 16 | #include "azure_c_shared_utility/macro_utils.h" |
AzureIoTClient | 42:448eecc3676e | 17 | #include "azure_c_shared_utility/buffer_.h" |
AzureIoTClient | 80:db5f5237bc95 | 18 | #include "azure_c_shared_utility/strings_types.h" |
AzureIoTClient | 80:db5f5237bc95 | 19 | #include "azure_c_shared_utility/httpapiex.h" |
AzureIoTClient | 80:db5f5237bc95 | 20 | #include "iothub_client_ll.h" |
AzureIoTClient | 79:bb88037c05e6 | 21 | #include "azure_c_shared_utility/shared_util_options.h" |
AzureIoTClient | 42:448eecc3676e | 22 | |
AzureIoTClient | 42:448eecc3676e | 23 | #ifdef __cplusplus |
AzureIoTClient | 42:448eecc3676e | 24 | #include <cstddef> |
AzureIoTClient | 42:448eecc3676e | 25 | extern "C" |
AzureIoTClient | 42:448eecc3676e | 26 | { |
AzureIoTClient | 42:448eecc3676e | 27 | #else |
AzureIoTClient | 42:448eecc3676e | 28 | #include <stddef.h> |
AzureIoTClient | 42:448eecc3676e | 29 | #endif |
AzureIoTClient | 42:448eecc3676e | 30 | |
AzureIoTClient | 42:448eecc3676e | 31 | #include "azure_c_shared_utility/umock_c_prod.h" |
AzureIoTClient | 42:448eecc3676e | 32 | |
AzureIoTClient | 80:db5f5237bc95 | 33 | /* Allow unit tests to override MAX_BLOCK_COUNT to something much smaller */ |
AzureIoTClient | 80:db5f5237bc95 | 34 | #ifndef MAX_BLOCK_COUNT |
AzureIoTClient | 80:db5f5237bc95 | 35 | /* Maximum count of blocks uploaded is 50000, per server*/ |
AzureIoTClient | 80:db5f5237bc95 | 36 | #define MAX_BLOCK_COUNT 50000 |
AzureIoTClient | 80:db5f5237bc95 | 37 | #endif |
AzureIoTClient | 80:db5f5237bc95 | 38 | |
AzureIoTClient | 42:448eecc3676e | 39 | #define BLOB_RESULT_VALUES \ |
AzureIoTClient | 42:448eecc3676e | 40 | BLOB_OK, \ |
AzureIoTClient | 42:448eecc3676e | 41 | BLOB_ERROR, \ |
AzureIoTClient | 42:448eecc3676e | 42 | BLOB_NOT_IMPLEMENTED, \ |
AzureIoTClient | 42:448eecc3676e | 43 | BLOB_HTTP_ERROR, \ |
AzureIoTClient | 82:f94e6bed4495 | 44 | BLOB_INVALID_ARG, \ |
AzureIoTClient | 82:f94e6bed4495 | 45 | BLOB_ABORTED |
AzureIoTClient | 42:448eecc3676e | 46 | |
AzureIoTClient | 42:448eecc3676e | 47 | DEFINE_ENUM(BLOB_RESULT, BLOB_RESULT_VALUES) |
AzureIoTClient | 42:448eecc3676e | 48 | |
AzureIoTClient | 42:448eecc3676e | 49 | /** |
AzureIoTClient | 80:db5f5237bc95 | 50 | * @brief Synchronously uploads a byte array to blob storage |
AzureIoTClient | 42:448eecc3676e | 51 | * |
AzureIoTClient | 80:db5f5237bc95 | 52 | * @param SASURI The URI to use to upload data |
AzureIoTClient | 82:f94e6bed4495 | 53 | * @param getDataCallbackEx A callback to be invoked to acquire the file chunks to be uploaded, as well as to indicate the status of the upload of the previous block. |
AzureIoTClient | 80:db5f5237bc95 | 54 | * @param context Any data provided by the user to serve as context on getDataCallback. |
AzureIoTClient | 80:db5f5237bc95 | 55 | * @param httpStatus A pointer to an out argument receiving the HTTP status (available only when the return value is BLOB_OK) |
AzureIoTClient | 80:db5f5237bc95 | 56 | * @param httpResponse A BUFFER_HANDLE that receives the HTTP response from the server (available only when the return value is BLOB_OK) |
AzureIoTClient | 80:db5f5237bc95 | 57 | * @param certificates A null terminated string containing CA certificates to be used |
AzureIoTClient | 79:bb88037c05e6 | 58 | * @param proxyOptions A structure that contains optional web proxy information |
AzureIoTClient | 42:448eecc3676e | 59 | * |
AzureIoTClient | 42:448eecc3676e | 60 | * @return A @c BLOB_RESULT. BLOB_OK means the blob has been uploaded successfully. Any other value indicates an error |
AzureIoTClient | 42:448eecc3676e | 61 | */ |
AzureIoTClient | 82:f94e6bed4495 | 62 | MOCKABLE_FUNCTION(, BLOB_RESULT, Blob_UploadMultipleBlocksFromSasUri, const char*, SASURI, IOTHUB_CLIENT_FILE_UPLOAD_GET_DATA_CALLBACK_EX, getDataCallbackEx, void*, context, unsigned int*, httpStatus, BUFFER_HANDLE, httpResponse, const char*, certificates, HTTP_PROXY_OPTIONS*, proxyOptions) |
AzureIoTClient | 42:448eecc3676e | 63 | |
AzureIoTClient | 80:db5f5237bc95 | 64 | /** |
AzureIoTClient | 80:db5f5237bc95 | 65 | * @brief Synchronously uploads a byte array as a new block to blob storage |
AzureIoTClient | 80:db5f5237bc95 | 66 | * |
AzureIoTClient | 80:db5f5237bc95 | 67 | * @param requestContent The data to upload |
AzureIoTClient | 80:db5f5237bc95 | 68 | * @param blockId The block id (from 00000 to 49999) |
AzureIoTClient | 80:db5f5237bc95 | 69 | * @param xml The XML file containing the blockId list |
AzureIoTClient | 80:db5f5237bc95 | 70 | * @param relativePath The destination path within the storage |
AzureIoTClient | 80:db5f5237bc95 | 71 | * @param httpApiExHandle The connection handle |
AzureIoTClient | 80:db5f5237bc95 | 72 | * @param httpStatus A pointer to an out argument receiving the HTTP status (available only when the return value is BLOB_OK) |
AzureIoTClient | 80:db5f5237bc95 | 73 | * @param httpResponse A BUFFER_HANDLE that receives the HTTP response from the server (available only when the return value is BLOB_OK) |
AzureIoTClient | 80:db5f5237bc95 | 74 | */ |
AzureIoTClient | 80:db5f5237bc95 | 75 | //MOCKABLE_FUNCTION(, BLOB_RESULT, Blob_UploadNextBlock, BUFFER_HANDLE, requestContent, unsigned int, blockID, STRING_HANDLE, xml, const char*, relativePath, HTTPAPIEX_HANDLE, httpApiExHandle, unsigned int*, httpStatus, BUFFER_HANDLE, httpResponse) |
AzureIoTClient | 80:db5f5237bc95 | 76 | MOCKABLE_FUNCTION(, BLOB_RESULT, Blob_UploadBlock, HTTPAPIEX_HANDLE, httpApiExHandle, const char*, relativePath, BUFFER_HANDLE, requestContent, unsigned int, blockID, STRING_HANDLE, blockIDList, unsigned int*, httpStatus, BUFFER_HANDLE, httpResponse) |
AzureIoTClient | 42:448eecc3676e | 77 | #ifdef __cplusplus |
AzureIoTClient | 42:448eecc3676e | 78 | } |
AzureIoTClient | 42:448eecc3676e | 79 | #endif |
AzureIoTClient | 42:448eecc3676e | 80 | |
AzureIoTClient | 42:448eecc3676e | 81 | #endif /* BLOB_H */ |