esp-azure icon indicating copy to clipboard operation
esp-azure copied to clipboard

Add support for "Upload To Blob" feature (CA-19)

Open giroudon opened this issue 5 years ago • 14 comments

Hello Esspressif Crew,

Here are some edits to support "Upload To Blob" operations in esp-azure. This required 2 things :

  • Enable HTTP(S) upload feature by adding httpapi_compact.c adapter in the component.mk list
  • Upgrade to azure-iot-sdk-c version 1.3.1 to avoid a NULL reference bug (issue #814)

Regards

giroudon avatar Nov 08 '19 14:11 giroudon

Hi,

I checkout and try to build it. I received the following error.

CMake Error at D:/ESP/esp-idf/tools/cmake/component.cmake:449 (add_library): Cannot find source file:

D:/ESP/esp-azure-goobie/azure-iot-sdk-c/c-utility/src/base64.c

The base64.c has been rename azure_base64.c

frederic-thibault avatar Nov 08 '19 18:11 frederic-thibault

Which version of esp-idf are you using? I try to build the with the release/v4.0

Another error that I can't fix.

D:/ESP/esp-azure-goobie/azure-iot-sdk-c/c-utility/inc/azure_c_shared_utility/strings.h:18:1: error: unknown type name 'MU_IF' MOCKABLE_FUNCTION(, STRING_HANDLE, STRING_new);

frederic-thibault avatar Nov 08 '19 18:11 frederic-thibault

I am using esp-idf v3.2.3 with the Makefile build system. Renaming of c-utility/src/base64.c to c-utility/src/azure_base64.c was done in commit 927f0a0 and should be replicated to CMake gears.

giroudon avatar Nov 08 '19 21:11 giroudon

Hi,

I finally make it works with CMakefile changes and idf v3 but my problem with the upload don't works when connecting to iot hub using x509 certificate. Sending messsage, direct method, registration using provisioning service works fine, but not upload. Upload works with sas but not certificate.

Thanks,

frederic-thibault avatar Nov 11 '19 15:11 frederic-thibault

Hi Frederic. After testing, I also noticed this issue when using x509 certificates. On devices configured using DPS provisioning, it fails with the x509 certificate method and works with the Symmetric Key method.

giroudon avatar Dec 03 '19 17:12 giroudon

Hi,

I didn't find where is the probleme exactly. IoTHub SDK doesn't upload the file directly to the hub. It is supposed to implement the valet key pattern. I believe that the problem is at the level of the request to receive the key and not for the upload .... for the moment at least.

I fix it by upload the file to a .net core 3 api with certificate authentication. The same certificate use for the provisioning. I cannot upload it directly to the blob using the valet key pattern because the blob doesn't support uploading with many chunk... or I didn't find how to do it.

Hopefully they will fix it one day!

B-Temia avatar Dec 04 '19 20:12 B-Temia

CLA assistant check
All committers have signed the CLA.

CLAassistant avatar Jul 10 '20 13:07 CLAassistant

@giroudon , thanks for the contribution. Do you mind adding examples for the features, in line with the other examples? That will make this PR complete.

shahpiyushv avatar Sep 11 '20 14:09 shahpiyushv

MQTT-over-WebSocket support now added to iothub_client_sample_mqtt/. Can be enabled from menuconfig (option "Example Configuration/MQTT over WebSocket"). This commit also fixes a TLS renegotiation option management, required for MQTT-over-WebSocket.

giroudon avatar Sep 15 '20 10:09 giroudon

@giroudon , sorry for the late response. Can you make these changes

  • Remove the updates made to the azure-iot-sdk-c submodule (wouldn't the current LTS release work)
  • Check if the TLS renegotiation logic can be removed, since it has been fixed in ESP IDF and backported till ESP IDF release/4.0.
  • Squash some commits so that the required changes are much more self explanatory, and probably split the MR into 2 (blob upload and websocket)

If you do not have enough time to make these changes, can you atleast take care of the last point and we will try to take up the rest internally.

shahpiyushv avatar Nov 02 '20 18:11 shahpiyushv

@giroudon , sorry for the late response. Can you make these changes

  • Remove the updates made to the azure-iot-sdk-c submodule (wouldn't the current LTS release work)
  • Check if the TLS renegotiation logic can be removed, since it has been fixed in ESP IDF and backported till ESP IDF release/4.0.
  • Squash some commits so that the required changes are much more self explanatory, and probably split the MR into 2 (blob upload and websocket)

If you do not have enough time to make these changes, can you atleast take care of the last point and we will try to take up the rest internally.

Hi guys! Is there any progress on this issue? The option to have MQTT over WebSocket is really quite cruical, and to have an officially supported version of this by Espressif is something that we would need in order to use your product on a large scale.

vidarmikaelsson avatar Nov 10 '20 10:11 vidarmikaelsson

As we are urgently waiting for the MQTT over WebSocket feature I have tested whether the implementation by @giroudon works for us. I have cloned the fork from goobie-lab:master, used it in our project and unfortunately it does not work for us.

Even the example iothub_client_sample_mqtt does not work, once I enable the SAMPLE_MQTT_OVER_WEBSOCKET config via menuconfig. It gives me the following linker error: undefined reference to MQTT_WebSocket_Protocol

Tested with esp-idf version v4.1.

@giroudon Does the example work for you? Which esp-idf version are you using for your tests? Please find the compiler log attached.

iothub_client_sample_mqtt_BuildCmdLineOutput.txt

daniel-grabner avatar Dec 14 '20 15:12 daniel-grabner

@daniel-grabner, the MQTT over WS is currently integrated on a commercial product using esp-idf 3.3.5. I confirm it is not yet operational on esp-idf 4. I will try to solve this issue as soon as possible (well I hope so... I do not have much time these days).

On esp-idf 3, you also need to checkout a recent version of mbedtls (2.16.7-idf) with the following command: (cd "$IDF_PATH/components/mbedtls/mbedtls/" && git checkout mbedtls-2.16.7-idf)

giroudon avatar Dec 14 '20 21:12 giroudon

Since I would like to have these fixes for WebSockets available, I decided to give a hand and split off the WebSocket-part of this PR into #111.

jspngh avatar Feb 18 '21 11:02 jspngh