question

Suresh-8460 avatar image
0 Votes"
Suresh-8460 asked asergaz commented

CC3220SF Launch XL- Azure OTA Update over HTTP Client

Hi,

1) I am trying to do HTTP/s based OTA - Update using Azure SDK. (Please suggest any other best way to perform OTA over Azure SDK).

Able to compile and run "simplesample_http" example from Azure sdk <C:\ti\azure_cc32xx_4_10_01_01\examples\rtos\CC3220SF_LAUNCHXL\azure\simplesample_http>.


Based on this example (IOTHUB_CLIENT_LL), Is it possible to perform HTTP GET / POST operation, so that I can download the binary from the Azure -cloud?

I mean, looking for HTTPAPI_ExecuteRequest() equivalent API for IOTHUB_CLIENT_LL.

As I am new to Azure MOCKABLE AP,I not able to map the actual client API calls. Please give some reference to map azure MOCKABLE_FUNCTION APi to Actual HTTP / MQTT Client API.

2) Also, tried HTTP Client API direct accessing (from azure's httpapi_sl.c & httpapi.h). by taking the reference "uhttp" example code (C:\ti\azure_cc32xx_4_10_01_01\source\third_party\azure-iot-pal-simplelink\sdk\deps\uhttp\samples\uhttp_sample)

But I am facing the "HTTPAPI_OPEN_REQUEST_FAILED".

Please find the attached code snippet.


84869-azurehttp.txt


This way can I perform HTTP calls? If Yes, Where I am missing please guide me to override "HTTPAPI_OPEN_REQUEST_FAILED".



Regards,
Suresh

azure-iotazure-iot-sdk
azurehttp.txt (3.2 KiB)
· 1
5 |1600 characters needed characters left characters exceeded

Up to 10 attachments (including images) can be used with a maximum of 3.0 MiB each and 30.0 MiB total.

@Suresh-8460 can you confirm that you are using Azure IoT C SDK and Libraries: https://github.com/Azure/azure-iot-sdk-c ?

Unfortunately we don't have a sample for your specific board but can you take a look at Device Update for Azure IoT Hub tutorial using Azure Real Time Operating System (RTOS) since it may relate with what you are trying to achieve?

After you confirm what SDK and Links\Samples you are trying to follow we will be better informed to help getting your device connected.

Thanks!


0 Votes 0 ·
Suresh-8460 avatar image
0 Votes"
Suresh-8460 answered asergaz commented

Hi Asergaz,

Thanks for your support it helped me to get some clarity about OTA-Implementation. Please suggest few more points below.


  1. To download a file from Azure storage blob, is it required to connect using connection string? Example how we are connecting to IOT-HUB using connection string.


  2. As of now we are using HTTP- to download blob storage. Is MQTT available in Azure IoT C SDK to download a binary from azure storage blob?, does azure storage blob support binary downloading using MQTT in chunks?



Regards,
Suresh

· 1
5 |1600 characters needed characters left characters exceeded

Up to 10 attachments (including images) can be used with a maximum of 3.0 MiB each and 30.0 MiB total.

You are very welcome !

To download a file from Azure storage blob, is it required to connect using connection string? Example how we are connecting to IOT-HUB using connection string.

You can\should use a SAS Token: https://docs.microsoft.com/en-us/azure/storage/common/storage-sas-overview

As of now we are using HTTP- to download blob storage. Is MQTT available in Azure IoT C SDK to download a binary from azure storage blob?, does azure storage blob support binary downloading using MQTT in chunks?

No (and that I am aware we are not planning to change it either), the only way to connect to your Azure Blob Storage is using HTTPS REST API.

Please accept the best answer to this thread so others can find it useful as well :)!

Remember:
- Please accept an answer if correct. Original posters help the community find answers faster by identifying the correct answer. Here is how.



0 Votes 0 ·
asergaz avatar image
0 Votes"
asergaz answered asergaz edited

For point 1. Did you check this doc already? It is part of the C-SDK which is used by SimpleLink CC32XX SDK Azure IoT Plugin 4.10.01.01 SDK (for TI - CC3220SF- LaunchXL board).

https://github.com/Azure/azure-iot-sdk-c/blob/master/iothub_client/devdoc/requirement_docs/iothubhttptransport_requirements.md

86452-image.png



image.png (129.1 KiB)
· 4
5 |1600 characters needed characters left characters exceeded

Up to 10 attachments (including images) can be used with a maximum of 3.0 MiB each and 30.0 MiB total.

Hi Asergaz ,

Thanks for your response, your suggestions helped me a lot to move forward, like how IOTHUB_CLIENT_LL performing HTTP-GET and HTTP-POST operations.


Now, considering actual OTA operation, I have loaded OTA binary at Azure blob service, and got the URI to download the bin (Ex : https://{HOST_ID}.blob.core.windows.net/Suresh/FirmwareOTA.bin)


What will be the HTTP-GET process to download the binary from the device(CC3220SF)?
Please suggest any document or example as I can see only upload API to create/update the Blob from device IoTHubDeviceClient_LL_UploadMultipleBlocksToBlob"



Regards,
Suresh





0 Votes 0 ·

@Suresh-8460 you are welcome.

We don't recommend doing OTA updates that way, the recommendation is to use Device Update for IoT Hub - an end-to-end platform that customers can use to publish, distribute, and manage over-the-air updates for everything from tiny sensors to gateway-level devices: https://docs.microsoft.com/en-us/azure/iot-hub-device-update/understand-device-update

To use it you will provision device update agent alongside your device app: https://docs.microsoft.com/en-us/azure/iot-hub-device-update/device-update-agent-provisioning

Nevertheless, if you would like to use Azure Blob Service, your device should connect to it in a secure way and leverage the Blob Storage API: https://docs.microsoft.com/en-us/rest/api/storageservices/

Thank you!

0 Votes 0 ·

Hi Asergaz ,

Thankns for your support.

I am following the sample example to OTA-update to my device (CC3220SF).
OTA happening in the same way like HTTP-client is downloading from Azure's blob storage.

the problem is, I can't see any C-SDK blob HTTP-API for GET https://myaccount.blob.core.windows.net/mycontainer/myblob operation.


  1. Please guide me, How to connect and download azure blob stored binary.

  2. As I mentioned earlier blob.h is having only upload API's, is C-SDK supports download ? please confirm on this.


  3. I can see 2 types of connection strings for connectivity, which one I should use?

    A) -> HostName=<host_name>;DeviceId=<device_id>;SharedAccessSignature=<device_sas_token>
    B) -> DefaultEndpointsProtocol=[http|https];AccountName=myAccountName;AccountKey=myAccountKey



Regards,
Suresh




0 Votes 0 ·

Hi @Suresh-8460,

Notice from the sample you are following the HttpClient is separate from the Azure IoT C SDK.

88299-image.png

2) Azure IoT SDK only has the file upload to a Blob Storage capability - this is by design: https://docs.microsoft.com/en-us/azure/iot-hub/iot-hub-devguide-endpoints

  • I would recommend that you implement Azure SDK for Embedded C in your device if you want to download a file from Azure Storage Blob. You can leverage LibCurl to connect to your Azure Blob Storage using the REST API and download the binary file from the blob.

3) Please help me understand better where you want to add those connection strings?

Thanks!






0 Votes 0 ·
image.png (30.3 KiB)
Suresh-8460 avatar image
1 Vote"
Suresh-8460 answered Suresh-8460 edited

Hi Asergaz ,

Thanks for you response,

I am using SimpleLink CC32XX SDK Azure IoT Plugin 4.10.01.01 SDK (for TI - CC3220SF- LaunchXL board). Refer release_notes_azure_cc32xx_4_10_01_01.html & HTTP example simplesample_http.c.


My point 2 - (HTTP Client API direct accessing) is working and able to perform HTTP-GET operation. (due to TLS authentication didn't work my sample code before).


My point 1 - (with MOCKABLE API) still I am not clear. I understand that, some of the MOCKABLE API's like IoTHubClient_LL_CreateFromConnectionString to establish MQTT/ HTTP protocol by using connection string.

But If I wanted to perform HTTP-GET operation with IOTHUB_CLIENT_LL, what will be the HTTPAPI_ExecuteRequest() equivalent MOCKABLE API and how I am going to select HTTP-Methods(POST / GET / DELETE etc).
Please give help me to get more info.






Regards,
Suresh

5 |1600 characters needed characters left characters exceeded

Up to 10 attachments (including images) can be used with a maximum of 3.0 MiB each and 30.0 MiB total.