From daa52393eae7e4010727453c6db4aeeda8db7331 Mon Sep 17 00:00:00 2001 From: Euripedes Rocha Date: Tue, 11 Oct 2022 11:08:14 +0200 Subject: [PATCH 1/8] Adds fmtlib component - Adds fmtlib version 9.1.0 --- .github/workflows/upload_component.yml | 1 + .gitmodules | 3 +++ fmt/CMakeLists.txt | 6 ++++++ fmt/LICENSE.rst | 1 + fmt/README.md | 9 +++++++++ fmt/fmt | 1 + fmt/idf_component.yml | 5 +++++ test_app/CMakeLists.txt | 2 +- 8 files changed, 27 insertions(+), 1 deletion(-) create mode 100644 fmt/CMakeLists.txt create mode 120000 fmt/LICENSE.rst create mode 100644 fmt/README.md create mode 160000 fmt/fmt create mode 100644 fmt/idf_component.yml diff --git a/.github/workflows/upload_component.yml b/.github/workflows/upload_component.yml index d2dd3f1..4c42387 100644 --- a/.github/workflows/upload_component.yml +++ b/.github/workflows/upload_component.yml @@ -21,5 +21,6 @@ jobs: usb/usb_host_msc; usb/usb_host_uvc; usb/esp_modem_usb_dte; + fmt; namespace: "espressif" api_token: ${{ secrets.IDF_COMPONENT_API_TOKEN }} diff --git a/.gitmodules b/.gitmodules index ece5c44..3f5acb5 100644 --- a/.gitmodules +++ b/.gitmodules @@ -19,3 +19,6 @@ [submodule "eigen/eigen"] path = eigen/eigen url = https://gitlab.com/libeigen/eigen.git +[submodule "fmt/fmt"] + path = fmt/fmt + url = https://github.com/fmtlib/fmt.git diff --git a/fmt/CMakeLists.txt b/fmt/CMakeLists.txt new file mode 100644 index 0000000..375173a --- /dev/null +++ b/fmt/CMakeLists.txt @@ -0,0 +1,6 @@ +idf_component_register( ) + +add_subdirectory(fmt) + +target_link_libraries(${COMPONENT_LIB} INTERFACE fmt::fmt) + diff --git a/fmt/LICENSE.rst b/fmt/LICENSE.rst new file mode 120000 index 0000000..0e5e74b --- /dev/null +++ b/fmt/LICENSE.rst @@ -0,0 +1 @@ +fmt/LICENSE.rst \ No newline at end of file diff --git a/fmt/README.md b/fmt/README.md new file mode 100644 index 0000000..31c1ebf --- /dev/null +++ b/fmt/README.md @@ -0,0 +1,9 @@ + # FMT + + +**fmt** is an open-source formatting library providing a fast and safe +alternative to C stdio and C++ iostreams. + +See the project [README](fmt/README.rst) for details. + + diff --git a/fmt/fmt b/fmt/fmt new file mode 160000 index 0000000..a337011 --- /dev/null +++ b/fmt/fmt @@ -0,0 +1 @@ +Subproject commit a33701196adfad74917046096bf5a2aa0ab0bb50 diff --git a/fmt/idf_component.yml b/fmt/idf_component.yml new file mode 100644 index 0000000..9890bfb --- /dev/null +++ b/fmt/idf_component.yml @@ -0,0 +1,5 @@ +version: "9.1.0" +description: Formatting library providing a fast and safe alternative to C stdio and C++ iostreams. +url: https://github.com/espressif/idf-extra-components/tree/master/fmt +dependencies: + idf: ">=4.1" diff --git a/test_app/CMakeLists.txt b/test_app/CMakeLists.txt index d221af9..de9c41e 100644 --- a/test_app/CMakeLists.txt +++ b/test_app/CMakeLists.txt @@ -5,7 +5,7 @@ include($ENV{IDF_PATH}/tools/cmake/version.cmake) # Add newly added components to one of these lines: # 1. Add here if the component is compatible with IDF >= v4.3 -set(EXTRA_COMPONENT_DIRS ../libsodium ../expat ../cbor ../jsmn ../qrcode ../coap ../eigen) +set(EXTRA_COMPONENT_DIRS ../libsodium ../expat ../cbor ../jsmn ../qrcode ../coap ../eigen ../fmt) # 2. Add here if the component is compatible with IDF >= v4.4 if("${IDF_VERSION_MAJOR}.${IDF_VERSION_MINOR}" VERSION_GREATER_EQUAL "4.4") From bbea67a2d50136e3fbb0e5f83312a78571077981 Mon Sep 17 00:00:00 2001 From: Tomas Rezucha Date: Mon, 7 Nov 2022 17:21:02 +0100 Subject: [PATCH 2/8] usb: Allow CDC-ACM copy constructor --- usb/usb_host_cdc_acm/idf_component.yml | 2 +- usb/usb_host_cdc_acm/include/usb/cdc_acm_host.h | 1 - 2 files changed, 1 insertion(+), 2 deletions(-) diff --git a/usb/usb_host_cdc_acm/idf_component.yml b/usb/usb_host_cdc_acm/idf_component.yml index fc7a717..9a3469b 100644 --- a/usb/usb_host_cdc_acm/idf_component.yml +++ b/usb/usb_host_cdc_acm/idf_component.yml @@ -1,4 +1,4 @@ -version: "1.0.3" +version: "1.0.4" description: USB Host CDC-ACM driver url: https://github.com/espressif/idf-extra-components/tree/master/usb/usb_host_cdc_acm dependencies: diff --git a/usb/usb_host_cdc_acm/include/usb/cdc_acm_host.h b/usb/usb_host_cdc_acm/include/usb/cdc_acm_host.h index d1169e9..f947944 100644 --- a/usb/usb_host_cdc_acm/include/usb/cdc_acm_host.h +++ b/usb/usb_host_cdc_acm/include/usb/cdc_acm_host.h @@ -333,7 +333,6 @@ public: } private: - CdcAcmDevice(const CdcAcmDevice &Copy); CdcAcmDevice &operator= (const CdcAcmDevice &Copy); bool operator== (const CdcAcmDevice ¶m) const; bool operator!= (const CdcAcmDevice ¶m) const; From aac444fb0536442d77dcd52c2ecb671e46eae120 Mon Sep 17 00:00:00 2001 From: Tomas Rezucha Date: Mon, 7 Nov 2022 18:06:40 +0100 Subject: [PATCH 3/8] usb: Update USB tests to IDF v5.0 --- usb/test_app/main/idf_component.yml | 6 ++++++ usb/usb_host_cdc_acm/test/CMakeLists.txt | 9 ++++++++- usb/usb_host_cdc_acm/test/test_cdc_acm_host.c | 1 - usb/usb_host_msc/idf_component.yml | 2 +- usb/usb_host_msc/test/CMakeLists.txt | 9 ++++++++- usb/usb_host_msc/test/test_msc.c | 5 ++--- 6 files changed, 25 insertions(+), 7 deletions(-) create mode 100644 usb/test_app/main/idf_component.yml diff --git a/usb/test_app/main/idf_component.yml b/usb/test_app/main/idf_component.yml new file mode 100644 index 0000000..4ee8551 --- /dev/null +++ b/usb/test_app/main/idf_component.yml @@ -0,0 +1,6 @@ +## IDF Component Manager Manifest File +dependencies: + espressif/esp_tinyusb: + version: "0.0.1" + rules: + - if: "idf_version >= 5.0" diff --git a/usb/usb_host_cdc_acm/test/CMakeLists.txt b/usb/usb_host_cdc_acm/test/CMakeLists.txt index b1b360e..97c08f8 100644 --- a/usb/usb_host_cdc_acm/test/CMakeLists.txt +++ b/usb/usb_host_cdc_acm/test/CMakeLists.txt @@ -1,3 +1,10 @@ +include($ENV{IDF_PATH}/tools/cmake/version.cmake) +set (TINYUSB_LIB) +if("${IDF_VERSION_MAJOR}.${IDF_VERSION_MINOR}" VERSION_GREATER_EQUAL "5.0") + set(TINYUSB_LIB "esp_tinyusb") +else() + set(TINYUSB_LIB "tinyusb") +endif() idf_component_register(SRCS "test_cdc_acm_host.c" "usb_device.c" INCLUDE_DIRS "." - REQUIRES usb_host_cdc_acm tinyusb unity) + REQUIRES usb_host_cdc_acm unity ${TINYUSB_LIB}) diff --git a/usb/usb_host_cdc_acm/test/test_cdc_acm_host.c b/usb/usb_host_cdc_acm/test/test_cdc_acm_host.c index 91836c7..4dc7b38 100644 --- a/usb/usb_host_cdc_acm/test/test_cdc_acm_host.c +++ b/usb/usb_host_cdc_acm/test/test_cdc_acm_host.c @@ -48,7 +48,6 @@ void usb_lib_task(void *arg) .target = USB_PHY_TARGET_INT, .otg_mode = USB_OTG_MODE_HOST, .otg_speed = USB_PHY_SPEED_UNDEFINED, //In Host mode, the speed is determined by the connected device - .gpio_conf = NULL, }; TEST_ASSERT_EQUAL(ESP_OK, usb_new_phy(&phy_config, &phy_hdl)); // Install USB Host driver. Should only be called once in entire application diff --git a/usb/usb_host_msc/idf_component.yml b/usb/usb_host_msc/idf_component.yml index 3bb4ae4..57bb06e 100644 --- a/usb/usb_host_msc/idf_component.yml +++ b/usb/usb_host_msc/idf_component.yml @@ -1,4 +1,4 @@ -version: "1.0.2" +version: "1.0.3" description: USB Host MSC driver url: https://github.com/espressif/idf-extra-components/tree/master/usb/usb_host_msc diff --git a/usb/usb_host_msc/test/CMakeLists.txt b/usb/usb_host_msc/test/CMakeLists.txt index 1dd7e53..8225c98 100644 --- a/usb/usb_host_msc/test/CMakeLists.txt +++ b/usb/usb_host_msc/test/CMakeLists.txt @@ -1,3 +1,10 @@ +include($ENV{IDF_PATH}/tools/cmake/version.cmake) +set (TINYUSB_LIB) +if("${IDF_VERSION_MAJOR}.${IDF_VERSION_MINOR}" VERSION_GREATER_EQUAL "5.0") + set(TINYUSB_LIB "esp_tinyusb") +else() + set(TINYUSB_LIB "tinyusb") +endif() idf_component_register(SRC_DIRS . INCLUDE_DIRS . - REQUIRES unity usb usb_host_msc tinyusb) + REQUIRES unity usb usb_host_msc ${TINYUSB_LIB}) diff --git a/usb/usb_host_msc/test/test_msc.c b/usb/usb_host_msc/test/test_msc.c index 5fb6cba..81ba7e5 100644 --- a/usb/usb_host_msc/test/test_msc.c +++ b/usb/usb_host_msc/test/test_msc.c @@ -188,7 +188,6 @@ static void msc_setup(void) .target = USB_PHY_TARGET_INT, .otg_mode = USB_OTG_MODE_HOST, .otg_speed = USB_PHY_SPEED_UNDEFINED, //In Host mode, the speed is determined by the connected device - .gpio_conf = NULL, }; ESP_OK_ASSERT(usb_new_phy(&phy_config, &phy_hdl)); const usb_host_config_t host_config = { @@ -220,8 +219,7 @@ static void msc_setup(void) static void msc_teardown(void) { - // Wait to finish any ongoing USB operations - vTaskDelay(100); + vTaskDelay(10); // Wait to finish any ongoing USB operations ESP_OK_ASSERT( msc_host_vfs_unregister(vfs_handle) ); ESP_OK_ASSERT( msc_host_uninstall_device(device) ); @@ -235,6 +233,7 @@ static void msc_teardown(void) phy_hdl = NULL; vQueueDelete(app_queue); + vTaskDelay(10); // Wait for FreeRTOS to clean up deleted tasks } static void write_read_sectors(void) From 382402733c521e5306bb6ce29cbc721631c3d84d Mon Sep 17 00:00:00 2001 From: Harshit Malpani Date: Fri, 4 Nov 2022 15:22:08 +0530 Subject: [PATCH 4/8] expat: upgrade expat to v2.5.0 release --- expat/expat | 2 +- expat/idf_component.yml | 2 +- expat/port/include/expat_config.h | 6 +++--- 3 files changed, 5 insertions(+), 5 deletions(-) diff --git a/expat/expat b/expat/expat index 3bab6c0..454c610 160000 --- a/expat/expat +++ b/expat/expat @@ -1 +1 @@ -Subproject commit 3bab6c09bbe8bf42d84b81563ddbcf4cca4be838 +Subproject commit 454c6105bc2d0ea2521b8f8f7a5161c2abd8c386 diff --git a/expat/idf_component.yml b/expat/idf_component.yml index a2e6055..9ffae5a 100644 --- a/expat/idf_component.yml +++ b/expat/idf_component.yml @@ -1,4 +1,4 @@ -version: "2.4.8" +version: "2.5.0" description: "Expat - XML Parsing C Library" url: https://github.com/espressif/idf-extra-components/tree/master/expat dependencies: diff --git a/expat/port/include/expat_config.h b/expat/port/include/expat_config.h index 42acb52..c5a086c 100644 --- a/expat/port/include/expat_config.h +++ b/expat/port/include/expat_config.h @@ -63,7 +63,7 @@ #define PACKAGE_NAME "expat" /* Define to the full name and version of this package. */ -#define PACKAGE_STRING "expat 2.4.8" +#define PACKAGE_STRING "expat 2.5.0" /* Define to the one symbol short name of this package. */ #define PACKAGE_TARNAME "expat" @@ -72,13 +72,13 @@ #define PACKAGE_URL "" /* Define to the version of this package. */ -#define PACKAGE_VERSION "2.4.8" +#define PACKAGE_VERSION "2.5.0" /* Define to 1 if you have the ANSI C header files. */ #define STDC_HEADERS 1 /* Version number of package */ -#define VERSION "2.4.8" +#define VERSION "2.5.0" /* whether byteorder is bigendian */ /* #undef WORDS_BIGENDIAN */ From 7881a689e7ba803f60f317f57861d1cffddbe6ad Mon Sep 17 00:00:00 2001 From: Harshit Malpani Date: Fri, 4 Nov 2022 15:36:01 +0530 Subject: [PATCH 5/8] cbor: upgrade cbor library to v0.6.0 release https://github.com/intel/tinycbor/releases/tag/v0.6.0 --- cbor/CMakeLists.txt | 2 ++ cbor/idf_component.yml | 2 +- cbor/tinycbor | 2 +- 3 files changed, 4 insertions(+), 2 deletions(-) diff --git a/cbor/CMakeLists.txt b/cbor/CMakeLists.txt index f213c22..657184f 100644 --- a/cbor/CMakeLists.txt +++ b/cbor/CMakeLists.txt @@ -1,8 +1,10 @@ idf_component_register(SRCS "tinycbor/src/cborencoder_close_container_checked.c" "tinycbor/src/cborencoder.c" + "tinycbor/src/cborencoder_float.c" "tinycbor/src/cborerrorstrings.c" "tinycbor/src/cborparser_dup_string.c" "tinycbor/src/cborparser.c" + "tinycbor/src/cborparser_float.c" "tinycbor/src/cborpretty_stdio.c" "tinycbor/src/cborpretty.c" "tinycbor/src/cbortojson.c" diff --git a/cbor/idf_component.yml b/cbor/idf_component.yml index ff92d94..d37c848 100644 --- a/cbor/idf_component.yml +++ b/cbor/idf_component.yml @@ -1,4 +1,4 @@ -version: "0.5.4" +version: "0.6.0" description: "CBOR: Concise Binary Object Representation Library" url: https://github.com/espressif/idf-extra-components/tree/master/cbor dependencies: diff --git a/cbor/tinycbor b/cbor/tinycbor index 7c349db..d393c16 160000 --- a/cbor/tinycbor +++ b/cbor/tinycbor @@ -1 +1 @@ -Subproject commit 7c349dbb6b8d76db39383b226d3ebdf59b8ab37d +Subproject commit d393c16f3eb30d0c47e6f9d92db62272f0ec4dc7 From 4bd3b75197b2ad57a7dff91c4af338bb67e18997 Mon Sep 17 00:00:00 2001 From: Harshit Malpani Date: Fri, 4 Nov 2022 17:48:46 +0530 Subject: [PATCH 6/8] nghttp: update nghttp library to v1.50.0 release --- nghttp/CMakeLists.txt | 2 ++ nghttp/idf_component.yml | 2 +- nghttp/nghttp2 | 2 +- nghttp/port/include/nghttp2/nghttp2ver.h | 2 +- 4 files changed, 5 insertions(+), 3 deletions(-) diff --git a/nghttp/CMakeLists.txt b/nghttp/CMakeLists.txt index 25d013a..74ee3c1 100644 --- a/nghttp/CMakeLists.txt +++ b/nghttp/CMakeLists.txt @@ -2,6 +2,7 @@ set(srcs "nghttp2/lib/nghttp2_buf.c" "nghttp2/lib/nghttp2_callbacks.c" "nghttp2/lib/nghttp2_debug.c" + "nghttp2/lib/nghttp2_extpri.c" "nghttp2/lib/nghttp2_frame.c" "nghttp2/lib/nghttp2_hd.c" "nghttp2/lib/nghttp2_hd_huffman.c" @@ -26,4 +27,5 @@ idf_component_register(SRCS "${srcs}" INCLUDE_DIRS port/include nghttp2/lib/includes PRIV_INCLUDE_DIRS port/private_include) +target_compile_options(${COMPONENT_LIB} PRIVATE "-Wno-format") target_compile_definitions(${COMPONENT_LIB} PUBLIC "-DHAVE_CONFIG_H") diff --git a/nghttp/idf_component.yml b/nghttp/idf_component.yml index 104aae9..128e168 100644 --- a/nghttp/idf_component.yml +++ b/nghttp/idf_component.yml @@ -1,4 +1,4 @@ -version: "1.41.0" +version: "1.50.0" description: "nghttp2 - HTTP/2 C Library" url: https://github.com/espressif/idf-extra-components/tree/master/nghttp dependencies: diff --git a/nghttp/nghttp2 b/nghttp/nghttp2 index 8f7b008..87fef4a 160000 --- a/nghttp/nghttp2 +++ b/nghttp/nghttp2 @@ -1 +1 @@ -Subproject commit 8f7b008b158e12de0e58247afd170f127dbb6456 +Subproject commit 87fef4ab71bebb2168f8d3d554df8d2f0f01f497 diff --git a/nghttp/port/include/nghttp2/nghttp2ver.h b/nghttp/port/include/nghttp2/nghttp2ver.h index 795a44c..9884c5b 100644 --- a/nghttp/port/include/nghttp2/nghttp2ver.h +++ b/nghttp/port/include/nghttp2/nghttp2ver.h @@ -29,7 +29,7 @@ * @macro * Version number of the nghttp2 library release */ -#define NGHTTP2_VERSION "1.41.0" +#define NGHTTP2_VERSION "1.50.0" /** * @macro From 7998fd60b425d8f21eb0a7f79a24718ea226f96b Mon Sep 17 00:00:00 2001 From: Harshit Malpani Date: Mon, 7 Nov 2022 11:19:12 +0530 Subject: [PATCH 7/8] cbor: Add test for cbor component --- cbor/test/CMakeLists.txt | 4 + cbor/test/test.c | 230 +++++++++++++++++++++++++++++++++++++++ 2 files changed, 234 insertions(+) create mode 100644 cbor/test/CMakeLists.txt create mode 100644 cbor/test/test.c diff --git a/cbor/test/CMakeLists.txt b/cbor/test/CMakeLists.txt new file mode 100644 index 0000000..b39a409 --- /dev/null +++ b/cbor/test/CMakeLists.txt @@ -0,0 +1,4 @@ +idf_component_register(SRC_DIRS "." + PRIV_INCLUDE_DIRS "." + REQUIRES unity + PRIV_REQUIRES cmock cbor) diff --git a/cbor/test/test.c b/cbor/test/test.c new file mode 100644 index 0000000..eef53b1 --- /dev/null +++ b/cbor/test/test.c @@ -0,0 +1,230 @@ +/* + * SPDX-FileCopyrightText: 2021-2022 Espressif Systems (Shanghai) CO LTD + * + * SPDX-License-Identifier: Unlicense OR CC0-1.0 + */ +#include +#include + +#include "unity.h" +#if __has_include("esp_random.h") +#include "esp_random.h" +#else +#include "esp_system.h" +#endif + +#include "cbor.h" + +#define CBOR_CHECK(a, str, goto_tag, ret_value, ...) \ + do \ + { \ + if ((a) != CborNoError) \ + { \ + printf("%s(%d): " str, __FUNCTION__, __LINE__, ##__VA_ARGS__); \ + ret = ret_value; \ + goto goto_tag; \ + } \ + } while (0) + +static void indent(int nestingLevel) +{ + while (nestingLevel--) { + printf(" "); + } +} + +static void dumpbytes(const uint8_t *buf, size_t len) +{ + while (len--) { + printf("%02X ", *buf++); + } +} + +/** + * Decode CBOR data manuallly + */ +static CborError example_dump_cbor_buffer(CborValue *it, int nestingLevel) +{ + CborError ret = CborNoError; + while (!cbor_value_at_end(it)) { + CborType type = cbor_value_get_type(it); + + indent(nestingLevel); + switch (type) { + case CborArrayType: { + CborValue recursed; + assert(cbor_value_is_container(it)); + puts("Array["); + ret = cbor_value_enter_container(it, &recursed); + CBOR_CHECK(ret, "enter container failed", err, ret); + ret = example_dump_cbor_buffer(&recursed, nestingLevel + 1); + CBOR_CHECK(ret, "recursive dump failed", err, ret); + ret = cbor_value_leave_container(it, &recursed); + CBOR_CHECK(ret, "leave container failed", err, ret); + indent(nestingLevel); + puts("]"); + continue; + } + case CborMapType: { + CborValue recursed; + assert(cbor_value_is_container(it)); + puts("Map{"); + ret = cbor_value_enter_container(it, &recursed); + CBOR_CHECK(ret, "enter container failed", err, ret); + ret = example_dump_cbor_buffer(&recursed, nestingLevel + 1); + CBOR_CHECK(ret, "recursive dump failed", err, ret); + ret = cbor_value_leave_container(it, &recursed); + CBOR_CHECK(ret, "leave container failed", err, ret); + indent(nestingLevel); + puts("}"); + continue; + } + case CborIntegerType: { + int64_t val; + ret = cbor_value_get_int64(it, &val); + CBOR_CHECK(ret, "parse int64 failed", err, ret); + printf("%lld\n", (long long)val); + break; + } + case CborByteStringType: { + uint8_t *buf; + size_t n; + ret = cbor_value_dup_byte_string(it, &buf, &n, it); + CBOR_CHECK(ret, "parse byte string failed", err, ret); + dumpbytes(buf, n); + puts(""); + free(buf); + continue; + } + case CborTextStringType: { + char *buf; + size_t n; + ret = cbor_value_dup_text_string(it, &buf, &n, it); + CBOR_CHECK(ret, "parse text string failed", err, ret); + puts(buf); + free(buf); + continue; + } + case CborTagType: { + CborTag tag; + ret = cbor_value_get_tag(it, &tag); + CBOR_CHECK(ret, "parse tag failed", err, ret); + printf("Tag(%lld)\n", (long long)tag); + break; + } + case CborSimpleType: { + uint8_t type; + ret = cbor_value_get_simple_type(it, &type); + CBOR_CHECK(ret, "parse simple type failed", err, ret); + printf("simple(%u)\n", type); + break; + } + case CborNullType: + puts("null"); + break; + case CborUndefinedType: + puts("undefined"); + break; + case CborBooleanType: { + bool val; + ret = cbor_value_get_boolean(it, &val); + CBOR_CHECK(ret, "parse boolean type failed", err, ret); + puts(val ? "true" : "false"); + break; + } + case CborHalfFloatType: { + uint16_t val; + ret = cbor_value_get_half_float(it, &val); + CBOR_CHECK(ret, "parse half float type failed", err, ret); + printf("__f16(%04x)\n", val); + break; + } + case CborFloatType: { + float val; + ret = cbor_value_get_float(it, &val); + CBOR_CHECK(ret, "parse float type failed", err, ret); + printf("%g\n", val); + break; + } + case CborDoubleType: { + double val; + ret = cbor_value_get_double(it, &val); + CBOR_CHECK(ret, "parse double float type failed", err, ret); + printf("%g\n", val); + break; + } + case CborInvalidType: { + ret = CborErrorUnknownType; + CBOR_CHECK(ret, "unknown cbor type", err, ret); + break; + } + } + + ret = cbor_value_advance_fixed(it); + CBOR_CHECK(ret, "fix value failed", err, ret); + } + return CborNoError; +err: + return ret; +} + + +TEST_CASE("CBOR example", "[cbor]") +{ + CborEncoder root_encoder; + CborParser root_parser; + CborValue it; + uint8_t buf[100]; + + // Initialize the outermost cbor encoder + cbor_encoder_init(&root_encoder, buf, sizeof(buf), 0); + + // Create an array containing several items + CborEncoder array_encoder; + CborEncoder map_encoder; + cbor_encoder_create_array(&root_encoder, &array_encoder, 5); // [ + // 1. Create a map containing several pairs + cbor_encoder_create_map(&array_encoder, &map_encoder, 3); // { + // chip:esp32 + cbor_encode_text_stringz(&map_encoder, "chip"); + cbor_encode_text_stringz(&map_encoder, "esp32"); + // unicore:false + cbor_encode_text_stringz(&map_encoder, "unicore"); + cbor_encode_boolean(&map_encoder, false); + // ip:[192,168,1,100] + cbor_encode_text_stringz(&map_encoder, "ip"); + CborEncoder array2; + cbor_encoder_create_array(&map_encoder, &array2, 4); // [ + // Encode several numbers + cbor_encode_uint(&array2, 192); + cbor_encode_uint(&array2, 168); + cbor_encode_uint(&array2, 1); + cbor_encode_uint(&array2, 100); + cbor_encoder_close_container(&map_encoder, &array2); // ] + cbor_encoder_close_container(&array_encoder, &map_encoder); // } + // 2. Encode float number + cbor_encode_float(&array_encoder, 3.14); + // 3. Encode simple value + cbor_encode_simple_value(&array_encoder, 99); + // 4. Encode a string + cbor_encode_text_stringz(&array_encoder, "2019-07-10 09:00:00+0000"); + // 5. Encode a undefined value + cbor_encode_undefined(&array_encoder); + cbor_encoder_close_container(&root_encoder, &array_encoder); // ] + + // If error happend when encoding, then this value should be meaningless + printf("encoded buffer size %d", cbor_encoder_get_buffer_size(&root_encoder, buf)); + + // Initialize the cbor parser and the value iterator + cbor_parser_init(buf, sizeof(buf), 0, &root_parser, &it); + + printf("convert CBOR to JSON"); + // Dump the values in JSON format + cbor_value_to_json(stdout, &it, 0); + puts(""); + + printf("decode CBOR manually: "); + // Decode CBOR data manully + TEST_ESP_OK(example_dump_cbor_buffer(&it, 0)); +} + From 5d1a941a3ae174cf25ad9d2df4e64ef7e780de93 Mon Sep 17 00:00:00 2001 From: Vilem Zavodny Date: Tue, 15 Nov 2022 09:17:15 +0100 Subject: [PATCH 8/8] esp_jpeg: Fixed list of MCUs with TjpgDec in ROM in Readme --- esp_jpeg/README.md | 3 +-- esp_jpeg/idf_component.yml | 2 +- 2 files changed, 2 insertions(+), 3 deletions(-) diff --git a/esp_jpeg/README.md b/esp_jpeg/README.md index dc532f6..0268986 100644 --- a/esp_jpeg/README.md +++ b/esp_jpeg/README.md @@ -27,9 +27,8 @@ Some microcontrollers have TJpg decoder in ROM. It is used as default, but it ca ### List of MCUs, which have TJpgDec in ROM - ESP32 - ESP32-S3 -- ESP32-C2 - ESP32-C3 -- ESP32-H2 +- ESP32-C6 ### Fixed compilation configuration of the ROM code - Stream input buffer: 512 diff --git a/esp_jpeg/idf_component.yml b/esp_jpeg/idf_component.yml index 0517652..f4f08f8 100644 --- a/esp_jpeg/idf_component.yml +++ b/esp_jpeg/idf_component.yml @@ -1,4 +1,4 @@ -version: "1.0.3" +version: "1.0.4" description: "JPEG Decoder: TJpgDec" url: https://github.com/espressif/idf-extra-components/tree/master/esp_jpeg/ dependencies: