Missing esp_http_client component

I noticed that esp_http_client is not in the following directory

./amazon-freertos/vendors/espressif/esp-idf/components

However it is in the official esp-idf release v3.3
Link to ESP-IDF repo

So I was wondering how I could use this component for my ESP32? Thanks!

Notes
I have the latest Amazon FreeRTOS release

FreeRTOS has it’s own HTTPS client library, which have been tested against our other IoT Libraries.

For more information on adding esp_http_client component, members from @Espressif team should be able to help you.

1 Like

@isnore You can use esp_http_client from ESP-IDF v3.3 release, as long as you are using lwIP networking stack (using -DAFR_ESP_LWIP=1, please refer to https://docs.aws.amazon.com/freertos/latest/userguide/getting_started_espressif.html#build-and-run-example-espressif). It should work without any changes with required components copied into vendors/espressif/esp-idf/components. However, this can not work with FreeRTOS TCP stack, since it does not provide posix socket layer interface.

Let me know if you face any issues, can provide you with feature branch if required for same.

Thanks.

I am using the lwip stack but I still can’t seem to get it to work:

CMake Options

-DAFR_ESP_LWIP=1
-DCMAKE_TOOLCHAIN_FILE=amazon-freertos/tools/cmake/toolchains/xtensa-esp32.cmake
-GNinja

I copied and pasted esp_http_client from the release v3.3 branch into the following directory

./amazon-freertos/vendors/espressif/esp-idf/components/esp_http_client

This is the error output in the console:

====================[ Build | flash | Debug ]===================================
/usr/local/bin/cmake --build /Users/vp/esp/Pebble_ESP32_Firmware/build --target flash
[0/2] Re-checking globbed directories...
[1/2] Re-running CMake...
-- Submodule update
-- Checking Python dependencies...
Python requirements from /Users/vp/esp/Pebble_ESP32_Firmware/amazon-freertos/vendors/espressif/esp-idf/requirements.txt are satisfied.
-- Building for target esp32
CMake Error at /Users/vp/esp/Pebble_ESP32_Firmware/amazon-freertos/vendors/espressif/esp-idf/tools/cmake/component_utils.cmake:20 (message):
  Required component esp-tls is not found in any of the provided
  COMPONENT_DIRS
Call Stack (most recent call first):
  /Users/vp/esp/Pebble_ESP32_Firmware/amazon-freertos/vendors/espressif/esp-idf/tools/cmake/scripts/expand_requirements.cmake:95 (find_component_path)
  /Users/vp/esp/Pebble_ESP32_Firmware/amazon-freertos/vendors/espressif/esp-idf/tools/cmake/scripts/expand_requirements.cmake:114 (expand_component_requirements)
  /Users/vp/esp/Pebble_ESP32_Firmware/amazon-freertos/vendors/espressif/esp-idf/tools/cmake/scripts/expand_requirements.cmake:217 (expand_component_requirements)


CMake Error at amazon-freertos/vendors/espressif/esp-idf/tools/cmake/idf_functions.cmake:338 (message):
  Failed to expand component requirements
Call Stack (most recent call first):
  amazon-freertos/vendors/espressif/boards/esp32/CMakeLists.txt:437 (idf_import_components)
  amazon-freertos/CMakeLists.txt:49 (include)


-- Configuring incomplete, errors occurred!
See also "/Users/vp/esp/Pebble_ESP32_Firmware/build/CMakeFiles/CMakeOutput.log".
See also "/Users/vp/esp/Pebble_ESP32_Firmware/build/CMakeFiles/CMakeError.log".
FAILED: build.ninja 
/usr/local/Cellar/cmake/3.16.2/bin/cmake -S/Users/vp/esp/Pebble_ESP32_Firmware -B/Users/vp/esp/Pebble_ESP32_Firmware/build
ninja: error: rebuilding 'build.ninja': subcommand failed

Please let me know if you need any more information. Thanks!

Notes
Compiler:
– The C compiler identification is GNU 5.2.0
– The CXX compiler identification is GNU 5.2.0

Our project layout:
/components
----/wifi
--------/include
------------dns.h
--------/src
------------dns.c
--------CMakeLists.txt < this is the file that tries to include the esp_http_client
/src
----main.c

Amazon Version:
Latest version on master branch

@isnore esp_http_client requires esp-tls and tcp_transport components. These components should also be copied from release/v3.3.

I have pulled in all the required components in my feature branch. For reference, you can checkout to this branch.

2 Likes

Got it to compile! Thanks! Also copied over the mbedtls component from release/v3.3.

@isnore As mbedtls component is already available in Amazon FreeRTOS, it should not be copied from release/v3.3.

To build application using esp_http_client, a change is required in mbedtls port layer. I have added the change in the same branch. Please try building the application using this branch with LwIP stack. Feel free to post if you face any issues.

Thanks for the update! Got it working :slight_smile: