diff --git a/doc/nrf/links.txt b/doc/nrf/links.txt index 7a1a97d802ed..94bab5831ab1 100644 --- a/doc/nrf/links.txt +++ b/doc/nrf/links.txt @@ -178,6 +178,9 @@ .. _`commit #d55314`: https://github.com/nrfconnect/sdk-nrf/commit/d553142f4f37bc324da9869e4837cdd9105e25ab +.. _`zcbor 0.8.0 release notes`: https://github.com/zephyrproject-rtos/zcbor/blob/0.8.0/RELEASE_NOTES.md +.. _`zcbor 0.8.1 release notes`: https://github.com/zephyrproject-rtos/zcbor/blob/0.8.1/RELEASE_NOTES.md + .. ### Source: github.io .. _`TinyCBOR`: https://intel.github.io/tinycbor/current/ diff --git a/doc/nrf/releases_and_maturity/releases/release-notes-changelog.rst b/doc/nrf/releases_and_maturity/releases/release-notes-changelog.rst index 2a0e646b391e..bd04d5abfa88 100644 --- a/doc/nrf/releases_and_maturity/releases/release-notes-changelog.rst +++ b/doc/nrf/releases_and_maturity/releases/release-notes-changelog.rst @@ -151,6 +151,8 @@ The following list summarizes the most important changes inherited from the upst * Renamed the ``CONFIG_CHIP_SED_ACTIVE_INTERVAL`` Kconfig option to :kconfig:option:`CONFIG_CHIP_ICD_FAST_POLLING_INTERVAL`. * Renamed the ``CONFIG_CHIP_SED_ACTIVE_THRESHOLD`` Kconfig option to :kconfig:option:`CONFIG_CHIP_ICD_ACTIVE_MODE_THRESHOLD`. + * zcbor 0.7.0 to 0.8.1. + Thread ------ @@ -358,6 +360,10 @@ Bluetooth samples * Corrected the behavior when building with the :ref:`ble_rpc` library. +* :ref:`bluetooth_central_dfu_smp` sample: + + * Updated to adapt to API changes in zcbor 0.8.x. + Bluetooth Mesh samples ---------------------- @@ -758,6 +764,13 @@ DFU libraries * The :kconfig:option:`CONFIG_DFU_TARGET_FULL_MODEM_USE_EXT_PARTITION` Kconfig option to be automatically enabled when ``nordic,pm-ext-flash`` is chosen in the devicetree. See :ref:`partition_manager` for details. + * Adapted to API changes in zcbor 0.8.x. + +* :ref:`lib_fmfu_fdev` library: + + * Updated: + + * Regenerated cbor code with zcbor 0.8.1 and adapted to API changes in zcbor 0.8.x. Modem libraries --------------- @@ -846,6 +859,10 @@ Modem libraries * Fixed a potential race condition, where two threads might corrupt a shared response buffer. +* :ref:`lib_modem_attest_token` library: + + * Updated to adapt to API changes in zcbor 0.8.x. + Libraries for networking ------------------------ @@ -898,6 +915,8 @@ Libraries for networking This parameter determines whether CoAP CON or NON messages are used. + * Regenerated cbor code with zcbor 0.8.1 and adapted to API changes in zcbor 0.8.x. + * :ref:`lib_nrf_cloud_log` library: * Added: @@ -932,9 +951,13 @@ Libraries for networking * :ref:`lib_nrf_provisioning` library: * Renamed nRF Device provisioning to :ref:`lib_nrf_provisioning`. - * Updated the device mode callback to send an event when the provisioning state changes. - * Fixed file descriptor handling by setting the :c:struct:`coap_client` structure's ``fd`` field to ``-1`` when closing the socket. * Added the :kconfig:option:`CONFIG_NRF_PROVISIONING_PRINT_ATTESTATION_TOKEN` option to enable printing the attestation token when the device is not yet claimed. + * Updated: + + * The device mode callback sends an event when the provisioning state changes. + * Regenerated cbor code with zcbor 0.8.1 and adapted to API changes in zcbor 0.8.x. + + * Fixed file descriptor handling by setting the :c:struct:`coap_client` structure's ``fd`` field to ``-1`` when closing the socket. * :ref:`lib_nrf_cloud_fota` library: @@ -1091,7 +1114,15 @@ Additions specific to |NCS| zcbor ===== -|no_changes_yet_note| +zcbor has been updated from 0.7.0 to 0.8.1. +For more information see the `zcbor 0.8.0 release notes`_ and the `zcbor 0.8.1 release notes`_. + +* Added: + + * Support for unordered maps. + * Performance improvements. + * Naming improvements for generated code. + * Bugfixes. Trusted Firmware-M ================== diff --git a/lib/modem_attest_token/modem_attest_token.c b/lib/modem_attest_token/modem_attest_token.c index 776881557feb..0082133d9be9 100644 --- a/lib/modem_attest_token/modem_attest_token.c +++ b/lib/modem_attest_token/modem_attest_token.c @@ -262,7 +262,8 @@ int modem_attest_token_parse(struct nrf_attestation_token const *const token_in, goto cleanup; } - zcbor_new_state(states, sizeof(states) / sizeof(zcbor_state_t), bin_buf, bin_buf_sz, 1); + zcbor_new_state(states, sizeof(states) / sizeof(zcbor_state_t), bin_buf, bin_buf_sz, 1, + NULL, 0); /* Get attestation token data */ err = get_attest_data(states, data_out); diff --git a/samples/bluetooth/central_smp_client/src/main.c b/samples/bluetooth/central_smp_client/src/main.c index 1b44eb48f76a..e97207af5696 100644 --- a/samples/bluetooth/central_smp_client/src/main.c +++ b/samples/bluetooth/central_smp_client/src/main.c @@ -306,7 +306,8 @@ static void smp_echo_rsp_proc(struct bt_dfu_smp *dfu_smp) char map_value[SMP_ECHO_MAP_VALUE_MAX_LEN]; bool ok; - zcbor_new_decode_state(zsd, ARRAY_SIZE(zsd), smp_rsp_buff.payload, payload_len, 1); + zcbor_new_decode_state(zsd, ARRAY_SIZE(zsd), smp_rsp_buff.payload, payload_len, 1, + NULL, 0); /* Stop decoding on the error. */ zsd->constant_state->stop_on_error = true; @@ -360,7 +361,7 @@ static void smp_echo_rsp_proc(struct bt_dfu_smp *dfu_smp) } static int send_smp_echo(struct bt_dfu_smp *dfu_smp, - const char *string) + const char *string, size_t string_max_len) { static struct smp_buffer smp_cmd; zcbor_state_t zse[CBOR_ENCODER_STATE_NUM]; @@ -374,7 +375,7 @@ static int send_smp_echo(struct bt_dfu_smp *dfu_smp, zcbor_map_start_encode(zse, CBOR_MAP_MAX_ELEMENT_CNT); zcbor_tstr_put_lit(zse, "d"); - zcbor_tstr_put_term(zse, string); + zcbor_tstr_put_term(zse, string, string_max_len); zcbor_map_end_encode(zse, CBOR_MAP_MAX_ELEMENT_CNT); if (!zcbor_check_error(zse)) { @@ -409,7 +410,7 @@ static void button_echo(bool state) ++echo_cnt; printk("Echo test: %d\n", echo_cnt); snprintk(buffer, sizeof(buffer), "Echo message: %u", echo_cnt); - ret = send_smp_echo(&dfu_smp, buffer); + ret = send_smp_echo(&dfu_smp, buffer, sizeof(buffer)); if (ret) { printk("Echo command send error (err: %d)\n", ret); } diff --git a/scripts/requirements-build.txt b/scripts/requirements-build.txt index 4262e3fd1a54..196301d22f12 100644 --- a/scripts/requirements-build.txt +++ b/scripts/requirements-build.txt @@ -5,4 +5,4 @@ cryptography>=42.0.0 imagesize>=1.2.0 intelhex pylint -zcbor +zcbor~=0.8.0 diff --git a/scripts/requirements-extra.txt b/scripts/requirements-extra.txt index 5e209a860269..2df755b089a3 100644 --- a/scripts/requirements-extra.txt +++ b/scripts/requirements-extra.txt @@ -3,5 +3,5 @@ Pillow>=10.2.0 editdistance>=0.5.0 PyGithub jinja2>=3.1.3 -zcbor==0.7.0 +zcbor>=0.8.0 nrfcredstore>=1.0.0,<2 diff --git a/scripts/requirements-fixed.txt b/scripts/requirements-fixed.txt index 803605293205..cbb392ea8676 100644 --- a/scripts/requirements-fixed.txt +++ b/scripts/requirements-fixed.txt @@ -35,7 +35,7 @@ future==0.18.3 # via junitparser gcovr==6.0 # via -r zephyr/scripts/requirements-build-test.txt gitdb==4.0.10 # via gitpython gitlint==0.18.0 # via -r nrf/scripts/requirements-ci.txt, -r zephyr/scripts/requirements-extras.txt -gitlint-core==0.18.0 # via gitlint, gitlint-core +gitlint-core==0.18.0 # via gitlint gitpython==3.1.41 # via -r nrf/scripts/requirements-ci.txt graphviz==0.20.1 # via -r zephyr/scripts/requirements-extras.txt grpcio==1.58.0 # via grpcio-tools @@ -84,7 +84,7 @@ pyelftools==0.30 # via -r zephyr/scripts/requirements-base.txt, pyocd pygit2==1.10.0 # via -r nrf/scripts/requirements-extra.txt pygithub==1.59.1 # via -r nrf/scripts/requirements-extra.txt, -r zephyr/scripts/requirements-extras.txt pygments==2.16.1 # via gcovr -pyjwt==2.8.0 # via pygithub, pyjwt +pyjwt==2.8.0 # via pygithub pykwalify==1.8.0 # via -r zephyr/scripts/requirements-base.txt, west pylink-square==1.2.0 # via -r zephyr/scripts/requirements-base.txt, pyocd pylint==2.17.5 # via -r nrf/scripts/requirements-build.txt, -r zephyr/scripts/requirements-compliance.txt @@ -125,7 +125,7 @@ west==1.2.0 # via -r nrf/scripts/requirements-base.txt, -r zephyr/ wget==3.2 # via -r nrf/scripts/requirements-ci.txt wrapt==1.15.0 # via astroid, deprecated, python-can yamllint==1.32.0 # via -r zephyr/scripts/requirements-compliance.txt -zcbor==0.7.0 # via -r nrf/scripts/requirements-build.txt, -r nrf/scripts/requirements-extra.txt, -r zephyr/scripts/requirements-extras.txt +zcbor==0.8.1 # via -r nrf/scripts/requirements-build.txt, -r nrf/scripts/requirements-extra.txt, -r zephyr/scripts/requirements-extras.txt zipp==3.17.0 # via importlib-metadata, importlib-resources # The following packages are considered to be unsafe in a requirements file: diff --git a/subsys/dfu/dfu_multi_image/src/dfu_multi_image.c b/subsys/dfu/dfu_multi_image/src/dfu_multi_image.c index e09a0a2e03ba..09c3d781b4c3 100644 --- a/subsys/dfu/dfu_multi_image/src/dfu_multi_image.c +++ b/subsys/dfu/dfu_multi_image/src/dfu_multi_image.c @@ -74,7 +74,7 @@ static int parse_cbor_header(void) uint_fast32_t image_count; ZCBOR_STATE_D(states, CBOR_HEADER_NESTING_LEVEL, ctx.buffer + FIXED_HEADER_SIZE, - ctx.cur_item_size - FIXED_HEADER_SIZE, 1); + ctx.cur_item_size - FIXED_HEADER_SIZE, 1, 0); res = zcbor_map_start_decode(states); res = res && zcbor_tstr_expect_lit(states, "img"); diff --git a/subsys/dfu/dfu_target/src/dfu_target_smp.c b/subsys/dfu/dfu_target/src/dfu_target_smp.c index 3b4f1ddbd51d..9675592202dd 100644 --- a/subsys/dfu/dfu_target/src/dfu_target_smp.c +++ b/subsys/dfu/dfu_target/src/dfu_target_smp.c @@ -314,7 +314,7 @@ static int dfu_target_smp_recovery_enable(void) { int rc; - rc = os_mgmt_client_echo(&os_gr_client, dfu_smp_echo_str); + rc = os_mgmt_client_echo(&os_gr_client, dfu_smp_echo_str, sizeof(dfu_smp_echo_str)); LOG_DBG("Recovery activate status %d", rc); return rc; diff --git a/subsys/dfu/fmfu_fdev/CMakeLists.txt b/subsys/dfu/fmfu_fdev/CMakeLists.txt index 9f812d4dc803..87aaa957ee9c 100644 --- a/subsys/dfu/fmfu_fdev/CMakeLists.txt +++ b/subsys/dfu/fmfu_fdev/CMakeLists.txt @@ -8,8 +8,6 @@ zephyr_library() zephyr_library_sources(src/fmfu_fdev.c) -zephyr_compile_definitions(fmfu_fdev CDDL_CBOR_CANONICAL) - if (CONFIG_FMFU_CDDL_DECODER_GENERATE) add_subdirectory(cddl) else() diff --git a/subsys/dfu/fmfu_fdev/Kconfig b/subsys/dfu/fmfu_fdev/Kconfig index 3bac826ca4dd..c4b11c048a07 100644 --- a/subsys/dfu/fmfu_fdev/Kconfig +++ b/subsys/dfu/fmfu_fdev/Kconfig @@ -14,7 +14,7 @@ menuconfig FMFU_FDEV if (FMFU_FDEV) config FMFU_CDDL_DECODER_GENERATE - bool + bool "Regenerate FMFU CBOR code from cddl using zcbor, for internal use." help Nordic internal, see cddl/CMakeLists.txt diff --git a/subsys/dfu/fmfu_fdev/cddl/CMakeLists.txt b/subsys/dfu/fmfu_fdev/cddl/CMakeLists.txt index 90f33222fd19..31fe7db6a879 100644 --- a/subsys/dfu/fmfu_fdev/cddl/CMakeLists.txt +++ b/subsys/dfu/fmfu_fdev/cddl/CMakeLists.txt @@ -54,9 +54,6 @@ find_program( if(NOT CLANG_FORMAT) message(WARNING "'clang-format' not found, generated code will not be formatted") -else() - set(CLANG_FORMAT_COMMAND - COMMAND ${CLANG_FORMAT} -i "${decode_c};${decode_h};${types_h}") endif() add_custom_command( @@ -64,9 +61,9 @@ add_custom_command( COMMAND ${PYTHON_EXECUTABLE} ${ZEPHYR_ZCBOR_MODULE_DIR}/zcbor/zcbor.py + code -c ${cddl_file} --default-max-qty 128 # TNSW-33521 - code --oc ${decode_c} --oh ${decode_h} --oht ${types_h} @@ -74,7 +71,6 @@ add_custom_command( -d # Decode COMMAND ${CMAKE_COMMAND} -DFILES="${decode_c}\;${decode_h}\;${types_h}" -P ${license} - ${CLANG_FORMAT_COMMAND} COMMENT "Generating files based on ${cddl_file}" DEPENDS ${license} ${cddl_file} @@ -86,11 +82,14 @@ zephyr_include_directories(${include_out}) # Create install target which allows the user to 'install' the generated # parser files into the working tree. +# Run clang format here in case the build folder is outside the nrf tree, +# in which case clang-format doesn't find the config file. add_custom_target( fmfu_cddl_modem_update_install COMMAND ${CMAKE_COMMAND} -E copy ${decode_c} ${src_install_dir}/${decode_c_name} COMMAND ${CMAKE_COMMAND} -E copy ${decode_h} ${include_install_dir}/${decode_h_name} COMMAND ${CMAKE_COMMAND} -E copy ${types_h} ${include_install_dir}/${types_h_name} + COMMAND ${CLANG_FORMAT} -i ${src_install_dir}/${decode_c_name} ${include_install_dir}/${decode_h_name} ${include_install_dir}/${types_h_name} DEPENDS ${decode_c} ${decode_h} ${types_h} COMMENT diff --git a/subsys/dfu/fmfu_fdev/cddl/license.cmake b/subsys/dfu/fmfu_fdev/cddl/license.cmake index a74cdfdfdbb2..3e2a64c9be03 100644 --- a/subsys/dfu/fmfu_fdev/cddl/license.cmake +++ b/subsys/dfu/fmfu_fdev/cddl/license.cmake @@ -4,9 +4,11 @@ # SPDX-License-Identifier: LicenseRef-Nordic-5-Clause # +string(TIMESTAMP NOW_YEAR "%Y") + set(LICENSE "\ /* - * Copyright (c) 2021 Nordic Semiconductor ASA + * Copyright (c) ${NOW_YEAR} Nordic Semiconductor ASA * * SPDX-License-Identifier: LicenseRef-Nordic-5-Clause */ diff --git a/subsys/dfu/fmfu_fdev/include/modem_update_decode.h b/subsys/dfu/fmfu_fdev/include/modem_update_decode.h index 1257884211c8..933ce49dddf7 100644 --- a/subsys/dfu/fmfu_fdev/include/modem_update_decode.h +++ b/subsys/dfu/fmfu_fdev/include/modem_update_decode.h @@ -1,11 +1,11 @@ /* - * Copyright (c) 2021 Nordic Semiconductor ASA + * Copyright (c) 2024 Nordic Semiconductor ASA * * SPDX-License-Identifier: LicenseRef-Nordic-5-Clause */ /* - * Generated using zcbor version 0.5.1 + * Generated using zcbor version 0.8.1 * https://github.com/NordicSemiconductor/zcbor * Generated with a --default-max-qty of 128 */ @@ -17,9 +17,12 @@ #include #include #include -#include "zcbor_decode.h" #include "modem_update_types.h" +#ifdef __cplusplus +extern "C" { +#endif + #if DEFAULT_MAX_QTY != 128 #error "The type file was generated with a different default_max_qty than this file" #endif @@ -33,4 +36,8 @@ int cbor_decode_Sig_structure1(const uint8_t *payload, size_t payload_len, int cbor_decode_Segments(const uint8_t *payload, size_t payload_len, struct Segments *result, size_t *payload_len_out); +#ifdef __cplusplus +} +#endif + #endif /* MODEM_UPDATE_DECODE_H__ */ diff --git a/subsys/dfu/fmfu_fdev/include/modem_update_types.h b/subsys/dfu/fmfu_fdev/include/modem_update_types.h index b51ee498ea8c..cc9fc701f74e 100644 --- a/subsys/dfu/fmfu_fdev/include/modem_update_types.h +++ b/subsys/dfu/fmfu_fdev/include/modem_update_types.h @@ -1,11 +1,11 @@ /* - * Copyright (c) 2021 Nordic Semiconductor ASA + * Copyright (c) 2024 Nordic Semiconductor ASA * * SPDX-License-Identifier: LicenseRef-Nordic-5-Clause */ /* - * Generated using zcbor version 0.5.1 + * Generated using zcbor version 0.8.1 * https://github.com/NordicSemiconductor/zcbor * Generated with a --default-max-qty of 128 */ @@ -16,8 +16,11 @@ #include #include #include -#include -#include "zcbor_decode.h" +#include + +#ifdef __cplusplus +extern "C" { +#endif /** Which value for --default-max-qty this file was created with. * @@ -29,30 +32,36 @@ #define DEFAULT_MAX_QTY 128 struct Segment { - uint32_t _Segment_target_addr; - uint32_t _Segment_len; + uint32_t Segment_target_addr; + uint32_t Segment_len; }; struct Segments { - struct Segment _Segments__Segment[128]; - uint_fast32_t _Segments__Segment_count; + struct Segment Segments_Segment_m[128]; + size_t Segments_Segment_m_count; }; struct Sig_structure1 { - struct zcbor_string _Sig_structure1_payload; + struct zcbor_string Sig_structure1_body_protected; + struct zcbor_string Sig_structure1_payload; }; struct Manifest { - uint32_t _Manifest_version; - uint32_t _Manifest_compat; - struct zcbor_string _Manifest_blob_hash; - struct zcbor_string _Manifest_segments; + uint32_t Manifest_version; + uint32_t Manifest_compat; + struct zcbor_string Manifest_blob_hash; + struct zcbor_string Manifest_segments; }; struct COSE_Sign1_Manifest { - struct zcbor_string _COSE_Sign1_Manifest_payload; - struct Manifest _COSE_Sign1_Manifest_payload_cbor; - struct zcbor_string _COSE_Sign1_Manifest_signature; + struct zcbor_string COSE_Sign1_Manifest_protected; + struct zcbor_string COSE_Sign1_Manifest_payload; + struct Manifest COSE_Sign1_Manifest_payload_cbor; + struct zcbor_string COSE_Sign1_Manifest_signature; }; +#ifdef __cplusplus +} +#endif + #endif /* MODEM_UPDATE_TYPES_H__ */ diff --git a/subsys/dfu/fmfu_fdev/src/fmfu_fdev.c b/subsys/dfu/fmfu_fdev/src/fmfu_fdev.c index fefe7c8aa0f1..4f5f6d4cc87a 100644 --- a/subsys/dfu/fmfu_fdev/src/fmfu_fdev.c +++ b/subsys/dfu/fmfu_fdev/src/fmfu_fdev.c @@ -19,9 +19,8 @@ LOG_MODULE_REGISTER(fmfu_fdev, CONFIG_FMFU_FDEV_LOG_LEVEL); static uint8_t meta_buf[MAX_META_LEN]; -static int get_hash_from_flash(const struct device *fdev, size_t offset, - size_t data_len, uint8_t *hash, uint8_t *buffer, - size_t buffer_len) +static int get_hash_from_flash(const struct device *fdev, size_t offset, size_t data_len, + uint8_t *hash, uint8_t *buffer, size_t buffer_len) { int err; mbedtls_sha256_context sha256_ctx; @@ -56,8 +55,7 @@ static int get_hash_from_flash(const struct device *fdev, size_t offset, return 0; } -static int write_chunk(uint8_t *buf, size_t buf_len, uint32_t address, - bool is_bootloader) +static int write_chunk(uint8_t *buf, size_t buf_len, uint32_t address, bool is_bootloader) { int err; @@ -78,9 +76,8 @@ static int write_chunk(uint8_t *buf, size_t buf_len, uint32_t address, return 0; } -static int load_segment(const struct device *fdev, size_t seg_size, - uint32_t seg_target_addr, uint32_t seg_offset, - uint8_t *buf, size_t buf_len, bool is_bootloader) +static int load_segment(const struct device *fdev, size_t seg_size, uint32_t seg_target_addr, + uint32_t seg_offset, uint8_t *buf, size_t buf_len, bool is_bootloader) { int err; uint32_t read_addr = seg_offset; @@ -95,15 +92,14 @@ static int load_segment(const struct device *fdev, size_t seg_size, return err; } - err = write_chunk(buf, read_len, seg_target_addr, - is_bootloader); + err = write_chunk(buf, read_len, seg_target_addr, is_bootloader); if (err != 0) { LOG_ERR("write_chunk failed: %d", err); return err; } - LOG_DBG("Wrote chunk: offset 0x%x target addr 0x%x size 0x%x", - read_addr, seg_target_addr, read_len); + LOG_DBG("Wrote chunk: offset 0x%x target addr 0x%x size 0x%x", read_addr, + seg_target_addr, read_len); seg_target_addr += read_len; bytes_left -= read_len; @@ -124,26 +120,24 @@ static int load_segment(const struct device *fdev, size_t seg_size, return 0; } -static int load_segments(const struct device *fdev, uint8_t *meta_buf, - size_t wrapper_len, const struct Segments *seg, - size_t blob_offset, uint8_t *buf, size_t buf_len) +static int load_segments(const struct device *fdev, uint8_t *meta_buf, size_t wrapper_len, + const struct Segments *seg, size_t blob_offset, uint8_t *buf, + size_t buf_len) { int err; size_t prev_segments_len = 0; - for (int i = 0; i < seg->_Segments__Segment_count; i++) { - size_t seg_size = seg->_Segments__Segment[i]._Segment_len; - uint32_t seg_addr = - seg->_Segments__Segment[i]._Segment_target_addr; + for (int i = 0; i < seg->Segments_Segment_m_count; i++) { + size_t seg_size = seg->Segments_Segment_m[i].Segment_len; + uint32_t seg_addr = seg->Segments_Segment_m[i].Segment_target_addr; uint32_t read_addr = blob_offset + prev_segments_len; bool is_bootloader = i == 0; - LOG_INF("Writing segment %d/%d, Target addr: 0x%x, size: 0%x", - i + 1, seg->_Segments__Segment_count, seg_addr, - seg_size); + LOG_INF("Writing segment %d/%d, Target addr: 0x%x, size: 0%x", i + 1, + seg->Segments_Segment_m_count, seg_addr, seg_size); - err = load_segment(fdev, seg_size, seg_addr, read_addr, buf, - buf_len, is_bootloader); + err = load_segment(fdev, seg_size, seg_addr, read_addr, buf, buf_len, + is_bootloader); if (err != 0) { LOG_ERR("load_segment failed: %d", err); return err; @@ -179,8 +173,7 @@ static int load_segments(const struct device *fdev, uint8_t *meta_buf, return 0; } -int fmfu_fdev_load(uint8_t *buf, size_t buf_len, const struct device *fdev, - size_t offset) +int fmfu_fdev_load(uint8_t *buf, size_t buf_len, const struct device *fdev, size_t offset) { const struct zcbor_string *segments_string; struct COSE_Sign1_Manifest wrapper; @@ -204,8 +197,7 @@ int fmfu_fdev_load(uint8_t *buf, size_t buf_len, const struct device *fdev, return err; } - if (cbor_decode_Wrapper(meta_buf, MAX_META_LEN, &wrapper, - &wrapper_len) != ZCBOR_SUCCESS) { + if (cbor_decode_Wrapper(meta_buf, MAX_META_LEN, &wrapper, &wrapper_len) != ZCBOR_SUCCESS) { LOG_ERR("Unable to decode wrapper"); return -EINVAL; } @@ -218,36 +210,31 @@ int fmfu_fdev_load(uint8_t *buf, size_t buf_len, const struct device *fdev, /* Get a pointer to, and decode, the segments as this is a cbor encoded * structure in itself. */ - segments_string = - &wrapper._COSE_Sign1_Manifest_payload_cbor._Manifest_segments; - if (cbor_decode_Segments(segments_string->value, segments_string->len, - &segments, NULL) != ZCBOR_SUCCESS) { + segments_string = &wrapper.COSE_Sign1_Manifest_payload_cbor.Manifest_segments; + if (cbor_decode_Segments(segments_string->value, segments_string->len, &segments, NULL) != + ZCBOR_SUCCESS) { LOG_ERR("Unable to decode segments"); return -EINVAL; } /* Extract the expected hash from the manifest */ - memcpy(expected_hash, - wrapper._COSE_Sign1_Manifest_payload_cbor._Manifest_blob_hash - .value, + memcpy(expected_hash, wrapper.COSE_Sign1_Manifest_payload_cbor.Manifest_blob_hash.value, sizeof(expected_hash)); /* Calculate total length of all segments */ blob_len = 0; - for (int i = 0; i < segments._Segments__Segment_count; i++) { - blob_len += segments._Segments__Segment[i]._Segment_len; + for (int i = 0; i < segments.Segments_Segment_m_count; i++) { + blob_len += segments.Segments_Segment_m[i].Segment_len; } - if (sizeof(hash) == - wrapper._COSE_Sign1_Manifest_payload_cbor._Manifest_blob_hash.len) { + if (sizeof(hash) == wrapper.COSE_Sign1_Manifest_payload_cbor.Manifest_blob_hash.len) { hash_len_valid = true; } else { LOG_ERR("Invalid hash length"); return -EINVAL; } - err = get_hash_from_flash(fdev, blob_offset, blob_len, hash, buf, - buf_len); + err = get_hash_from_flash(fdev, blob_offset, blob_len, hash, buf, buf_len); if (err != 0) { return err; } @@ -261,8 +248,7 @@ int fmfu_fdev_load(uint8_t *buf, size_t buf_len, const struct device *fdev, if (hash_len_valid && hash_valid) { return load_segments(fdev, meta_buf, wrapper_len, - (const struct Segments *)&segments, - blob_offset, buf, buf_len); + (const struct Segments *)&segments, blob_offset, buf, buf_len); } else { return -EINVAL; } diff --git a/subsys/dfu/fmfu_fdev/src/modem_update_decode.c b/subsys/dfu/fmfu_fdev/src/modem_update_decode.c index 1435c6de538c..423c3d73dd06 100644 --- a/subsys/dfu/fmfu_fdev/src/modem_update_decode.c +++ b/subsys/dfu/fmfu_fdev/src/modem_update_decode.c @@ -1,11 +1,11 @@ /* - * Copyright (c) 2021 Nordic Semiconductor ASA + * Copyright (c) 2024 Nordic Semiconductor ASA * * SPDX-License-Identifier: LicenseRef-Nordic-5-Clause */ /* - * Generated using zcbor version 0.5.1 + * Generated using zcbor version 0.8.1 * https://github.com/NordicSemiconductor/zcbor * Generated with a --default-max-qty of 128 */ @@ -16,6 +16,7 @@ #include #include "zcbor_decode.h" #include "modem_update_decode.h" +#include "zcbor_print.h" #if DEFAULT_MAX_QTY != 128 #error "The type file was generated with a different default_max_qty than this file" @@ -31,20 +32,24 @@ static bool decode_Wrapper(zcbor_state_t *state, struct COSE_Sign1_Manifest *res static bool decode_Segment(zcbor_state_t *state, struct Segment *result) { - zcbor_print("%s\r\n", __func__); + zcbor_log("%s\r\n", __func__); - bool tmp_result = (((((zcbor_uint32_decode(state, (&(*result)._Segment_target_addr)))) && - ((zcbor_uint32_decode(state, (&(*result)._Segment_len))))))); + bool tmp_result = (((((zcbor_uint32_decode(state, (&(*result).Segment_target_addr)))) && + ((zcbor_uint32_decode(state, (&(*result).Segment_len))))))); - if (!tmp_result) - zcbor_trace(); + if (!tmp_result) { + zcbor_trace_file(state); + zcbor_log("%s error: %s\r\n", __func__, zcbor_error_str(zcbor_peek_error(state))); + } else { + zcbor_log("%s success\r\n", __func__); + } return tmp_result; } static bool decode_header_map(zcbor_state_t *state, void *result) { - zcbor_print("%s\r\n", __func__); + zcbor_log("%s\r\n", __func__); bool tmp_result = (((zcbor_map_start_decode(state) && @@ -52,82 +57,98 @@ static bool decode_header_map(zcbor_state_t *state, void *result) (zcbor_list_map_end_force_decode(state), false)) && zcbor_map_end_decode(state)))); - if (!tmp_result) - zcbor_trace(); + if (!tmp_result) { + zcbor_trace_file(state); + zcbor_log("%s error: %s\r\n", __func__, zcbor_error_str(zcbor_peek_error(state))); + } else { + zcbor_log("%s success\r\n", __func__); + } return tmp_result; } static bool decode_Manifest(zcbor_state_t *state, struct Manifest *result) { - zcbor_print("%s\r\n", __func__); + zcbor_log("%s\r\n", __func__); bool tmp_result = (((zcbor_list_start_decode(state) && - ((((zcbor_uint32_decode(state, (&(*result)._Manifest_version)))) && - ((zcbor_uint32_decode(state, (&(*result)._Manifest_compat)))) && - ((zcbor_bstr_decode(state, (&(*result)._Manifest_blob_hash))) && - ((((*result)._Manifest_blob_hash.len >= 32) && - ((*result)._Manifest_blob_hash.len <= 32)) || + ((((zcbor_uint32_decode(state, (&(*result).Manifest_version)))) && + ((zcbor_uint32_decode(state, (&(*result).Manifest_compat)))) && + ((zcbor_bstr_decode(state, (&(*result).Manifest_blob_hash))) && + ((((*result).Manifest_blob_hash.len >= 32) && + ((*result).Manifest_blob_hash.len <= 32)) || (zcbor_error(state, ZCBOR_ERR_WRONG_RANGE), false))) && - ((zcbor_bstr_decode(state, (&(*result)._Manifest_segments))))) || + ((zcbor_bstr_decode(state, (&(*result).Manifest_segments))))) || (zcbor_list_map_end_force_decode(state), false)) && zcbor_list_end_decode(state)))); - if (!tmp_result) - zcbor_trace(); + if (!tmp_result) { + zcbor_trace_file(state); + zcbor_log("%s error: %s\r\n", __func__, zcbor_error_str(zcbor_peek_error(state))); + } else { + zcbor_log("%s success\r\n", __func__); + } return tmp_result; } static bool decode_COSE_Sign1_Manifest(zcbor_state_t *state, struct COSE_Sign1_Manifest *result) { - zcbor_print("%s\r\n", __func__); + zcbor_log("%s\r\n", __func__); bool int_res; bool tmp_result = (((zcbor_list_start_decode(state) && - ((((zcbor_bstr_start_decode(state, NULL) && + ((((zcbor_bstr_start_decode(state, &(*result).COSE_Sign1_Manifest_protected) && (int_res = (((decode_header_map(state, NULL)))), zcbor_bstr_end_decode(state), int_res))) && ((zcbor_map_start_decode(state) && zcbor_map_end_decode(state))) && - ((zcbor_bstr_start_decode(state, &(*result)._COSE_Sign1_Manifest_payload) && + ((zcbor_bstr_start_decode(state, &(*result).COSE_Sign1_Manifest_payload) && (int_res = (((decode_Manifest( - state, (&(*result)._COSE_Sign1_Manifest_payload_cbor))))), + state, (&(*result).COSE_Sign1_Manifest_payload_cbor))))), zcbor_bstr_end_decode(state), int_res))) && - ((zcbor_bstr_decode(state, (&(*result)._COSE_Sign1_Manifest_signature))) && - ((((*result)._COSE_Sign1_Manifest_signature.len >= 256) && - ((*result)._COSE_Sign1_Manifest_signature.len <= 256)) || + ((zcbor_bstr_decode(state, (&(*result).COSE_Sign1_Manifest_signature))) && + ((((*result).COSE_Sign1_Manifest_signature.len >= 256) && + ((*result).COSE_Sign1_Manifest_signature.len <= 256)) || (zcbor_error(state, ZCBOR_ERR_WRONG_RANGE), false)))) || (zcbor_list_map_end_force_decode(state), false)) && zcbor_list_end_decode(state)))); - if (!tmp_result) - zcbor_trace(); + if (!tmp_result) { + zcbor_trace_file(state); + zcbor_log("%s error: %s\r\n", __func__, zcbor_error_str(zcbor_peek_error(state))); + } else { + zcbor_log("%s success\r\n", __func__); + } return tmp_result; } static bool decode_Segments(zcbor_state_t *state, struct Segments *result) { - zcbor_print("%s\r\n", __func__); + zcbor_log("%s\r\n", __func__); bool tmp_result = (((zcbor_list_start_decode(state) && - ((zcbor_multi_decode(1, 128, &(*result)._Segments__Segment_count, + ((zcbor_multi_decode(1, 128, &(*result).Segments_Segment_m_count, (zcbor_decoder_t *)decode_Segment, state, - (&(*result)._Segments__Segment), sizeof(struct Segment))) || + (&(*result).Segments_Segment_m), sizeof(struct Segment))) || (zcbor_list_map_end_force_decode(state), false)) && zcbor_list_end_decode(state)))); - if (!tmp_result) - zcbor_trace(); + if (!tmp_result) { + zcbor_trace_file(state); + zcbor_log("%s error: %s\r\n", __func__, zcbor_error_str(zcbor_peek_error(state))); + } else { + zcbor_log("%s success\r\n", __func__); + } return tmp_result; } static bool decode_Sig_structure1(zcbor_state_t *state, struct Sig_structure1 *result) { - zcbor_print("%s\r\n", __func__); + zcbor_log("%s\r\n", __func__); struct zcbor_string tmp_str; bool int_res; @@ -136,30 +157,38 @@ static bool decode_Sig_structure1(zcbor_state_t *state, struct Sig_structure1 *r ((((zcbor_tstr_expect(state, ((tmp_str.value = (uint8_t *)"Signature1", tmp_str.len = sizeof("Signature1") - 1, &tmp_str))))) && - ((zcbor_bstr_start_decode(state, NULL) && + ((zcbor_bstr_start_decode(state, &(*result).Sig_structure1_body_protected) && (int_res = (((decode_header_map(state, NULL)))), zcbor_bstr_end_decode(state), int_res))) && ((zcbor_bstr_expect(state, ((tmp_str.value = (uint8_t *)"", tmp_str.len = sizeof("") - 1, &tmp_str))))) && - ((zcbor_bstr_decode(state, (&(*result)._Sig_structure1_payload))))) || + ((zcbor_bstr_decode(state, (&(*result).Sig_structure1_payload))))) || (zcbor_list_map_end_force_decode(state), false)) && zcbor_list_end_decode(state)))); - if (!tmp_result) - zcbor_trace(); + if (!tmp_result) { + zcbor_trace_file(state); + zcbor_log("%s error: %s\r\n", __func__, zcbor_error_str(zcbor_peek_error(state))); + } else { + zcbor_log("%s success\r\n", __func__); + } return tmp_result; } static bool decode_Wrapper(zcbor_state_t *state, struct COSE_Sign1_Manifest *result) { - zcbor_print("%s\r\n", __func__); + zcbor_log("%s\r\n", __func__); bool tmp_result = ((zcbor_tag_expect(state, 18) && (decode_COSE_Sign1_Manifest(state, (&(*result)))))); - if (!tmp_result) - zcbor_trace(); + if (!tmp_result) { + zcbor_trace_file(state); + zcbor_log("%s error: %s\r\n", __func__, zcbor_error_str(zcbor_peek_error(state))); + } else { + zcbor_log("%s success\r\n", __func__); + } return tmp_result; } @@ -169,21 +198,9 @@ int cbor_decode_Wrapper(const uint8_t *payload, size_t payload_len, { zcbor_state_t states[5]; - zcbor_new_state(states, sizeof(states) / sizeof(zcbor_state_t), payload, payload_len, 1); - - bool ret = decode_Wrapper(states, result); - - if (ret && (payload_len_out != NULL)) { - *payload_len_out = MIN(payload_len, (size_t)states[0].payload - (size_t)payload); - } - - if (!ret) { - int err = zcbor_pop_error(states); - - zcbor_print("Return error: %d\r\n", err); - return (err == ZCBOR_SUCCESS) ? ZCBOR_ERR_UNKNOWN : err; - } - return ZCBOR_SUCCESS; + return zcbor_entry_function(payload, payload_len, (void *)result, payload_len_out, states, + (zcbor_decoder_t *)decode_Wrapper, + sizeof(states) / sizeof(zcbor_state_t), 1); } int cbor_decode_Sig_structure1(const uint8_t *payload, size_t payload_len, @@ -191,21 +208,9 @@ int cbor_decode_Sig_structure1(const uint8_t *payload, size_t payload_len, { zcbor_state_t states[5]; - zcbor_new_state(states, sizeof(states) / sizeof(zcbor_state_t), payload, payload_len, 1); - - bool ret = decode_Sig_structure1(states, result); - - if (ret && (payload_len_out != NULL)) { - *payload_len_out = MIN(payload_len, (size_t)states[0].payload - (size_t)payload); - } - - if (!ret) { - int err = zcbor_pop_error(states); - - zcbor_print("Return error: %d\r\n", err); - return (err == ZCBOR_SUCCESS) ? ZCBOR_ERR_UNKNOWN : err; - } - return ZCBOR_SUCCESS; + return zcbor_entry_function(payload, payload_len, (void *)result, payload_len_out, states, + (zcbor_decoder_t *)decode_Sig_structure1, + sizeof(states) / sizeof(zcbor_state_t), 1); } int cbor_decode_Segments(const uint8_t *payload, size_t payload_len, struct Segments *result, @@ -213,19 +218,7 @@ int cbor_decode_Segments(const uint8_t *payload, size_t payload_len, struct Segm { zcbor_state_t states[3]; - zcbor_new_state(states, sizeof(states) / sizeof(zcbor_state_t), payload, payload_len, 1); - - bool ret = decode_Segments(states, result); - - if (ret && (payload_len_out != NULL)) { - *payload_len_out = MIN(payload_len, (size_t)states[0].payload - (size_t)payload); - } - - if (!ret) { - int err = zcbor_pop_error(states); - - zcbor_print("Return error: %d\r\n", err); - return (err == ZCBOR_SUCCESS) ? ZCBOR_ERR_UNKNOWN : err; - } - return ZCBOR_SUCCESS; + return zcbor_entry_function(payload, payload_len, (void *)result, payload_len_out, states, + (zcbor_decoder_t *)decode_Segments, + sizeof(states) / sizeof(zcbor_state_t), 1); } diff --git a/subsys/net/lib/nrf_cloud/CMakeLists.txt b/subsys/net/lib/nrf_cloud/CMakeLists.txt index ca7e65c6e193..11224d0d3a30 100644 --- a/subsys/net/lib/nrf_cloud/CMakeLists.txt +++ b/subsys/net/lib/nrf_cloud/CMakeLists.txt @@ -50,8 +50,7 @@ zephyr_library_sources_ifdef( CONFIG_NRF_CLOUD_REST src/nrf_cloud_rest.c) zephyr_compile_definitions_ifdef( - CONFIG_NRF_CLOUD_COAP - CDDL_CBOR_CANONICAL) + CONFIG_NRF_CLOUD_COAP) zephyr_library_sources_ifdef( CONFIG_NRF_CLOUD_COAP coap/src/agnss_encode.c diff --git a/subsys/net/lib/nrf_cloud/coap/include/agnss_encode.h b/subsys/net/lib/nrf_cloud/coap/include/agnss_encode.h index b55c36a0ad6c..ef9de30a00c0 100644 --- a/subsys/net/lib/nrf_cloud/coap/include/agnss_encode.h +++ b/subsys/net/lib/nrf_cloud/coap/include/agnss_encode.h @@ -1,8 +1,8 @@ /* - * Copyright (c) 2023 Nordic Semiconductor ASA + * Copyright (c) 2024 Nordic Semiconductor ASA * SPDX-License-Identifier: LicenseRef-Nordic-5-Clause * - * Generated using zcbor version 0.7.0 + * Generated using zcbor version 0.8.1 * https://github.com/NordicSemiconductor/zcbor * Generated with a --default-max-qty of 10 */ diff --git a/subsys/net/lib/nrf_cloud/coap/include/agnss_encode_types.h b/subsys/net/lib/nrf_cloud/coap/include/agnss_encode_types.h index ad85771e632c..cc94719c8784 100644 --- a/subsys/net/lib/nrf_cloud/coap/include/agnss_encode_types.h +++ b/subsys/net/lib/nrf_cloud/coap/include/agnss_encode_types.h @@ -1,8 +1,8 @@ /* - * Copyright (c) 2023 Nordic Semiconductor ASA + * Copyright (c) 2024 Nordic Semiconductor ASA * SPDX-License-Identifier: LicenseRef-Nordic-5-Clause * - * Generated using zcbor version 0.7.0 + * Generated using zcbor version 0.8.1 * https://github.com/NordicSemiconductor/zcbor * Generated with a --default-max-qty of 10 */ @@ -27,36 +27,36 @@ extern "C" { */ #define DEFAULT_MAX_QTY 10 -struct agnss_req_types_ { - int32_t _agnss_req_types_int[13]; - size_t _agnss_req_types_int_count; +struct agnss_req_types_r { + int32_t agnss_req_types_int[13]; + size_t agnss_req_types_int_count; }; struct agnss_req_filtered { - bool _agnss_req_filtered; + bool agnss_req_filtered; }; struct agnss_req_mask { - uint32_t _agnss_req_mask; + uint32_t agnss_req_mask; }; struct agnss_req_rsrp { - int32_t _agnss_req_rsrp; + int32_t agnss_req_rsrp; }; struct agnss_req { - struct agnss_req_types_ _agnss_req_types; - bool _agnss_req_types_present; - uint32_t _agnss_req_eci; - struct agnss_req_filtered _agnss_req_filtered; - bool _agnss_req_filtered_present; - struct agnss_req_mask _agnss_req_mask; - bool _agnss_req_mask_present; - uint32_t _agnss_req_mcc; - uint32_t _agnss_req_mnc; - struct agnss_req_rsrp _agnss_req_rsrp; - bool _agnss_req_rsrp_present; - uint32_t _agnss_req_tac; + struct agnss_req_types_r agnss_req_types; + bool agnss_req_types_present; + uint32_t agnss_req_eci; + struct agnss_req_filtered agnss_req_filtered; + bool agnss_req_filtered_present; + struct agnss_req_mask agnss_req_mask; + bool agnss_req_mask_present; + uint32_t agnss_req_mcc; + uint32_t agnss_req_mnc; + struct agnss_req_rsrp agnss_req_rsrp; + bool agnss_req_rsrp_present; + uint32_t agnss_req_tac; }; #ifdef __cplusplus diff --git a/subsys/net/lib/nrf_cloud/coap/include/ground_fix_decode.h b/subsys/net/lib/nrf_cloud/coap/include/ground_fix_decode.h index e3f6b968f169..11daefa8d0ed 100644 --- a/subsys/net/lib/nrf_cloud/coap/include/ground_fix_decode.h +++ b/subsys/net/lib/nrf_cloud/coap/include/ground_fix_decode.h @@ -1,8 +1,8 @@ /* - * Copyright (c) 2023 Nordic Semiconductor ASA + * Copyright (c) 2024 Nordic Semiconductor ASA * SPDX-License-Identifier: LicenseRef-Nordic-5-Clause * - * Generated using zcbor version 0.7.0 + * Generated using zcbor version 0.8.1 * https://github.com/NordicSemiconductor/zcbor * Generated with a --default-max-qty of 10 */ diff --git a/subsys/net/lib/nrf_cloud/coap/include/ground_fix_decode_types.h b/subsys/net/lib/nrf_cloud/coap/include/ground_fix_decode_types.h index 85a7b6f2832f..e9effd0c9d51 100644 --- a/subsys/net/lib/nrf_cloud/coap/include/ground_fix_decode_types.h +++ b/subsys/net/lib/nrf_cloud/coap/include/ground_fix_decode_types.h @@ -1,8 +1,8 @@ /* - * Copyright (c) 2023 Nordic Semiconductor ASA + * Copyright (c) 2024 Nordic Semiconductor ASA * SPDX-License-Identifier: LicenseRef-Nordic-5-Clause * - * Generated using zcbor version 0.7.0 + * Generated using zcbor version 0.8.1 * https://github.com/NordicSemiconductor/zcbor * Generated with a --default-max-qty of 10 */ @@ -29,17 +29,17 @@ extern "C" { #define DEFAULT_MAX_QTY 10 struct ground_fix_resp { - double _ground_fix_resp_lat; - double _ground_fix_resp_lon; + double ground_fix_resp_lat; + double ground_fix_resp_lon; union { - int32_t _ground_fix_resp_uncertainty_int; - double _ground_fix_resp_uncertainty_float; + int32_t ground_fix_resp_uncertainty_int; + double ground_fix_resp_uncertainty_float; }; enum { - _ground_fix_resp_uncertainty_int, - _ground_fix_resp_uncertainty_float, - } _ground_fix_resp_uncertainty_choice; - struct zcbor_string _ground_fix_resp_fulfilledWith; + ground_fix_resp_uncertainty_int_c, + ground_fix_resp_uncertainty_float_c, + } ground_fix_resp_uncertainty_choice; + struct zcbor_string ground_fix_resp_fulfilledWith; }; #ifdef __cplusplus diff --git a/subsys/net/lib/nrf_cloud/coap/include/ground_fix_encode.h b/subsys/net/lib/nrf_cloud/coap/include/ground_fix_encode.h index a2bc1177ae7f..f4aa276e4c28 100644 --- a/subsys/net/lib/nrf_cloud/coap/include/ground_fix_encode.h +++ b/subsys/net/lib/nrf_cloud/coap/include/ground_fix_encode.h @@ -1,8 +1,8 @@ /* - * Copyright (c) 2023 Nordic Semiconductor ASA + * Copyright (c) 2024 Nordic Semiconductor ASA * SPDX-License-Identifier: LicenseRef-Nordic-5-Clause * - * Generated using zcbor version 0.7.0 + * Generated using zcbor version 0.8.1 * https://github.com/NordicSemiconductor/zcbor * Generated with a --default-max-qty of 10 */ diff --git a/subsys/net/lib/nrf_cloud/coap/include/ground_fix_encode_types.h b/subsys/net/lib/nrf_cloud/coap/include/ground_fix_encode_types.h index 2447f06da2a3..41d9c769265b 100644 --- a/subsys/net/lib/nrf_cloud/coap/include/ground_fix_encode_types.h +++ b/subsys/net/lib/nrf_cloud/coap/include/ground_fix_encode_types.h @@ -1,8 +1,8 @@ /* - * Copyright (c) 2023 Nordic Semiconductor ASA + * Copyright (c) 2024 Nordic Semiconductor ASA * SPDX-License-Identifier: LicenseRef-Nordic-5-Clause * - * Generated using zcbor version 0.7.0 + * Generated using zcbor version 0.8.1 * https://github.com/NordicSemiconductor/zcbor * Generated with a --default-max-qty of 10 */ @@ -29,137 +29,137 @@ extern "C" { #define DEFAULT_MAX_QTY 10 struct cell_earfcn { - uint32_t _cell_earfcn; + uint32_t cell_earfcn; }; struct cell_adv { - uint32_t _cell_adv; + uint32_t cell_adv; }; struct ncell_rsrp { - int32_t _ncell_rsrp; + int32_t ncell_rsrp; }; -struct ncell_rsrq_ { +struct ncell_rsrq_r { union { - float _ncell_rsrq_float32; - int32_t _ncell_rsrq_int; + float ncell_rsrq_float32; + int32_t ncell_rsrq_int; }; enum { - _ncell_rsrq_float32, - _ncell_rsrq_int, - } _ncell_rsrq_choice; + ncell_rsrq_float32_c, + ncell_rsrq_int_c, + } ncell_rsrq_choice; }; struct ncell_timeDiff { - int32_t _ncell_timeDiff; + int32_t ncell_timeDiff; }; struct ncell { - uint32_t _ncell_earfcn; - uint32_t _ncell_pci; - struct ncell_rsrp _ncell_rsrp; - bool _ncell_rsrp_present; - struct ncell_rsrq_ _ncell_rsrq; - bool _ncell_rsrq_present; - struct ncell_timeDiff _ncell_timeDiff; - bool _ncell_timeDiff_present; + uint32_t ncell_earfcn; + uint32_t ncell_pci; + struct ncell_rsrp ncell_rsrp; + bool ncell_rsrp_present; + struct ncell_rsrq_r ncell_rsrq; + bool ncell_rsrq_present; + struct ncell_timeDiff ncell_timeDiff; + bool ncell_timeDiff_present; }; -struct cell_nmr_ { - struct ncell _cell_nmr_ncells[5]; - size_t _cell_nmr_ncells_count; +struct cell_nmr_r { + struct ncell cell_nmr_ncells[5]; + size_t cell_nmr_ncells_count; }; struct cell_rsrp { - int32_t _cell_rsrp; + int32_t cell_rsrp; }; -struct cell_rsrq_ { +struct cell_rsrq_r { union { - float _cell_rsrq_float32; - int32_t _cell_rsrq_int; + float cell_rsrq_float32; + int32_t cell_rsrq_int; }; enum { - _cell_rsrq_float32, - _cell_rsrq_int, - } _cell_rsrq_choice; + cell_rsrq_float32_c, + cell_rsrq_int_c, + } cell_rsrq_choice; }; struct cell { - uint32_t _cell_mcc; - uint32_t _cell_mnc; - uint32_t _cell_eci; - uint32_t _cell_tac; - struct cell_earfcn _cell_earfcn; - bool _cell_earfcn_present; - struct cell_adv _cell_adv; - bool _cell_adv_present; - struct cell_nmr_ _cell_nmr; - bool _cell_nmr_present; - struct cell_rsrp _cell_rsrp; - bool _cell_rsrp_present; - struct cell_rsrq_ _cell_rsrq; - bool _cell_rsrq_present; + uint32_t cell_mcc; + uint32_t cell_mnc; + uint32_t cell_eci; + uint32_t cell_tac; + struct cell_earfcn cell_earfcn; + bool cell_earfcn_present; + struct cell_adv cell_adv; + bool cell_adv_present; + struct cell_nmr_r cell_nmr; + bool cell_nmr_present; + struct cell_rsrp cell_rsrp; + bool cell_rsrp_present; + struct cell_rsrq_r cell_rsrq; + bool cell_rsrq_present; }; struct lte_ar { - struct cell _lte_ar__cell[5]; - size_t _lte_ar__cell_count; + struct cell lte_ar_cell_m[5]; + size_t lte_ar_cell_m_count; }; struct ground_fix_req_lte { - struct lte_ar _ground_fix_req_lte; + struct lte_ar ground_fix_req_lte; }; struct ap_age { - uint32_t _ap_age; + uint32_t ap_age; }; struct ap_signalStrength { - int32_t _ap_signalStrength; + int32_t ap_signalStrength; }; struct ap_channel { - uint32_t _ap_channel; + uint32_t ap_channel; }; struct ap_frequency { - uint32_t _ap_frequency; + uint32_t ap_frequency; }; struct ap_ssid { - struct zcbor_string _ap_ssid; + struct zcbor_string ap_ssid; }; struct ap { - struct zcbor_string _ap_macAddress; - struct ap_age _ap_age; - bool _ap_age_present; - struct ap_signalStrength _ap_signalStrength; - bool _ap_signalStrength_present; - struct ap_channel _ap_channel; - bool _ap_channel_present; - struct ap_frequency _ap_frequency; - bool _ap_frequency_present; - struct ap_ssid _ap_ssid; - bool _ap_ssid_present; + struct zcbor_string ap_macAddress; + struct ap_age ap_age; + bool ap_age_present; + struct ap_signalStrength ap_signalStrength; + bool ap_signalStrength_present; + struct ap_channel ap_channel; + bool ap_channel_present; + struct ap_frequency ap_frequency; + bool ap_frequency_present; + struct ap_ssid ap_ssid; + bool ap_ssid_present; }; struct wifi_ob { - struct ap _wifi_ob_accessPoints__ap[20]; - size_t _wifi_ob_accessPoints__ap_count; + struct ap wifi_ob_accessPoints_ap_m[20]; + size_t wifi_ob_accessPoints_ap_m_count; }; struct ground_fix_req_wifi { - struct wifi_ob _ground_fix_req_wifi; + struct wifi_ob ground_fix_req_wifi; }; struct ground_fix_req { - struct ground_fix_req_lte _ground_fix_req_lte; - bool _ground_fix_req_lte_present; - struct ground_fix_req_wifi _ground_fix_req_wifi; - bool _ground_fix_req_wifi_present; + struct ground_fix_req_lte ground_fix_req_lte; + bool ground_fix_req_lte_present; + struct ground_fix_req_wifi ground_fix_req_wifi; + bool ground_fix_req_wifi_present; }; #ifdef __cplusplus diff --git a/subsys/net/lib/nrf_cloud/coap/include/msg_encode.h b/subsys/net/lib/nrf_cloud/coap/include/msg_encode.h index 61dd0e638abc..079a808515c5 100644 --- a/subsys/net/lib/nrf_cloud/coap/include/msg_encode.h +++ b/subsys/net/lib/nrf_cloud/coap/include/msg_encode.h @@ -1,8 +1,8 @@ /* - * Copyright (c) 2023 Nordic Semiconductor ASA + * Copyright (c) 2024 Nordic Semiconductor ASA * SPDX-License-Identifier: LicenseRef-Nordic-5-Clause * - * Generated using zcbor version 0.7.0 + * Generated using zcbor version 0.8.1 * https://github.com/NordicSemiconductor/zcbor * Generated with a --default-max-qty of 10 */ diff --git a/subsys/net/lib/nrf_cloud/coap/include/msg_encode_types.h b/subsys/net/lib/nrf_cloud/coap/include/msg_encode_types.h index 6cf6a97b9463..7a561ae5808a 100644 --- a/subsys/net/lib/nrf_cloud/coap/include/msg_encode_types.h +++ b/subsys/net/lib/nrf_cloud/coap/include/msg_encode_types.h @@ -1,8 +1,8 @@ /* - * Copyright (c) 2023 Nordic Semiconductor ASA + * Copyright (c) 2024 Nordic Semiconductor ASA * SPDX-License-Identifier: LicenseRef-Nordic-5-Clause * - * Generated using zcbor version 0.7.0 + * Generated using zcbor version 0.8.1 * https://github.com/NordicSemiconductor/zcbor * Generated with a --default-max-qty of 10 */ @@ -29,49 +29,49 @@ extern "C" { #define DEFAULT_MAX_QTY 10 struct pvt_spd { - double _pvt_spd; + double pvt_spd; }; struct pvt_hdg { - double _pvt_hdg; + double pvt_hdg; }; struct pvt_alt { - double _pvt_alt; + double pvt_alt; }; struct pvt { - double _pvt_lat; - double _pvt_lng; - double _pvt_acc; - struct pvt_spd _pvt_spd; - bool _pvt_spd_present; - struct pvt_hdg _pvt_hdg; - bool _pvt_hdg_present; - struct pvt_alt _pvt_alt; - bool _pvt_alt_present; + double pvt_lat; + double pvt_lng; + double pvt_acc; + struct pvt_spd pvt_spd; + bool pvt_spd_present; + struct pvt_hdg pvt_hdg; + bool pvt_hdg_present; + struct pvt_alt pvt_alt; + bool pvt_alt_present; }; struct message_out_ts { - uint64_t _message_out_ts; + uint64_t message_out_ts; }; struct message_out { - struct zcbor_string _message_out_appId; + struct zcbor_string message_out_appId; union { - struct zcbor_string _message_out_data_tstr; - double _message_out_data_float; - int32_t _message_out_data_int; - struct pvt _message_out_data__pvt; + struct zcbor_string message_out_data_tstr; + double message_out_data_float; + int32_t message_out_data_int; + struct pvt message_out_data_pvt_m; }; enum { - _message_out_data_tstr, - _message_out_data_float, - _message_out_data_int, - _message_out_data__pvt, - } _message_out_data_choice; - struct message_out_ts _message_out_ts; - bool _message_out_ts_present; + message_out_data_tstr_c, + message_out_data_float_c, + message_out_data_int_c, + message_out_data_pvt_m_c, + } message_out_data_choice; + struct message_out_ts message_out_ts; + bool message_out_ts_present; }; #ifdef __cplusplus diff --git a/subsys/net/lib/nrf_cloud/coap/include/pgps_decode.h b/subsys/net/lib/nrf_cloud/coap/include/pgps_decode.h index 1aa72f74e090..42fe1bb487d2 100644 --- a/subsys/net/lib/nrf_cloud/coap/include/pgps_decode.h +++ b/subsys/net/lib/nrf_cloud/coap/include/pgps_decode.h @@ -1,8 +1,8 @@ /* - * Copyright (c) 2023 Nordic Semiconductor ASA + * Copyright (c) 2024 Nordic Semiconductor ASA * SPDX-License-Identifier: LicenseRef-Nordic-5-Clause * - * Generated using zcbor version 0.7.0 + * Generated using zcbor version 0.8.1 * https://github.com/NordicSemiconductor/zcbor * Generated with a --default-max-qty of 10 */ diff --git a/subsys/net/lib/nrf_cloud/coap/include/pgps_decode_types.h b/subsys/net/lib/nrf_cloud/coap/include/pgps_decode_types.h index f0c534c86dd0..36be6b751bd7 100644 --- a/subsys/net/lib/nrf_cloud/coap/include/pgps_decode_types.h +++ b/subsys/net/lib/nrf_cloud/coap/include/pgps_decode_types.h @@ -1,8 +1,8 @@ /* - * Copyright (c) 2023 Nordic Semiconductor ASA + * Copyright (c) 2024 Nordic Semiconductor ASA * SPDX-License-Identifier: LicenseRef-Nordic-5-Clause * - * Generated using zcbor version 0.7.0 + * Generated using zcbor version 0.8.1 * https://github.com/NordicSemiconductor/zcbor * Generated with a --default-max-qty of 10 */ @@ -29,8 +29,8 @@ extern "C" { #define DEFAULT_MAX_QTY 10 struct pgps_resp { - struct zcbor_string _pgps_resp_host; - struct zcbor_string _pgps_resp_path; + struct zcbor_string pgps_resp_host; + struct zcbor_string pgps_resp_path; }; #ifdef __cplusplus diff --git a/subsys/net/lib/nrf_cloud/coap/include/pgps_encode.h b/subsys/net/lib/nrf_cloud/coap/include/pgps_encode.h index 9bf71e6d5c21..3d5022979038 100644 --- a/subsys/net/lib/nrf_cloud/coap/include/pgps_encode.h +++ b/subsys/net/lib/nrf_cloud/coap/include/pgps_encode.h @@ -1,8 +1,8 @@ /* - * Copyright (c) 2023 Nordic Semiconductor ASA + * Copyright (c) 2024 Nordic Semiconductor ASA * SPDX-License-Identifier: LicenseRef-Nordic-5-Clause * - * Generated using zcbor version 0.7.0 + * Generated using zcbor version 0.8.1 * https://github.com/NordicSemiconductor/zcbor * Generated with a --default-max-qty of 10 */ diff --git a/subsys/net/lib/nrf_cloud/coap/include/pgps_encode_types.h b/subsys/net/lib/nrf_cloud/coap/include/pgps_encode_types.h index 0bf684bb32ea..42d14fe1248b 100644 --- a/subsys/net/lib/nrf_cloud/coap/include/pgps_encode_types.h +++ b/subsys/net/lib/nrf_cloud/coap/include/pgps_encode_types.h @@ -1,8 +1,8 @@ /* - * Copyright (c) 2023 Nordic Semiconductor ASA + * Copyright (c) 2024 Nordic Semiconductor ASA * SPDX-License-Identifier: LicenseRef-Nordic-5-Clause * - * Generated using zcbor version 0.7.0 + * Generated using zcbor version 0.8.1 * https://github.com/NordicSemiconductor/zcbor * Generated with a --default-max-qty of 10 */ @@ -28,10 +28,10 @@ extern "C" { #define DEFAULT_MAX_QTY 10 struct pgps_req { - uint32_t _pgps_req_predictionCount; - uint32_t _pgps_req_predictionIntervalMinutes; - uint32_t _pgps_req_startGPSDay; - uint32_t _pgps_req_startGPSTimeOfDaySeconds; + uint32_t pgps_req_predictionCount; + uint32_t pgps_req_predictionIntervalMinutes; + uint32_t pgps_req_startGPSDay; + uint32_t pgps_req_startGPSTimeOfDaySeconds; }; #ifdef __cplusplus diff --git a/subsys/net/lib/nrf_cloud/coap/src/agnss_encode.c b/subsys/net/lib/nrf_cloud/coap/src/agnss_encode.c index 48e9fefe1edb..84d36b58c96b 100644 --- a/subsys/net/lib/nrf_cloud/coap/src/agnss_encode.c +++ b/subsys/net/lib/nrf_cloud/coap/src/agnss_encode.c @@ -1,8 +1,8 @@ /* - * Copyright (c) 2023 Nordic Semiconductor ASA + * Copyright (c) 2024 Nordic Semiconductor ASA * SPDX-License-Identifier: LicenseRef-Nordic-5-Clause * - * Generated using zcbor version 0.7.0 + * Generated using zcbor version 0.8.1 * https://github.com/NordicSemiconductor/zcbor * Generated with a --default-max-qty of 10 */ @@ -13,13 +13,14 @@ #include #include "zcbor_encode.h" #include "agnss_encode.h" +#include "zcbor_print.h" #if DEFAULT_MAX_QTY != 10 #error "The type file was generated with a different default_max_qty than this file" #endif static bool encode_repeated_agnss_req_types(zcbor_state_t *state, - const struct agnss_req_types_ *input); + const struct agnss_req_types_r *input); static bool encode_repeated_agnss_req_filtered(zcbor_state_t *state, const struct agnss_req_filtered *input); static bool encode_repeated_agnss_req_mask(zcbor_state_t *state, @@ -29,21 +30,24 @@ static bool encode_repeated_agnss_req_rsrp(zcbor_state_t *state, static bool encode_agnss_req(zcbor_state_t *state, const struct agnss_req *input); static bool encode_repeated_agnss_req_types(zcbor_state_t *state, - const struct agnss_req_types_ *input) + const struct agnss_req_types_r *input) { - zcbor_print("%s\r\n", __func__); + zcbor_log("%s\r\n", __func__); - bool tmp_result = (( - ((zcbor_uint32_put(state, (1)))) && - (zcbor_list_start_encode(state, 13) && - ((zcbor_multi_encode_minmax(1, 13, &(*input)._agnss_req_types_int_count, - (zcbor_encoder_t *)zcbor_int32_encode, state, - (&(*input)._agnss_req_types_int), sizeof(int32_t))) || - (zcbor_list_map_end_force_encode(state), false)) && - zcbor_list_end_encode(state, 13)))); + bool tmp_result = + ((((zcbor_uint32_put(state, (1)))) && + (zcbor_list_start_encode(state, 13) && + ((zcbor_multi_encode_minmax(1, 13, &(*input).agnss_req_types_int_count, + (zcbor_encoder_t *)zcbor_int32_encode, state, + (&(*input).agnss_req_types_int), sizeof(int32_t))) || + (zcbor_list_map_end_force_encode(state), false)) && + zcbor_list_end_encode(state, 13)))); if (!tmp_result) { - zcbor_trace(); + zcbor_trace_file(state); + zcbor_log("%s error: %s\r\n", __func__, zcbor_error_str(zcbor_peek_error(state))); + } else { + zcbor_log("%s success\r\n", __func__); } return tmp_result; @@ -52,13 +56,16 @@ static bool encode_repeated_agnss_req_types(zcbor_state_t *state, static bool encode_repeated_agnss_req_filtered(zcbor_state_t *state, const struct agnss_req_filtered *input) { - zcbor_print("%s\r\n", __func__); + zcbor_log("%s\r\n", __func__); bool tmp_result = ((((zcbor_uint32_put(state, (3)))) && - (zcbor_bool_encode(state, (&(*input)._agnss_req_filtered))))); + (zcbor_bool_encode(state, (&(*input).agnss_req_filtered))))); if (!tmp_result) { - zcbor_trace(); + zcbor_trace_file(state); + zcbor_log("%s error: %s\r\n", __func__, zcbor_error_str(zcbor_peek_error(state))); + } else { + zcbor_log("%s success\r\n", __func__); } return tmp_result; @@ -66,13 +73,16 @@ static bool encode_repeated_agnss_req_filtered(zcbor_state_t *state, static bool encode_repeated_agnss_req_mask(zcbor_state_t *state, const struct agnss_req_mask *input) { - zcbor_print("%s\r\n", __func__); + zcbor_log("%s\r\n", __func__); bool tmp_result = ((((zcbor_uint32_put(state, (4)))) && - (zcbor_uint32_encode(state, (&(*input)._agnss_req_mask))))); + (zcbor_uint32_encode(state, (&(*input).agnss_req_mask))))); if (!tmp_result) { - zcbor_trace(); + zcbor_trace_file(state); + zcbor_log("%s error: %s\r\n", __func__, zcbor_error_str(zcbor_peek_error(state))); + } else { + zcbor_log("%s success\r\n", __func__); } return tmp_result; @@ -80,13 +90,16 @@ static bool encode_repeated_agnss_req_mask(zcbor_state_t *state, const struct ag static bool encode_repeated_agnss_req_rsrp(zcbor_state_t *state, const struct agnss_req_rsrp *input) { - zcbor_print("%s\r\n", __func__); + zcbor_log("%s\r\n", __func__); bool tmp_result = ((((zcbor_uint32_put(state, (7)))) && - (zcbor_int32_encode(state, (&(*input)._agnss_req_rsrp))))); + (zcbor_int32_encode(state, (&(*input).agnss_req_rsrp))))); if (!tmp_result) { - zcbor_trace(); + zcbor_trace_file(state); + zcbor_log("%s error: %s\r\n", __func__, zcbor_error_str(zcbor_peek_error(state))); + } else { + zcbor_log("%s success\r\n", __func__); } return tmp_result; @@ -94,35 +107,34 @@ static bool encode_repeated_agnss_req_rsrp(zcbor_state_t *state, const struct ag static bool encode_agnss_req(zcbor_state_t *state, const struct agnss_req *input) { - zcbor_print("%s\r\n", __func__); + zcbor_log("%s\r\n", __func__); bool tmp_result = (((zcbor_map_start_encode(state, 8) && - ((zcbor_present_encode(&((*input)._agnss_req_types_present), - (zcbor_encoder_t *)encode_repeated_agnss_req_types, state, - (&(*input)._agnss_req_types)) && + (((!(*input).agnss_req_types_present || + encode_repeated_agnss_req_types(state, (&(*input).agnss_req_types))) && (((zcbor_uint32_put(state, (2)))) && - (zcbor_uint32_encode(state, (&(*input)._agnss_req_eci)))) && - zcbor_present_encode(&((*input)._agnss_req_filtered_present), - (zcbor_encoder_t *)encode_repeated_agnss_req_filtered, - state, (&(*input)._agnss_req_filtered)) && - zcbor_present_encode(&((*input)._agnss_req_mask_present), - (zcbor_encoder_t *)encode_repeated_agnss_req_mask, state, - (&(*input)._agnss_req_mask)) && + (zcbor_uint32_encode(state, (&(*input).agnss_req_eci)))) && + (!(*input).agnss_req_filtered_present || + encode_repeated_agnss_req_filtered(state, (&(*input).agnss_req_filtered))) && + (!(*input).agnss_req_mask_present || + encode_repeated_agnss_req_mask(state, (&(*input).agnss_req_mask))) && (((zcbor_uint32_put(state, (5)))) && - (zcbor_uint32_encode(state, (&(*input)._agnss_req_mcc)))) && + (zcbor_uint32_encode(state, (&(*input).agnss_req_mcc)))) && (((zcbor_uint32_put(state, (6)))) && - (zcbor_uint32_encode(state, (&(*input)._agnss_req_mnc)))) && - zcbor_present_encode(&((*input)._agnss_req_rsrp_present), - (zcbor_encoder_t *)encode_repeated_agnss_req_rsrp, state, - (&(*input)._agnss_req_rsrp)) && + (zcbor_uint32_encode(state, (&(*input).agnss_req_mnc)))) && + (!(*input).agnss_req_rsrp_present || + encode_repeated_agnss_req_rsrp(state, (&(*input).agnss_req_rsrp))) && (((zcbor_uint32_put(state, (8)))) && - (zcbor_uint32_encode(state, (&(*input)._agnss_req_tac))))) || + (zcbor_uint32_encode(state, (&(*input).agnss_req_tac))))) || (zcbor_list_map_end_force_encode(state), false)) && zcbor_map_end_encode(state, 8)))); if (!tmp_result) { - zcbor_trace(); + zcbor_trace_file(state); + zcbor_log("%s error: %s\r\n", __func__, zcbor_error_str(zcbor_peek_error(state))); + } else { + zcbor_log("%s success\r\n", __func__); } return tmp_result; @@ -133,19 +145,7 @@ int cbor_encode_agnss_req(uint8_t *payload, size_t payload_len, const struct agn { zcbor_state_t states[4]; - zcbor_new_state(states, sizeof(states) / sizeof(zcbor_state_t), payload, payload_len, 1); - - bool ret = encode_agnss_req(states, input); - - if (ret && (payload_len_out != NULL)) { - *payload_len_out = MIN(payload_len, (size_t)states[0].payload - (size_t)payload); - } - - if (!ret) { - int err = zcbor_pop_error(states); - - zcbor_print("Return error: %d\r\n", err); - return (err == ZCBOR_SUCCESS) ? ZCBOR_ERR_UNKNOWN : err; - } - return ZCBOR_SUCCESS; + return zcbor_entry_function(payload, payload_len, (void *)input, payload_len_out, states, + (zcbor_decoder_t *)encode_agnss_req, + sizeof(states) / sizeof(zcbor_state_t), 1); } diff --git a/subsys/net/lib/nrf_cloud/coap/src/coap_codec.c b/subsys/net/lib/nrf_cloud/coap/src/coap_codec.c index b748be2dc44e..d1351affea4f 100644 --- a/subsys/net/lib/nrf_cloud/coap/src/coap_codec.c +++ b/subsys/net/lib/nrf_cloud/coap/src/coap_codec.c @@ -47,47 +47,47 @@ static int encode_message(struct nrf_cloud_obj_coap_cbor *msg, uint8_t *buf, siz size_t out_len; memset(&input, 0, sizeof(struct message_out)); - input._message_out_appId.value = msg->app_id; - input._message_out_appId.len = strlen(msg->app_id); + input.message_out_appId.value = msg->app_id; + input.message_out_appId.len = strlen(msg->app_id); switch (msg->type) { case NRF_CLOUD_DATA_TYPE_NONE: LOG_ERR("Cannot encode unknown type."); return -EINVAL; case NRF_CLOUD_DATA_TYPE_STR: - input._message_out_data_choice = _message_out_data_tstr; - input._message_out_data_tstr.value = msg->str_val; - input._message_out_data_tstr.len = strlen(msg->str_val); + input.message_out_data_choice = message_out_data_tstr_c; + input.message_out_data_tstr.value = msg->str_val; + input.message_out_data_tstr.len = strlen(msg->str_val); break; case NRF_CLOUD_DATA_TYPE_PVT: - input._message_out_data_choice = _message_out_data__pvt; - input._message_out_data__pvt._pvt_lat = msg->pvt->lat; - input._message_out_data__pvt._pvt_lng = msg->pvt->lon; - input._message_out_data__pvt._pvt_acc = msg->pvt->accuracy; + input.message_out_data_choice = message_out_data_pvt_m_c; + input.message_out_data_pvt_m.pvt_lat = msg->pvt->lat; + input.message_out_data_pvt_m.pvt_lng = msg->pvt->lon; + input.message_out_data_pvt_m.pvt_acc = msg->pvt->accuracy; if (msg->pvt->has_speed) { - input._message_out_data__pvt._pvt_spd._pvt_spd = msg->pvt->speed; - input._message_out_data__pvt._pvt_spd_present = true; + input.message_out_data_pvt_m.pvt_spd.pvt_spd = msg->pvt->speed; + input.message_out_data_pvt_m.pvt_spd_present = true; } if (msg->pvt->has_heading) { - input._message_out_data__pvt._pvt_hdg._pvt_hdg = msg->pvt->heading; - input._message_out_data__pvt._pvt_hdg_present = true; + input.message_out_data_pvt_m.pvt_hdg.pvt_hdg = msg->pvt->heading; + input.message_out_data_pvt_m.pvt_hdg_present = true; } if (msg->pvt->has_alt) { - input._message_out_data__pvt._pvt_alt._pvt_alt = msg->pvt->alt; - input._message_out_data__pvt._pvt_alt_present = true; + input.message_out_data_pvt_m.pvt_alt.pvt_alt = msg->pvt->alt; + input.message_out_data_pvt_m.pvt_alt_present = true; } break; case NRF_CLOUD_DATA_TYPE_INT: - input._message_out_data_choice = _message_out_data_int; - input._message_out_data_int = msg->int_val; + input.message_out_data_choice = message_out_data_int_c; + input.message_out_data_int = msg->int_val; break; case NRF_CLOUD_DATA_TYPE_DOUBLE: - input._message_out_data_choice = _message_out_data_float; - input._message_out_data_float = msg->double_val; + input.message_out_data_choice = message_out_data_float_c; + input.message_out_data_float = msg->double_val; break; } - input._message_out_ts._message_out_ts = msg->ts; - input._message_out_ts_present = true; + input.message_out_ts.message_out_ts = msg->ts; + input.message_out_ts_present = true; err = cbor_encode_message_out(buf, *len, &input, &out_len); if (err) { LOG_ERR("Error %d encoding message", err); @@ -167,48 +167,48 @@ int coap_codec_pvt_encode(const char *app_id, const struct nrf_cloud_gnss_pvt *p static void copy_cell(struct cell *dst, struct lte_lc_cell const *const src) { - dst->_cell_mcc = src->mcc; - dst->_cell_mnc = src->mnc; - dst->_cell_eci = src->id; - dst->_cell_tac = src->tac; + dst->cell_mcc = src->mcc; + dst->cell_mnc = src->mnc; + dst->cell_eci = src->id; + dst->cell_tac = src->tac; - dst->_cell_earfcn._cell_earfcn = src->earfcn; - dst->_cell_earfcn_present = (src->earfcn != NRF_CLOUD_LOCATION_CELL_OMIT_EARFCN); + dst->cell_earfcn.cell_earfcn = src->earfcn; + dst->cell_earfcn_present = (src->earfcn != NRF_CLOUD_LOCATION_CELL_OMIT_EARFCN); - dst->_cell_adv._cell_adv = MIN(src->timing_advance, NRF_CLOUD_LOCATION_CELL_TIME_ADV_MAX); - dst->_cell_adv_present = (src->timing_advance != NRF_CLOUD_LOCATION_CELL_OMIT_TIME_ADV); + dst->cell_adv.cell_adv = MIN(src->timing_advance, NRF_CLOUD_LOCATION_CELL_TIME_ADV_MAX); + dst->cell_adv_present = (src->timing_advance != NRF_CLOUD_LOCATION_CELL_OMIT_TIME_ADV); - dst->_cell_rsrp._cell_rsrp = RSRP_IDX_TO_DBM(src->rsrp); - dst->_cell_rsrp_present = (src->rsrp != NRF_CLOUD_LOCATION_CELL_OMIT_RSRP); + dst->cell_rsrp.cell_rsrp = RSRP_IDX_TO_DBM(src->rsrp); + dst->cell_rsrp_present = (src->rsrp != NRF_CLOUD_LOCATION_CELL_OMIT_RSRP); - dst->_cell_rsrq._cell_rsrq_float32 = RSRQ_IDX_TO_DB(src->rsrq); - dst->_cell_rsrq._cell_rsrq_choice = _cell_rsrq_float32; - dst->_cell_rsrq_present = (src->rsrq != NRF_CLOUD_LOCATION_CELL_OMIT_RSRQ); + dst->cell_rsrq.cell_rsrq_float32 = RSRQ_IDX_TO_DB(src->rsrq); + dst->cell_rsrq.cell_rsrq_choice = cell_rsrq_float32_c; + dst->cell_rsrq_present = (src->rsrq != NRF_CLOUD_LOCATION_CELL_OMIT_RSRQ); } static void copy_ncells(struct ncell *dst, int num, struct lte_lc_ncell *src) { for (int i = 0; i < num; i++) { - dst->_ncell_earfcn = src->earfcn; - dst->_ncell_pci = src->phys_cell_id; + dst->ncell_earfcn = src->earfcn; + dst->ncell_pci = src->phys_cell_id; if (src->rsrp != NRF_CLOUD_LOCATION_CELL_OMIT_RSRP) { - dst->_ncell_rsrp._ncell_rsrp = RSRP_IDX_TO_DBM(src->rsrp); - dst->_ncell_rsrp_present = true; + dst->ncell_rsrp.ncell_rsrp = RSRP_IDX_TO_DBM(src->rsrp); + dst->ncell_rsrp_present = true; } else { - dst->_ncell_rsrp_present = false; + dst->ncell_rsrp_present = false; } if (src->rsrq != NRF_CLOUD_LOCATION_CELL_OMIT_RSRQ) { - dst->_ncell_rsrq._ncell_rsrq_float32 = RSRQ_IDX_TO_DB(src->rsrq); - dst->_ncell_rsrq._ncell_rsrq_choice = _ncell_rsrq_float32; - dst->_ncell_rsrq_present = true; + dst->ncell_rsrq.ncell_rsrq_float32 = RSRQ_IDX_TO_DB(src->rsrq); + dst->ncell_rsrq.ncell_rsrq_choice = ncell_rsrq_float32_c; + dst->ncell_rsrq_present = true; } else { - dst->_ncell_rsrq_present = false; + dst->ncell_rsrq_present = false; } if (src->time_diff != LTE_LC_CELL_TIME_DIFF_INVALID) { - dst->_ncell_timeDiff._ncell_timeDiff = src->time_diff; - dst->_ncell_timeDiff_present = true; + dst->ncell_timeDiff.ncell_timeDiff = src->time_diff; + dst->ncell_timeDiff_present = true; } else { - dst->_ncell_timeDiff_present = false; + dst->ncell_timeDiff_present = false; } src++; dst++; @@ -222,10 +222,10 @@ static void copy_cell_info(struct lte_ar *lte_encode, return; } - const size_t max_cells = ARRAY_SIZE(lte_encode->_lte_ar__cell); + const size_t max_cells = ARRAY_SIZE(lte_encode->lte_ar_cell_m); size_t cnt = 0; size_t nmrs; - struct cell *enc_cell = lte_encode->_lte_ar__cell; + struct cell *enc_cell = lte_encode->lte_ar_cell_m; if (cell_info->current_cell.id != LTE_LC_CELL_EUTRAN_ID_INVALID) { @@ -233,16 +233,16 @@ static void copy_cell_info(struct lte_ar *lte_encode, copy_cell(enc_cell, &cell_info->current_cell); /* Copy neighbor cell(s) */ - nmrs = MIN(ARRAY_SIZE(enc_cell->_cell_nmr._cell_nmr_ncells), + nmrs = MIN(ARRAY_SIZE(enc_cell->cell_nmr.cell_nmr_ncells), cell_info->ncells_count); if (nmrs) { - copy_ncells(enc_cell->_cell_nmr._cell_nmr_ncells, + copy_ncells(enc_cell->cell_nmr.cell_nmr_ncells, nmrs, cell_info->neighbor_cells); } - enc_cell->_cell_nmr._cell_nmr_ncells_count = nmrs; - enc_cell->_cell_nmr_present = (nmrs > 0); + enc_cell->cell_nmr.cell_nmr_ncells_count = nmrs; + enc_cell->cell_nmr_present = (nmrs > 0); LOG_DBG("Copied serving cell and %zd neighbor cells", nmrs); @@ -261,34 +261,34 @@ static void copy_cell_info(struct lte_ar *lte_encode, LOG_DBG("Copied %u GCI cells", cell_info->gci_cells_count); } - lte_encode->_lte_ar__cell_count = cnt; + lte_encode->lte_ar_cell_m_count = cnt; } static void copy_wifi_info(struct wifi_ob *wifi_encode, struct wifi_scan_info const *const wifi_info) { - struct ap *dst = wifi_encode->_wifi_ob_accessPoints__ap; + struct ap *dst = wifi_encode->wifi_ob_accessPoints_ap_m; struct wifi_scan_result *src = wifi_info->ap_info; - size_t num_aps = MIN(ARRAY_SIZE(wifi_encode->_wifi_ob_accessPoints__ap), wifi_info->cnt); + size_t num_aps = MIN(ARRAY_SIZE(wifi_encode->wifi_ob_accessPoints_ap_m), wifi_info->cnt); - wifi_encode->_wifi_ob_accessPoints__ap_count = num_aps; + wifi_encode->wifi_ob_accessPoints_ap_m_count = num_aps; for (int i = 0; i < num_aps; i++, src++, dst++) { - dst->_ap_macAddress.value = src->mac; - dst->_ap_macAddress.len = src->mac_length; - dst->_ap_age_present = false; + dst->ap_macAddress.value = src->mac; + dst->ap_macAddress.len = src->mac_length; + dst->ap_age_present = false; - dst->_ap_signalStrength._ap_signalStrength = src->rssi; - dst->_ap_signalStrength_present = (src->rssi != NRF_CLOUD_LOCATION_WIFI_OMIT_RSSI); + dst->ap_signalStrength.ap_signalStrength = src->rssi; + dst->ap_signalStrength_present = (src->rssi != NRF_CLOUD_LOCATION_WIFI_OMIT_RSSI); - dst->_ap_channel._ap_channel = src->channel; - dst->_ap_channel_present = (src->channel != NRF_CLOUD_LOCATION_WIFI_OMIT_CHAN); + dst->ap_channel.ap_channel = src->channel; + dst->ap_channel_present = (src->channel != NRF_CLOUD_LOCATION_WIFI_OMIT_CHAN); - dst->_ap_frequency_present = false; - dst->_ap_ssid_present = (IS_ENABLED(CONFIG_NRF_CLOUD_COAP_SEND_SSIDS) && + dst->ap_frequency_present = false; + dst->ap_ssid_present = (IS_ENABLED(CONFIG_NRF_CLOUD_COAP_SEND_SSIDS) && (src->ssid_length && src->ssid[0])); - dst->_ap_ssid._ap_ssid.value = src->ssid; - dst->_ap_ssid._ap_ssid.len = src->ssid_length; + dst->ap_ssid.ap_ssid.value = src->ssid; + dst->ap_ssid.ap_ssid.len = src->ssid_length; } } @@ -310,13 +310,13 @@ int coap_codec_ground_fix_req_encode(struct lte_lc_cells_info const *const cell_ size_t out_len; memset(&input, 0, sizeof(struct ground_fix_req)); - input._ground_fix_req_lte_present = (cell_info != NULL); + input.ground_fix_req_lte_present = (cell_info != NULL); if (cell_info) { - copy_cell_info(&input._ground_fix_req_lte._ground_fix_req_lte, cell_info); + copy_cell_info(&input.ground_fix_req_lte.ground_fix_req_lte, cell_info); } - input._ground_fix_req_wifi_present = (wifi_info != NULL); + input.ground_fix_req_wifi_present = (wifi_info != NULL); if (wifi_info) { - copy_wifi_info(&input._ground_fix_req_wifi._ground_fix_req_wifi, wifi_info); + copy_wifi_info(&input.ground_fix_req_wifi.ground_fix_req_wifi, wifi_info); } err = cbor_encode_ground_fix_req(buf, *len, &input, &out_len); if (err) { @@ -366,8 +366,8 @@ int coap_codec_ground_fix_resp_decode(struct nrf_cloud_location_result *result, return err; } - const char *with = res._ground_fix_resp_fulfilledWith.value; - int rlen = res._ground_fix_resp_fulfilledWith.len; + const char *with = res.ground_fix_resp_fulfilledWith.value; + int rlen = res.ground_fix_resp_fulfilledWith.len; if (strncmp(with, NRF_CLOUD_LOCATION_TYPE_VAL_MCELL, rlen) == 0) { result->type = LOCATION_TYPE_MULTI_CELL; @@ -380,13 +380,13 @@ int coap_codec_ground_fix_resp_decode(struct nrf_cloud_location_result *result, LOG_WRN("Unhandled location type: %*s", rlen, with); } - result->lat = res._ground_fix_resp_lat; - result->lon = res._ground_fix_resp_lon; + result->lat = res.ground_fix_resp_lat; + result->lon = res.ground_fix_resp_lon; - if (res._ground_fix_resp_uncertainty_choice == _ground_fix_resp_uncertainty_int) { - result->unc = res._ground_fix_resp_uncertainty_int; + if (res.ground_fix_resp_uncertainty_choice == ground_fix_resp_uncertainty_int_c) { + result->unc = res.ground_fix_resp_uncertainty_int; } else { - result->unc = (uint32_t)lround(res._ground_fix_resp_uncertainty_float); + result->unc = (uint32_t)lround(res.ground_fix_resp_uncertainty_float); } return err; } @@ -406,40 +406,40 @@ int coap_codec_agnss_encode(struct nrf_cloud_rest_agnss_request const *const req int ret; struct agnss_req input; - struct agnss_req_types_ *t = &input._agnss_req_types; + struct agnss_req_types_r *t = &input.agnss_req_types; size_t out_len; - enum nrf_cloud_agnss_type types[ARRAY_SIZE(t->_agnss_req_types_int)]; + enum nrf_cloud_agnss_type types[ARRAY_SIZE(t->agnss_req_types_int)]; int cnt; memset(&input, 0, sizeof(struct agnss_req)); - input._agnss_req_eci = request->net_info->current_cell.id; - input._agnss_req_mcc = request->net_info->current_cell.mcc; - input._agnss_req_mnc = request->net_info->current_cell.mnc; - input._agnss_req_tac = request->net_info->current_cell.tac; + input.agnss_req_eci = request->net_info->current_cell.id; + input.agnss_req_mcc = request->net_info->current_cell.mcc; + input.agnss_req_mnc = request->net_info->current_cell.mnc; + input.agnss_req_tac = request->net_info->current_cell.tac; if (request->type == NRF_CLOUD_REST_AGNSS_REQ_CUSTOM) { cnt = nrf_cloud_agnss_type_array_get(request->agnss_req, types, ARRAY_SIZE(types)); - t->_agnss_req_types_int_count = cnt; - input._agnss_req_types_present = true; + t->agnss_req_types_int_count = cnt; + input.agnss_req_types_present = true; LOG_DBG("num elements: %d", cnt); for (int i = 0; i < cnt; i++) { LOG_DBG(" %d: %d", i, types[i]); - t->_agnss_req_types_int[i] = (int)types[i]; + t->agnss_req_types_int[i] = (int)types[i]; } } else { LOG_ERR("Invalid request type: %d", request->type); return -ENOTSUP; } if (request->filtered) { - input._agnss_req_filtered_present = true; - input._agnss_req_filtered._agnss_req_filtered = true; + input.agnss_req_filtered_present = true; + input.agnss_req_filtered.agnss_req_filtered = true; if (request->mask_angle != DEFAULT_MASK_ANGLE) { - input._agnss_req_mask_present = true; - input._agnss_req_mask._agnss_req_mask = request->mask_angle; + input.agnss_req_mask_present = true; + input.agnss_req_mask.agnss_req_mask = request->mask_angle; } } if (request->net_info->current_cell.rsrp != NRF_CLOUD_LOCATION_CELL_OMIT_RSRP) { - input._agnss_req_rsrp._agnss_req_rsrp = request->net_info->current_cell.rsrp; - input._agnss_req_rsrp_present = true; + input.agnss_req_rsrp.agnss_req_rsrp = request->net_info->current_cell.rsrp; + input.agnss_req_rsrp_present = true; } ret = cbor_encode_agnss_req(buf, *len, &input, &out_len); if (ret) { @@ -511,10 +511,10 @@ int coap_codec_pgps_encode(struct nrf_cloud_rest_pgps_request const *const reque memset(&input, 0, sizeof(input)); - input._pgps_req_predictionCount = request->pgps_req->prediction_count; - input._pgps_req_predictionIntervalMinutes = request->pgps_req->prediction_period_min; - input._pgps_req_startGPSDay = request->pgps_req->gps_day; - input._pgps_req_startGPSTimeOfDaySeconds = request->pgps_req->gps_time_of_day; + input.pgps_req_predictionCount = request->pgps_req->prediction_count; + input.pgps_req_predictionIntervalMinutes = request->pgps_req->prediction_period_min; + input.pgps_req_startGPSDay = request->pgps_req->gps_day; + input.pgps_req_startGPSTimeOfDaySeconds = request->pgps_req->gps_time_of_day; ret = cbor_encode_pgps_req(buf, *len, &input, &out_len); if (ret) { @@ -558,16 +558,16 @@ int coap_codec_pgps_resp_decode(struct nrf_cloud_pgps_result *result, err = cbor_decode_pgps_resp(buf, len, &resp, &resp_len); if (!err) { - strncpy(result->host, resp._pgps_resp_host.value, result->host_sz); - if (result->host_sz > resp._pgps_resp_host.len) { - result->host[resp._pgps_resp_host.len] = '\0'; + strncpy(result->host, resp.pgps_resp_host.value, result->host_sz); + if (result->host_sz > resp.pgps_resp_host.len) { + result->host[resp.pgps_resp_host.len] = '\0'; } - result->host_sz = resp._pgps_resp_host.len; - strncpy(result->path, resp._pgps_resp_path.value, result->path_sz); - if (result->path_sz > resp._pgps_resp_path.len) { - result->path[resp._pgps_resp_path.len] = '\0'; + result->host_sz = resp.pgps_resp_host.len; + strncpy(result->path, resp.pgps_resp_path.value, result->path_sz); + if (result->path_sz > resp.pgps_resp_path.len) { + result->path[resp.pgps_resp_path.len] = '\0'; } - result->path_sz = resp._pgps_resp_path.len; + result->path_sz = resp.pgps_resp_path.len; } return err; } diff --git a/subsys/net/lib/nrf_cloud/coap/src/ground_fix_decode.c b/subsys/net/lib/nrf_cloud/coap/src/ground_fix_decode.c index 4f313a55efd1..4cfd5af20847 100644 --- a/subsys/net/lib/nrf_cloud/coap/src/ground_fix_decode.c +++ b/subsys/net/lib/nrf_cloud/coap/src/ground_fix_decode.c @@ -1,8 +1,8 @@ /* - * Copyright (c) 2023 Nordic Semiconductor ASA + * Copyright (c) 2024 Nordic Semiconductor ASA * SPDX-License-Identifier: LicenseRef-Nordic-5-Clause * - * Generated using zcbor version 0.7.0 + * Generated using zcbor version 0.8.1 * https://github.com/NordicSemiconductor/zcbor * Generated with a --default-max-qty of 10 */ @@ -13,6 +13,7 @@ #include #include "zcbor_decode.h" #include "ground_fix_decode.h" +#include "zcbor_print.h" #if DEFAULT_MAX_QTY != 10 #error "The type file was generated with a different default_max_qty than this file" @@ -22,36 +23,38 @@ static bool decode_ground_fix_resp(zcbor_state_t *state, struct ground_fix_resp static bool decode_ground_fix_resp(zcbor_state_t *state, struct ground_fix_resp *result) { - zcbor_print("%s\r\n", __func__); + zcbor_log("%s\r\n", __func__); bool int_res; - bool tmp_result = (( - (zcbor_map_start_decode(state) && - (((((zcbor_uint32_expect(state, (1)))) && - (zcbor_float64_decode(state, (&(*result)._ground_fix_resp_lat)))) && - (((zcbor_uint32_expect(state, (2)))) && - (zcbor_float64_decode(state, (&(*result)._ground_fix_resp_lon)))) && - (((zcbor_uint32_expect(state, (3)))) && - (zcbor_union_start_code(state) && - (int_res = - ((((zcbor_int32_decode( - state, (&(*result)._ground_fix_resp_uncertainty_int)))) && - (((*result)._ground_fix_resp_uncertainty_choice = - _ground_fix_resp_uncertainty_int), - true)) || - (((zcbor_float_decode( - state, (&(*result)._ground_fix_resp_uncertainty_float)))) && - (((*result)._ground_fix_resp_uncertainty_choice = - _ground_fix_resp_uncertainty_float), - true))), - zcbor_union_end_code(state), int_res))) && - (((zcbor_uint32_expect(state, (4)))) && - (zcbor_tstr_decode(state, (&(*result)._ground_fix_resp_fulfilledWith))))) || - (zcbor_list_map_end_force_decode(state), false)) && - zcbor_map_end_decode(state)))); + bool tmp_result = ((( + zcbor_map_start_decode(state) && + (((((zcbor_uint32_expect(state, (1)))) && + (zcbor_float64_decode(state, (&(*result).ground_fix_resp_lat)))) && + (((zcbor_uint32_expect(state, (2)))) && + (zcbor_float64_decode(state, (&(*result).ground_fix_resp_lon)))) && + (((zcbor_uint32_expect(state, (3)))) && + (zcbor_union_start_code(state) && + (int_res = ((((zcbor_int32_decode( + state, (&(*result).ground_fix_resp_uncertainty_int)))) && + (((*result).ground_fix_resp_uncertainty_choice = + ground_fix_resp_uncertainty_int_c), + true)) || + (((zcbor_float_decode( + state, (&(*result).ground_fix_resp_uncertainty_float)))) && + (((*result).ground_fix_resp_uncertainty_choice = + ground_fix_resp_uncertainty_float_c), + true))), + zcbor_union_end_code(state), int_res))) && + (((zcbor_uint32_expect(state, (4)))) && + (zcbor_tstr_decode(state, (&(*result).ground_fix_resp_fulfilledWith))))) || + (zcbor_list_map_end_force_decode(state), false)) && + zcbor_map_end_decode(state)))); if (!tmp_result) { - zcbor_trace(); + zcbor_trace_file(state); + zcbor_log("%s error: %s\r\n", __func__, zcbor_error_str(zcbor_peek_error(state))); + } else { + zcbor_log("%s success\r\n", __func__); } return tmp_result; @@ -62,19 +65,7 @@ int cbor_decode_ground_fix_resp(const uint8_t *payload, size_t payload_len, { zcbor_state_t states[4]; - zcbor_new_state(states, sizeof(states) / sizeof(zcbor_state_t), payload, payload_len, 1); - - bool ret = decode_ground_fix_resp(states, result); - - if (ret && (payload_len_out != NULL)) { - *payload_len_out = MIN(payload_len, (size_t)states[0].payload - (size_t)payload); - } - - if (!ret) { - int err = zcbor_pop_error(states); - - zcbor_print("Return error: %d\r\n", err); - return (err == ZCBOR_SUCCESS) ? ZCBOR_ERR_UNKNOWN : err; - } - return ZCBOR_SUCCESS; + return zcbor_entry_function(payload, payload_len, (void *)result, payload_len_out, states, + (zcbor_decoder_t *)decode_ground_fix_resp, + sizeof(states) / sizeof(zcbor_state_t), 1); } diff --git a/subsys/net/lib/nrf_cloud/coap/src/ground_fix_encode.c b/subsys/net/lib/nrf_cloud/coap/src/ground_fix_encode.c index af7e87abaa06..ca0665176edc 100644 --- a/subsys/net/lib/nrf_cloud/coap/src/ground_fix_encode.c +++ b/subsys/net/lib/nrf_cloud/coap/src/ground_fix_encode.c @@ -1,8 +1,8 @@ /* - * Copyright (c) 2023 Nordic Semiconductor ASA + * Copyright (c) 2024 Nordic Semiconductor ASA * SPDX-License-Identifier: LicenseRef-Nordic-5-Clause * - * Generated using zcbor version 0.7.0 + * Generated using zcbor version 0.8.1 * https://github.com/NordicSemiconductor/zcbor * Generated with a --default-max-qty of 10 */ @@ -13,6 +13,7 @@ #include #include "zcbor_encode.h" #include "ground_fix_encode.h" +#include "zcbor_print.h" #if DEFAULT_MAX_QTY != 10 #error "The type file was generated with a different default_max_qty than this file" @@ -21,13 +22,13 @@ static bool encode_repeated_cell_earfcn(zcbor_state_t *state, const struct cell_earfcn *input); static bool encode_repeated_cell_adv(zcbor_state_t *state, const struct cell_adv *input); static bool encode_repeated_ncell_rsrp(zcbor_state_t *state, const struct ncell_rsrp *input); -static bool encode_repeated_ncell_rsrq(zcbor_state_t *state, const struct ncell_rsrq_ *input); +static bool encode_repeated_ncell_rsrq(zcbor_state_t *state, const struct ncell_rsrq_r *input); static bool encode_repeated_ncell_timeDiff(zcbor_state_t *state, const struct ncell_timeDiff *input); static bool encode_ncell(zcbor_state_t *state, const struct ncell *input); -static bool encode_repeated_cell_nmr(zcbor_state_t *state, const struct cell_nmr_ *input); +static bool encode_repeated_cell_nmr(zcbor_state_t *state, const struct cell_nmr_r *input); static bool encode_repeated_cell_rsrp(zcbor_state_t *state, const struct cell_rsrp *input); -static bool encode_repeated_cell_rsrq(zcbor_state_t *state, const struct cell_rsrq_ *input); +static bool encode_repeated_cell_rsrq(zcbor_state_t *state, const struct cell_rsrq_r *input); static bool encode_cell(zcbor_state_t *state, const struct cell *input); static bool encode_lte_ar(zcbor_state_t *state, const struct lte_ar *input); static bool encode_repeated_ground_fix_req_lte(zcbor_state_t *state, @@ -46,13 +47,16 @@ static bool encode_ground_fix_req(zcbor_state_t *state, const struct ground_fix_ static bool encode_repeated_cell_earfcn(zcbor_state_t *state, const struct cell_earfcn *input) { - zcbor_print("%s\r\n", __func__); + zcbor_log("%s\r\n", __func__); bool tmp_result = ((((zcbor_uint32_put(state, (1)))) && - (zcbor_uint32_encode(state, (&(*input)._cell_earfcn))))); + (zcbor_uint32_encode(state, (&(*input).cell_earfcn))))); if (!tmp_result) { - zcbor_trace(); + zcbor_trace_file(state); + zcbor_log("%s error: %s\r\n", __func__, zcbor_error_str(zcbor_peek_error(state))); + } else { + zcbor_log("%s success\r\n", __func__); } return tmp_result; @@ -60,13 +64,16 @@ static bool encode_repeated_cell_earfcn(zcbor_state_t *state, const struct cell_ static bool encode_repeated_cell_adv(zcbor_state_t *state, const struct cell_adv *input) { - zcbor_print("%s\r\n", __func__); + zcbor_log("%s\r\n", __func__); bool tmp_result = ((((zcbor_uint32_put(state, (10)))) && - (zcbor_uint32_encode(state, (&(*input)._cell_adv))))); + (zcbor_uint32_encode(state, (&(*input).cell_adv))))); if (!tmp_result) { - zcbor_trace(); + zcbor_trace_file(state); + zcbor_log("%s error: %s\r\n", __func__, zcbor_error_str(zcbor_peek_error(state))); + } else { + zcbor_log("%s success\r\n", __func__); } return tmp_result; @@ -74,32 +81,38 @@ static bool encode_repeated_cell_adv(zcbor_state_t *state, const struct cell_adv static bool encode_repeated_ncell_rsrp(zcbor_state_t *state, const struct ncell_rsrp *input) { - zcbor_print("%s\r\n", __func__); + zcbor_log("%s\r\n", __func__); bool tmp_result = ((((zcbor_uint32_put(state, (3)))) && - (zcbor_int32_encode(state, (&(*input)._ncell_rsrp))))); + (zcbor_int32_encode(state, (&(*input).ncell_rsrp))))); if (!tmp_result) { - zcbor_trace(); + zcbor_trace_file(state); + zcbor_log("%s error: %s\r\n", __func__, zcbor_error_str(zcbor_peek_error(state))); + } else { + zcbor_log("%s success\r\n", __func__); } return tmp_result; } -static bool encode_repeated_ncell_rsrq(zcbor_state_t *state, const struct ncell_rsrq_ *input) +static bool encode_repeated_ncell_rsrq(zcbor_state_t *state, const struct ncell_rsrq_r *input) { - zcbor_print("%s\r\n", __func__); + zcbor_log("%s\r\n", __func__); bool tmp_result = ((((zcbor_uint32_put(state, (4)))) && - (((*input)._ncell_rsrq_choice == _ncell_rsrq_float32) - ? ((zcbor_float32_encode(state, (&(*input)._ncell_rsrq_float32)))) - : (((*input)._ncell_rsrq_choice == _ncell_rsrq_int) - ? ((zcbor_int32_encode(state, (&(*input)._ncell_rsrq_int)))) + (((*input).ncell_rsrq_choice == ncell_rsrq_float32_c) + ? ((zcbor_float32_encode(state, (&(*input).ncell_rsrq_float32)))) + : (((*input).ncell_rsrq_choice == ncell_rsrq_int_c) + ? ((zcbor_int32_encode(state, (&(*input).ncell_rsrq_int)))) : false)))); if (!tmp_result) { - zcbor_trace(); + zcbor_trace_file(state); + zcbor_log("%s error: %s\r\n", __func__, zcbor_error_str(zcbor_peek_error(state))); + } else { + zcbor_log("%s success\r\n", __func__); } return tmp_result; @@ -107,13 +120,16 @@ static bool encode_repeated_ncell_rsrq(zcbor_state_t *state, const struct ncell_ static bool encode_repeated_ncell_timeDiff(zcbor_state_t *state, const struct ncell_timeDiff *input) { - zcbor_print("%s\r\n", __func__); + zcbor_log("%s\r\n", __func__); bool tmp_result = ((((zcbor_uint32_put(state, (5)))) && - (zcbor_int32_encode(state, (&(*input)._ncell_timeDiff))))); + (zcbor_int32_encode(state, (&(*input).ncell_timeDiff))))); if (!tmp_result) { - zcbor_trace(); + zcbor_trace_file(state); + zcbor_log("%s error: %s\r\n", __func__, zcbor_error_str(zcbor_peek_error(state))); + } else { + zcbor_log("%s success\r\n", __func__); } return tmp_result; @@ -121,48 +137,51 @@ static bool encode_repeated_ncell_timeDiff(zcbor_state_t *state, const struct nc static bool encode_ncell(zcbor_state_t *state, const struct ncell *input) { - zcbor_print("%s\r\n", __func__); + zcbor_log("%s\r\n", __func__); bool tmp_result = (((zcbor_map_start_encode(state, 5) && (((((zcbor_uint32_put(state, (1)))) && - (zcbor_uint32_encode(state, (&(*input)._ncell_earfcn)))) && + (zcbor_uint32_encode(state, (&(*input).ncell_earfcn)))) && (((zcbor_uint32_put(state, (2)))) && - (zcbor_uint32_encode(state, (&(*input)._ncell_pci)))) && - zcbor_present_encode(&((*input)._ncell_rsrp_present), - (zcbor_encoder_t *)encode_repeated_ncell_rsrp, state, - (&(*input)._ncell_rsrp)) && - zcbor_present_encode(&((*input)._ncell_rsrq_present), - (zcbor_encoder_t *)encode_repeated_ncell_rsrq, state, - (&(*input)._ncell_rsrq)) && - zcbor_present_encode(&((*input)._ncell_timeDiff_present), - (zcbor_encoder_t *)encode_repeated_ncell_timeDiff, state, - (&(*input)._ncell_timeDiff))) || + (zcbor_uint32_encode(state, (&(*input).ncell_pci)))) && + (!(*input).ncell_rsrp_present || + encode_repeated_ncell_rsrp(state, (&(*input).ncell_rsrp))) && + (!(*input).ncell_rsrq_present || + encode_repeated_ncell_rsrq(state, (&(*input).ncell_rsrq))) && + (!(*input).ncell_timeDiff_present || + encode_repeated_ncell_timeDiff(state, (&(*input).ncell_timeDiff)))) || (zcbor_list_map_end_force_encode(state), false)) && zcbor_map_end_encode(state, 5)))); if (!tmp_result) { - zcbor_trace(); + zcbor_trace_file(state); + zcbor_log("%s error: %s\r\n", __func__, zcbor_error_str(zcbor_peek_error(state))); + } else { + zcbor_log("%s success\r\n", __func__); } return tmp_result; } -static bool encode_repeated_cell_nmr(zcbor_state_t *state, const struct cell_nmr_ *input) +static bool encode_repeated_cell_nmr(zcbor_state_t *state, const struct cell_nmr_r *input) { - zcbor_print("%s\r\n", __func__); + zcbor_log("%s\r\n", __func__); bool tmp_result = ((((zcbor_uint32_put(state, (11)))) && (zcbor_list_start_encode(state, 5) && ((zcbor_multi_encode_minmax( - 0, 5, &(*input)._cell_nmr_ncells_count, (zcbor_encoder_t *)encode_ncell, - state, (&(*input)._cell_nmr_ncells), sizeof(struct ncell))) || + 0, 5, &(*input).cell_nmr_ncells_count, (zcbor_encoder_t *)encode_ncell, + state, (&(*input).cell_nmr_ncells), sizeof(struct ncell))) || (zcbor_list_map_end_force_encode(state), false)) && zcbor_list_end_encode(state, 5)))); if (!tmp_result) { - zcbor_trace(); + zcbor_trace_file(state); + zcbor_log("%s error: %s\r\n", __func__, zcbor_error_str(zcbor_peek_error(state))); + } else { + zcbor_log("%s success\r\n", __func__); } return tmp_result; @@ -170,32 +189,38 @@ static bool encode_repeated_cell_nmr(zcbor_state_t *state, const struct cell_nmr static bool encode_repeated_cell_rsrp(zcbor_state_t *state, const struct cell_rsrp *input) { - zcbor_print("%s\r\n", __func__); + zcbor_log("%s\r\n", __func__); bool tmp_result = ((((zcbor_uint32_put(state, (3)))) && - (zcbor_int32_encode(state, (&(*input)._cell_rsrp))))); + (zcbor_int32_encode(state, (&(*input).cell_rsrp))))); if (!tmp_result) { - zcbor_trace(); + zcbor_trace_file(state); + zcbor_log("%s error: %s\r\n", __func__, zcbor_error_str(zcbor_peek_error(state))); + } else { + zcbor_log("%s success\r\n", __func__); } return tmp_result; } -static bool encode_repeated_cell_rsrq(zcbor_state_t *state, const struct cell_rsrq_ *input) +static bool encode_repeated_cell_rsrq(zcbor_state_t *state, const struct cell_rsrq_r *input) { - zcbor_print("%s\r\n", __func__); + zcbor_log("%s\r\n", __func__); bool tmp_result = ((((zcbor_uint32_put(state, (4)))) && - (((*input)._cell_rsrq_choice == _cell_rsrq_float32) - ? ((zcbor_float32_encode(state, (&(*input)._cell_rsrq_float32)))) - : (((*input)._cell_rsrq_choice == _cell_rsrq_int) - ? ((zcbor_int32_encode(state, (&(*input)._cell_rsrq_int)))) + (((*input).cell_rsrq_choice == cell_rsrq_float32_c) + ? ((zcbor_float32_encode(state, (&(*input).cell_rsrq_float32)))) + : (((*input).cell_rsrq_choice == cell_rsrq_int_c) + ? ((zcbor_int32_encode(state, (&(*input).cell_rsrq_int)))) : false)))); if (!tmp_result) { - zcbor_trace(); + zcbor_trace_file(state); + zcbor_log("%s error: %s\r\n", __func__, zcbor_error_str(zcbor_peek_error(state))); + } else { + zcbor_log("%s success\r\n", __func__); } return tmp_result; @@ -203,37 +228,35 @@ static bool encode_repeated_cell_rsrq(zcbor_state_t *state, const struct cell_rs static bool encode_cell(zcbor_state_t *state, const struct cell *input) { - zcbor_print("%s\r\n", __func__); + zcbor_log("%s\r\n", __func__); bool tmp_result = (((zcbor_map_start_encode(state, 9) && (((((zcbor_uint32_put(state, (6)))) && - (zcbor_uint32_encode(state, (&(*input)._cell_mcc)))) && + (zcbor_uint32_encode(state, (&(*input).cell_mcc)))) && (((zcbor_uint32_put(state, (7)))) && - (zcbor_uint32_encode(state, (&(*input)._cell_mnc)))) && + (zcbor_uint32_encode(state, (&(*input).cell_mnc)))) && (((zcbor_uint32_put(state, (8)))) && - (zcbor_uint32_encode(state, (&(*input)._cell_eci)))) && + (zcbor_uint32_encode(state, (&(*input).cell_eci)))) && (((zcbor_uint32_put(state, (9)))) && - (zcbor_uint32_encode(state, (&(*input)._cell_tac)))) && - zcbor_present_encode(&((*input)._cell_earfcn_present), - (zcbor_encoder_t *)encode_repeated_cell_earfcn, - state, (&(*input)._cell_earfcn)) && - zcbor_present_encode(&((*input)._cell_adv_present), - (zcbor_encoder_t *)encode_repeated_cell_adv, - state, (&(*input)._cell_adv)) && - zcbor_present_encode(&((*input)._cell_nmr_present), - (zcbor_encoder_t *)encode_repeated_cell_nmr, - state, (&(*input)._cell_nmr)) && - zcbor_present_encode(&((*input)._cell_rsrp_present), - (zcbor_encoder_t *)encode_repeated_cell_rsrp, - state, (&(*input)._cell_rsrp)) && - zcbor_present_encode(&((*input)._cell_rsrq_present), - (zcbor_encoder_t *)encode_repeated_cell_rsrq, - state, (&(*input)._cell_rsrq))) || + (zcbor_uint32_encode(state, (&(*input).cell_tac)))) && + (!(*input).cell_earfcn_present || + encode_repeated_cell_earfcn(state, (&(*input).cell_earfcn))) && + (!(*input).cell_adv_present || + encode_repeated_cell_adv(state, (&(*input).cell_adv))) && + (!(*input).cell_nmr_present || + encode_repeated_cell_nmr(state, (&(*input).cell_nmr))) && + (!(*input).cell_rsrp_present || + encode_repeated_cell_rsrp(state, (&(*input).cell_rsrp))) && + (!(*input).cell_rsrq_present || + encode_repeated_cell_rsrq(state, (&(*input).cell_rsrq)))) || (zcbor_list_map_end_force_encode(state), false)) && zcbor_map_end_encode(state, 9)))); if (!tmp_result) { - zcbor_trace(); + zcbor_trace_file(state); + zcbor_log("%s error: %s\r\n", __func__, zcbor_error_str(zcbor_peek_error(state))); + } else { + zcbor_log("%s success\r\n", __func__); } return tmp_result; @@ -241,18 +264,21 @@ static bool encode_cell(zcbor_state_t *state, const struct cell *input) static bool encode_lte_ar(zcbor_state_t *state, const struct lte_ar *input) { - zcbor_print("%s\r\n", __func__); + zcbor_log("%s\r\n", __func__); bool tmp_result = (((zcbor_list_start_encode(state, 5) && - ((zcbor_multi_encode_minmax(1, 5, &(*input)._lte_ar__cell_count, + ((zcbor_multi_encode_minmax(1, 5, &(*input).lte_ar_cell_m_count, (zcbor_encoder_t *)encode_cell, state, - (&(*input)._lte_ar__cell), sizeof(struct cell))) || + (&(*input).lte_ar_cell_m), sizeof(struct cell))) || (zcbor_list_map_end_force_encode(state), false)) && zcbor_list_end_encode(state, 5)))); if (!tmp_result) { - zcbor_trace(); + zcbor_trace_file(state); + zcbor_log("%s error: %s\r\n", __func__, zcbor_error_str(zcbor_peek_error(state))); + } else { + zcbor_log("%s success\r\n", __func__); } return tmp_result; @@ -261,13 +287,16 @@ static bool encode_lte_ar(zcbor_state_t *state, const struct lte_ar *input) static bool encode_repeated_ground_fix_req_lte(zcbor_state_t *state, const struct ground_fix_req_lte *input) { - zcbor_print("%s\r\n", __func__); + zcbor_log("%s\r\n", __func__); bool tmp_result = ((((zcbor_uint32_put(state, (19)))) && - (encode_lte_ar(state, (&(*input)._ground_fix_req_lte))))); + (encode_lte_ar(state, (&(*input).ground_fix_req_lte))))); if (!tmp_result) { - zcbor_trace(); + zcbor_trace_file(state); + zcbor_log("%s error: %s\r\n", __func__, zcbor_error_str(zcbor_peek_error(state))); + } else { + zcbor_log("%s success\r\n", __func__); } return tmp_result; @@ -275,13 +304,16 @@ static bool encode_repeated_ground_fix_req_lte(zcbor_state_t *state, static bool encode_repeated_ap_age(zcbor_state_t *state, const struct ap_age *input) { - zcbor_print("%s\r\n", __func__); + zcbor_log("%s\r\n", __func__); bool tmp_result = ((((zcbor_uint32_put(state, (13)))) && - (zcbor_uint32_encode(state, (&(*input)._ap_age))))); + (zcbor_uint32_encode(state, (&(*input).ap_age))))); if (!tmp_result) { - zcbor_trace(); + zcbor_trace_file(state); + zcbor_log("%s error: %s\r\n", __func__, zcbor_error_str(zcbor_peek_error(state))); + } else { + zcbor_log("%s success\r\n", __func__); } return tmp_result; @@ -290,13 +322,16 @@ static bool encode_repeated_ap_age(zcbor_state_t *state, const struct ap_age *in static bool encode_repeated_ap_signalStrength(zcbor_state_t *state, const struct ap_signalStrength *input) { - zcbor_print("%s\r\n", __func__); + zcbor_log("%s\r\n", __func__); bool tmp_result = ((((zcbor_uint32_put(state, (14)))) && - (zcbor_int32_encode(state, (&(*input)._ap_signalStrength))))); + (zcbor_int32_encode(state, (&(*input).ap_signalStrength))))); if (!tmp_result) { - zcbor_trace(); + zcbor_trace_file(state); + zcbor_log("%s error: %s\r\n", __func__, zcbor_error_str(zcbor_peek_error(state))); + } else { + zcbor_log("%s success\r\n", __func__); } return tmp_result; @@ -304,13 +339,16 @@ static bool encode_repeated_ap_signalStrength(zcbor_state_t *state, static bool encode_repeated_ap_channel(zcbor_state_t *state, const struct ap_channel *input) { - zcbor_print("%s\r\n", __func__); + zcbor_log("%s\r\n", __func__); bool tmp_result = ((((zcbor_uint32_put(state, (15)))) && - (zcbor_uint32_encode(state, (&(*input)._ap_channel))))); + (zcbor_uint32_encode(state, (&(*input).ap_channel))))); if (!tmp_result) { - zcbor_trace(); + zcbor_trace_file(state); + zcbor_log("%s error: %s\r\n", __func__, zcbor_error_str(zcbor_peek_error(state))); + } else { + zcbor_log("%s success\r\n", __func__); } return tmp_result; @@ -318,13 +356,16 @@ static bool encode_repeated_ap_channel(zcbor_state_t *state, const struct ap_cha static bool encode_repeated_ap_frequency(zcbor_state_t *state, const struct ap_frequency *input) { - zcbor_print("%s\r\n", __func__); + zcbor_log("%s\r\n", __func__); bool tmp_result = ((((zcbor_uint32_put(state, (16)))) && - (zcbor_uint32_encode(state, (&(*input)._ap_frequency))))); + (zcbor_uint32_encode(state, (&(*input).ap_frequency))))); if (!tmp_result) { - zcbor_trace(); + zcbor_trace_file(state); + zcbor_log("%s error: %s\r\n", __func__, zcbor_error_str(zcbor_peek_error(state))); + } else { + zcbor_log("%s success\r\n", __func__); } return tmp_result; @@ -332,13 +373,16 @@ static bool encode_repeated_ap_frequency(zcbor_state_t *state, const struct ap_f static bool encode_repeated_ap_ssid(zcbor_state_t *state, const struct ap_ssid *input) { - zcbor_print("%s\r\n", __func__); + zcbor_log("%s\r\n", __func__); bool tmp_result = ((((zcbor_uint32_put(state, (17)))) && - (zcbor_tstr_encode(state, (&(*input)._ap_ssid))))); + (zcbor_tstr_encode(state, (&(*input).ap_ssid))))); if (!tmp_result) { - zcbor_trace(); + zcbor_trace_file(state); + zcbor_log("%s error: %s\r\n", __func__, zcbor_error_str(zcbor_peek_error(state))); + } else { + zcbor_log("%s success\r\n", __func__); } return tmp_result; @@ -346,32 +390,29 @@ static bool encode_repeated_ap_ssid(zcbor_state_t *state, const struct ap_ssid * static bool encode_ap(zcbor_state_t *state, const struct ap *input) { - zcbor_print("%s\r\n", __func__); - - bool tmp_result = - (((zcbor_map_start_encode(state, 6) && - (((((zcbor_uint32_put(state, (12)))) && - (zcbor_bstr_encode(state, (&(*input)._ap_macAddress)))) && - zcbor_present_encode(&((*input)._ap_age_present), - (zcbor_encoder_t *)encode_repeated_ap_age, state, - (&(*input)._ap_age)) && - zcbor_present_encode(&((*input)._ap_signalStrength_present), - (zcbor_encoder_t *)encode_repeated_ap_signalStrength, - state, (&(*input)._ap_signalStrength)) && - zcbor_present_encode(&((*input)._ap_channel_present), - (zcbor_encoder_t *)encode_repeated_ap_channel, state, - (&(*input)._ap_channel)) && - zcbor_present_encode(&((*input)._ap_frequency_present), - (zcbor_encoder_t *)encode_repeated_ap_frequency, state, - (&(*input)._ap_frequency)) && - zcbor_present_encode(&((*input)._ap_ssid_present), - (zcbor_encoder_t *)encode_repeated_ap_ssid, state, - (&(*input)._ap_ssid))) || - (zcbor_list_map_end_force_encode(state), false)) && - zcbor_map_end_encode(state, 6)))); + zcbor_log("%s\r\n", __func__); + + bool tmp_result = ((( + zcbor_map_start_encode(state, 6) && + (((((zcbor_uint32_put(state, (12)))) && + (zcbor_bstr_encode(state, (&(*input).ap_macAddress)))) && + (!(*input).ap_age_present || encode_repeated_ap_age(state, (&(*input).ap_age))) && + (!(*input).ap_signalStrength_present || + encode_repeated_ap_signalStrength(state, (&(*input).ap_signalStrength))) && + (!(*input).ap_channel_present || + encode_repeated_ap_channel(state, (&(*input).ap_channel))) && + (!(*input).ap_frequency_present || + encode_repeated_ap_frequency(state, (&(*input).ap_frequency))) && + (!(*input).ap_ssid_present || + encode_repeated_ap_ssid(state, (&(*input).ap_ssid)))) || + (zcbor_list_map_end_force_encode(state), false)) && + zcbor_map_end_encode(state, 6)))); if (!tmp_result) { - zcbor_trace(); + zcbor_trace_file(state); + zcbor_log("%s error: %s\r\n", __func__, zcbor_error_str(zcbor_peek_error(state))); + } else { + zcbor_log("%s success\r\n", __func__); } return tmp_result; @@ -379,15 +420,15 @@ static bool encode_ap(zcbor_state_t *state, const struct ap *input) static bool encode_wifi_ob(zcbor_state_t *state, const struct wifi_ob *input) { - zcbor_print("%s\r\n", __func__); + zcbor_log("%s\r\n", __func__); bool tmp_result = (((zcbor_map_start_encode(state, 1) && (((((zcbor_uint32_put(state, (18)))) && (zcbor_list_start_encode(state, 20) && - ((zcbor_multi_encode_minmax(2, 20, &(*input)._wifi_ob_accessPoints__ap_count, + ((zcbor_multi_encode_minmax(2, 20, &(*input).wifi_ob_accessPoints_ap_m_count, (zcbor_encoder_t *)encode_ap, state, - (&(*input)._wifi_ob_accessPoints__ap), + (&(*input).wifi_ob_accessPoints_ap_m), sizeof(struct ap))) || (zcbor_list_map_end_force_encode(state), false)) && zcbor_list_end_encode(state, 20)))) || @@ -395,7 +436,10 @@ static bool encode_wifi_ob(zcbor_state_t *state, const struct wifi_ob *input) zcbor_map_end_encode(state, 1)))); if (!tmp_result) { - zcbor_trace(); + zcbor_trace_file(state); + zcbor_log("%s error: %s\r\n", __func__, zcbor_error_str(zcbor_peek_error(state))); + } else { + zcbor_log("%s success\r\n", __func__); } return tmp_result; @@ -404,13 +448,16 @@ static bool encode_wifi_ob(zcbor_state_t *state, const struct wifi_ob *input) static bool encode_repeated_ground_fix_req_wifi(zcbor_state_t *state, const struct ground_fix_req_wifi *input) { - zcbor_print("%s\r\n", __func__); + zcbor_log("%s\r\n", __func__); bool tmp_result = ((((zcbor_uint32_put(state, (20)))) && - (encode_wifi_ob(state, (&(*input)._ground_fix_req_wifi))))); + (encode_wifi_ob(state, (&(*input).ground_fix_req_wifi))))); if (!tmp_result) { - zcbor_trace(); + zcbor_trace_file(state); + zcbor_log("%s error: %s\r\n", __func__, zcbor_error_str(zcbor_peek_error(state))); + } else { + zcbor_log("%s success\r\n", __func__); } return tmp_result; @@ -418,21 +465,22 @@ static bool encode_repeated_ground_fix_req_wifi(zcbor_state_t *state, static bool encode_ground_fix_req(zcbor_state_t *state, const struct ground_fix_req *input) { - zcbor_print("%s\r\n", __func__); + zcbor_log("%s\r\n", __func__); - bool tmp_result = - (((zcbor_map_start_encode(state, 2) && - ((zcbor_present_encode(&((*input)._ground_fix_req_lte_present), - (zcbor_encoder_t *)encode_repeated_ground_fix_req_lte, - state, (&(*input)._ground_fix_req_lte)) && - zcbor_present_encode(&((*input)._ground_fix_req_wifi_present), - (zcbor_encoder_t *)encode_repeated_ground_fix_req_wifi, - state, (&(*input)._ground_fix_req_wifi))) || - (zcbor_list_map_end_force_encode(state), false)) && - zcbor_map_end_encode(state, 2)))); + bool tmp_result = (( + (zcbor_map_start_encode(state, 2) && + (((!(*input).ground_fix_req_lte_present || + encode_repeated_ground_fix_req_lte(state, (&(*input).ground_fix_req_lte))) && + (!(*input).ground_fix_req_wifi_present || + encode_repeated_ground_fix_req_wifi(state, (&(*input).ground_fix_req_wifi)))) || + (zcbor_list_map_end_force_encode(state), false)) && + zcbor_map_end_encode(state, 2)))); if (!tmp_result) { - zcbor_trace(); + zcbor_trace_file(state); + zcbor_log("%s error: %s\r\n", __func__, zcbor_error_str(zcbor_peek_error(state))); + } else { + zcbor_log("%s success\r\n", __func__); } return tmp_result; @@ -443,19 +491,7 @@ int cbor_encode_ground_fix_req(uint8_t *payload, size_t payload_len, { zcbor_state_t states[8]; - zcbor_new_state(states, sizeof(states) / sizeof(zcbor_state_t), payload, payload_len, 1); - - bool ret = encode_ground_fix_req(states, input); - - if (ret && (payload_len_out != NULL)) { - *payload_len_out = MIN(payload_len, (size_t)states[0].payload - (size_t)payload); - } - - if (!ret) { - int err = zcbor_pop_error(states); - - zcbor_print("Return error: %d\r\n", err); - return (err == ZCBOR_SUCCESS) ? ZCBOR_ERR_UNKNOWN : err; - } - return ZCBOR_SUCCESS; + return zcbor_entry_function(payload, payload_len, (void *)input, payload_len_out, states, + (zcbor_decoder_t *)encode_ground_fix_req, + sizeof(states) / sizeof(zcbor_state_t), 1); } diff --git a/subsys/net/lib/nrf_cloud/coap/src/msg_encode.c b/subsys/net/lib/nrf_cloud/coap/src/msg_encode.c index 7ccf3929660f..40c7bfbd6e95 100644 --- a/subsys/net/lib/nrf_cloud/coap/src/msg_encode.c +++ b/subsys/net/lib/nrf_cloud/coap/src/msg_encode.c @@ -1,8 +1,8 @@ /* - * Copyright (c) 2023 Nordic Semiconductor ASA + * Copyright (c) 2024 Nordic Semiconductor ASA * SPDX-License-Identifier: LicenseRef-Nordic-5-Clause * - * Generated using zcbor version 0.7.0 + * Generated using zcbor version 0.8.1 * https://github.com/NordicSemiconductor/zcbor * Generated with a --default-max-qty of 10 */ @@ -13,6 +13,7 @@ #include #include "zcbor_encode.h" #include "msg_encode.h" +#include "zcbor_print.h" #if DEFAULT_MAX_QTY != 10 #error "The type file was generated with a different default_max_qty than this file" @@ -28,13 +29,16 @@ static bool encode_message_out(zcbor_state_t *state, const struct message_out *i static bool encode_repeated_pvt_spd(zcbor_state_t *state, const struct pvt_spd *input) { - zcbor_print("%s\r\n", __func__); + zcbor_log("%s\r\n", __func__); bool tmp_result = ((((zcbor_uint32_put(state, (7)))) && - (zcbor_float64_encode(state, (&(*input)._pvt_spd))))); + (zcbor_float64_encode(state, (&(*input).pvt_spd))))); if (!tmp_result) { - zcbor_trace(); + zcbor_trace_file(state); + zcbor_log("%s error: %s\r\n", __func__, zcbor_error_str(zcbor_peek_error(state))); + } else { + zcbor_log("%s success\r\n", __func__); } return tmp_result; @@ -42,13 +46,16 @@ static bool encode_repeated_pvt_spd(zcbor_state_t *state, const struct pvt_spd * static bool encode_repeated_pvt_hdg(zcbor_state_t *state, const struct pvt_hdg *input) { - zcbor_print("%s\r\n", __func__); + zcbor_log("%s\r\n", __func__); bool tmp_result = ((((zcbor_uint32_put(state, (8)))) && - (zcbor_float64_encode(state, (&(*input)._pvt_hdg))))); + (zcbor_float64_encode(state, (&(*input).pvt_hdg))))); if (!tmp_result) { - zcbor_trace(); + zcbor_trace_file(state); + zcbor_log("%s error: %s\r\n", __func__, zcbor_error_str(zcbor_peek_error(state))); + } else { + zcbor_log("%s success\r\n", __func__); } return tmp_result; @@ -56,13 +63,16 @@ static bool encode_repeated_pvt_hdg(zcbor_state_t *state, const struct pvt_hdg * static bool encode_repeated_pvt_alt(zcbor_state_t *state, const struct pvt_alt *input) { - zcbor_print("%s\r\n", __func__); + zcbor_log("%s\r\n", __func__); bool tmp_result = ((((zcbor_uint32_put(state, (9)))) && - (zcbor_float64_encode(state, (&(*input)._pvt_alt))))); + (zcbor_float64_encode(state, (&(*input).pvt_alt))))); if (!tmp_result) { - zcbor_trace(); + zcbor_trace_file(state); + zcbor_log("%s error: %s\r\n", __func__, zcbor_error_str(zcbor_peek_error(state))); + } else { + zcbor_log("%s success\r\n", __func__); } return tmp_result; @@ -70,29 +80,29 @@ static bool encode_repeated_pvt_alt(zcbor_state_t *state, const struct pvt_alt * static bool encode_pvt(zcbor_state_t *state, const struct pvt *input) { - zcbor_print("%s\r\n", __func__); + zcbor_log("%s\r\n", __func__); bool tmp_result = (((zcbor_map_start_encode(state, 6) && (((((zcbor_uint32_put(state, (4)))) && - (zcbor_float64_encode(state, (&(*input)._pvt_lat)))) && + (zcbor_float64_encode(state, (&(*input).pvt_lat)))) && (((zcbor_uint32_put(state, (5)))) && - (zcbor_float64_encode(state, (&(*input)._pvt_lng)))) && + (zcbor_float64_encode(state, (&(*input).pvt_lng)))) && (((zcbor_uint32_put(state, (6)))) && - (zcbor_float64_encode(state, (&(*input)._pvt_acc)))) && - zcbor_present_encode(&((*input)._pvt_spd_present), - (zcbor_encoder_t *)encode_repeated_pvt_spd, - state, (&(*input)._pvt_spd)) && - zcbor_present_encode(&((*input)._pvt_hdg_present), - (zcbor_encoder_t *)encode_repeated_pvt_hdg, - state, (&(*input)._pvt_hdg)) && - zcbor_present_encode(&((*input)._pvt_alt_present), - (zcbor_encoder_t *)encode_repeated_pvt_alt, - state, (&(*input)._pvt_alt))) || + (zcbor_float64_encode(state, (&(*input).pvt_acc)))) && + (!(*input).pvt_spd_present || + encode_repeated_pvt_spd(state, (&(*input).pvt_spd))) && + (!(*input).pvt_hdg_present || + encode_repeated_pvt_hdg(state, (&(*input).pvt_hdg))) && + (!(*input).pvt_alt_present || + encode_repeated_pvt_alt(state, (&(*input).pvt_alt)))) || (zcbor_list_map_end_force_encode(state), false)) && zcbor_map_end_encode(state, 6)))); if (!tmp_result) { - zcbor_trace(); + zcbor_trace_file(state); + zcbor_log("%s error: %s\r\n", __func__, zcbor_error_str(zcbor_peek_error(state))); + } else { + zcbor_log("%s success\r\n", __func__); } return tmp_result; @@ -100,15 +110,18 @@ static bool encode_pvt(zcbor_state_t *state, const struct pvt *input) static bool encode_repeated_message_out_ts(zcbor_state_t *state, const struct message_out_ts *input) { - zcbor_print("%s\r\n", __func__); + zcbor_log("%s\r\n", __func__); bool tmp_result = ((((zcbor_uint32_put(state, (3)))) && - ((((*input)._message_out_ts <= UINT64_MAX)) || + ((((*input).message_out_ts <= UINT64_MAX)) || (zcbor_error(state, ZCBOR_ERR_WRONG_RANGE), false)) && - (zcbor_uint64_encode(state, (&(*input)._message_out_ts))))); + (zcbor_uint64_encode(state, (&(*input).message_out_ts))))); if (!tmp_result) { - zcbor_trace(); + zcbor_trace_file(state); + zcbor_log("%s error: %s\r\n", __func__, zcbor_error_str(zcbor_peek_error(state))); + } else { + zcbor_log("%s success\r\n", __func__); } return tmp_result; @@ -116,37 +129,39 @@ static bool encode_repeated_message_out_ts(zcbor_state_t *state, const struct me static bool encode_message_out(zcbor_state_t *state, const struct message_out *input) { - zcbor_print("%s\r\n", __func__); + zcbor_log("%s\r\n", __func__); bool tmp_result = ((( zcbor_map_start_encode(state, 3) && (((((zcbor_uint32_put(state, (1)))) && - (zcbor_tstr_encode(state, (&(*input)._message_out_appId)))) && + (zcbor_tstr_encode(state, (&(*input).message_out_appId)))) && (((zcbor_uint32_put(state, (2)))) && - (((*input)._message_out_data_choice == _message_out_data_tstr) - ? ((zcbor_tstr_encode(state, (&(*input)._message_out_data_tstr)))) - : (((*input)._message_out_data_choice == _message_out_data_float) - ? ((zcbor_float64_encode( - state, (&(*input)._message_out_data_float)))) - : (((*input)._message_out_data_choice == - _message_out_data_int) - ? ((zcbor_int32_encode( - state, - (&(*input)._message_out_data_int)))) - : (((*input)._message_out_data_choice == - _message_out_data__pvt) - ? ((encode_pvt( - state, - (&(*input)._message_out_data__pvt)))) - : false))))) && - zcbor_present_encode(&((*input)._message_out_ts_present), - (zcbor_encoder_t *)encode_repeated_message_out_ts, state, - (&(*input)._message_out_ts))) || + (((*input).message_out_data_choice == message_out_data_tstr_c) + ? ((zcbor_tstr_encode(state, (&(*input).message_out_data_tstr)))) + : (((*input).message_out_data_choice == message_out_data_float_c) + ? ((zcbor_float64_encode( + state, (&(*input).message_out_data_float)))) + : (((*input).message_out_data_choice == + message_out_data_int_c) + ? ((zcbor_int32_encode( + state, + (&(*input).message_out_data_int)))) + : (((*input).message_out_data_choice == + message_out_data_pvt_m_c) + ? ((encode_pvt( + state, + (&(*input).message_out_data_pvt_m)))) + : false))))) && + (!(*input).message_out_ts_present || + encode_repeated_message_out_ts(state, (&(*input).message_out_ts)))) || (zcbor_list_map_end_force_encode(state), false)) && zcbor_map_end_encode(state, 3)))); if (!tmp_result) { - zcbor_trace(); + zcbor_trace_file(state); + zcbor_log("%s error: %s\r\n", __func__, zcbor_error_str(zcbor_peek_error(state))); + } else { + zcbor_log("%s success\r\n", __func__); } return tmp_result; @@ -157,19 +172,7 @@ int cbor_encode_message_out(uint8_t *payload, size_t payload_len, const struct m { zcbor_state_t states[5]; - zcbor_new_state(states, sizeof(states) / sizeof(zcbor_state_t), payload, payload_len, 1); - - bool ret = encode_message_out(states, input); - - if (ret && (payload_len_out != NULL)) { - *payload_len_out = MIN(payload_len, (size_t)states[0].payload - (size_t)payload); - } - - if (!ret) { - int err = zcbor_pop_error(states); - - zcbor_print("Return error: %d\r\n", err); - return (err == ZCBOR_SUCCESS) ? ZCBOR_ERR_UNKNOWN : err; - } - return ZCBOR_SUCCESS; + return zcbor_entry_function(payload, payload_len, (void *)input, payload_len_out, states, + (zcbor_decoder_t *)encode_message_out, + sizeof(states) / sizeof(zcbor_state_t), 1); } diff --git a/subsys/net/lib/nrf_cloud/coap/src/pgps_decode.c b/subsys/net/lib/nrf_cloud/coap/src/pgps_decode.c index ce5edcdd0e64..9e5a8d6326b0 100644 --- a/subsys/net/lib/nrf_cloud/coap/src/pgps_decode.c +++ b/subsys/net/lib/nrf_cloud/coap/src/pgps_decode.c @@ -1,8 +1,8 @@ /* - * Copyright (c) 2023 Nordic Semiconductor ASA + * Copyright (c) 2024 Nordic Semiconductor ASA * SPDX-License-Identifier: LicenseRef-Nordic-5-Clause * - * Generated using zcbor version 0.7.0 + * Generated using zcbor version 0.8.1 * https://github.com/NordicSemiconductor/zcbor * Generated with a --default-max-qty of 10 */ @@ -13,6 +13,7 @@ #include #include "zcbor_decode.h" #include "pgps_decode.h" +#include "zcbor_print.h" #if DEFAULT_MAX_QTY != 10 #error "The type file was generated with a different default_max_qty than this file" @@ -22,18 +23,21 @@ static bool decode_pgps_resp(zcbor_state_t *state, struct pgps_resp *result); static bool decode_pgps_resp(zcbor_state_t *state, struct pgps_resp *result) { - zcbor_print("%s\r\n", __func__); + zcbor_log("%s\r\n", __func__); bool tmp_result = (((zcbor_map_start_decode(state) && (((((zcbor_uint32_expect(state, (1)))) && - (zcbor_tstr_decode(state, (&(*result)._pgps_resp_host)))) && + (zcbor_tstr_decode(state, (&(*result).pgps_resp_host)))) && (((zcbor_uint32_expect(state, (2)))) && - (zcbor_tstr_decode(state, (&(*result)._pgps_resp_path))))) || + (zcbor_tstr_decode(state, (&(*result).pgps_resp_path))))) || (zcbor_list_map_end_force_decode(state), false)) && zcbor_map_end_decode(state)))); if (!tmp_result) { - zcbor_trace(); + zcbor_trace_file(state); + zcbor_log("%s error: %s\r\n", __func__, zcbor_error_str(zcbor_peek_error(state))); + } else { + zcbor_log("%s success\r\n", __func__); } return tmp_result; @@ -44,19 +48,7 @@ int cbor_decode_pgps_resp(const uint8_t *payload, size_t payload_len, struct pgp { zcbor_state_t states[3]; - zcbor_new_state(states, sizeof(states) / sizeof(zcbor_state_t), payload, payload_len, 1); - - bool ret = decode_pgps_resp(states, result); - - if (ret && (payload_len_out != NULL)) { - *payload_len_out = MIN(payload_len, (size_t)states[0].payload - (size_t)payload); - } - - if (!ret) { - int err = zcbor_pop_error(states); - - zcbor_print("Return error: %d\r\n", err); - return (err == ZCBOR_SUCCESS) ? ZCBOR_ERR_UNKNOWN : err; - } - return ZCBOR_SUCCESS; + return zcbor_entry_function(payload, payload_len, (void *)result, payload_len_out, states, + (zcbor_decoder_t *)decode_pgps_resp, + sizeof(states) / sizeof(zcbor_state_t), 1); } diff --git a/subsys/net/lib/nrf_cloud/coap/src/pgps_encode.c b/subsys/net/lib/nrf_cloud/coap/src/pgps_encode.c index 5e54c6a8a888..5cd530b9a101 100644 --- a/subsys/net/lib/nrf_cloud/coap/src/pgps_encode.c +++ b/subsys/net/lib/nrf_cloud/coap/src/pgps_encode.c @@ -1,8 +1,8 @@ /* - * Copyright (c) 2023 Nordic Semiconductor ASA + * Copyright (c) 2024 Nordic Semiconductor ASA * SPDX-License-Identifier: LicenseRef-Nordic-5-Clause * - * Generated using zcbor version 0.7.0 + * Generated using zcbor version 0.8.1 * https://github.com/NordicSemiconductor/zcbor * Generated with a --default-max-qty of 10 */ @@ -13,6 +13,7 @@ #include #include "zcbor_encode.h" #include "pgps_encode.h" +#include "zcbor_print.h" #if DEFAULT_MAX_QTY != 10 #error "The type file was generated with a different default_max_qty than this file" @@ -22,23 +23,26 @@ static bool encode_pgps_req(zcbor_state_t *state, const struct pgps_req *input); static bool encode_pgps_req(zcbor_state_t *state, const struct pgps_req *input) { - zcbor_print("%s\r\n", __func__); - - bool tmp_result = ((( - zcbor_map_start_encode(state, 4) && - (((((zcbor_uint32_put(state, (1)))) && - (zcbor_uint32_encode(state, (&(*input)._pgps_req_predictionCount)))) && - (((zcbor_uint32_put(state, (2)))) && - (zcbor_uint32_encode(state, (&(*input)._pgps_req_predictionIntervalMinutes)))) && - (((zcbor_uint32_put(state, (3)))) && - (zcbor_uint32_encode(state, (&(*input)._pgps_req_startGPSDay)))) && - (((zcbor_uint32_put(state, (4)))) && - (zcbor_uint32_encode(state, (&(*input)._pgps_req_startGPSTimeOfDaySeconds))))) || - (zcbor_list_map_end_force_encode(state), false)) && - zcbor_map_end_encode(state, 4)))); + zcbor_log("%s\r\n", __func__); + + bool tmp_result = (( + (zcbor_map_start_encode(state, 4) && + (((((zcbor_uint32_put(state, (1)))) && + (zcbor_uint32_encode(state, (&(*input).pgps_req_predictionCount)))) && + (((zcbor_uint32_put(state, (2)))) && + (zcbor_uint32_encode(state, (&(*input).pgps_req_predictionIntervalMinutes)))) && + (((zcbor_uint32_put(state, (3)))) && + (zcbor_uint32_encode(state, (&(*input).pgps_req_startGPSDay)))) && + (((zcbor_uint32_put(state, (4)))) && + (zcbor_uint32_encode(state, (&(*input).pgps_req_startGPSTimeOfDaySeconds))))) || + (zcbor_list_map_end_force_encode(state), false)) && + zcbor_map_end_encode(state, 4)))); if (!tmp_result) { - zcbor_trace(); + zcbor_trace_file(state); + zcbor_log("%s error: %s\r\n", __func__, zcbor_error_str(zcbor_peek_error(state))); + } else { + zcbor_log("%s success\r\n", __func__); } return tmp_result; @@ -49,19 +53,7 @@ int cbor_encode_pgps_req(uint8_t *payload, size_t payload_len, const struct pgps { zcbor_state_t states[3]; - zcbor_new_state(states, sizeof(states) / sizeof(zcbor_state_t), payload, payload_len, 1); - - bool ret = encode_pgps_req(states, input); - - if (ret && (payload_len_out != NULL)) { - *payload_len_out = MIN(payload_len, (size_t)states[0].payload - (size_t)payload); - } - - if (!ret) { - int err = zcbor_pop_error(states); - - zcbor_print("Return error: %d\r\n", err); - return (err == ZCBOR_SUCCESS) ? ZCBOR_ERR_UNKNOWN : err; - } - return ZCBOR_SUCCESS; + return zcbor_entry_function(payload, payload_len, (void *)input, payload_len_out, states, + (zcbor_decoder_t *)encode_pgps_req, + sizeof(states) / sizeof(zcbor_state_t), 1); } diff --git a/subsys/net/lib/nrf_cloud/coap/update_codec.sh b/subsys/net/lib/nrf_cloud/coap/update_codec.sh index 442c3d8369c9..4b3342e10368 100644 --- a/subsys/net/lib/nrf_cloud/coap/update_codec.sh +++ b/subsys/net/lib/nrf_cloud/coap/update_codec.sh @@ -3,7 +3,7 @@ # SPDX-License-Identifier: LicenseRef-Nordic-5-Clause export HDR=" -Copyright (c) 2023 Nordic Semiconductor ASA +Copyright (c) $(date +%Y) Nordic Semiconductor ASA SPDX-License-Identifier: LicenseRef-Nordic-5-Clause " diff --git a/subsys/net/lib/nrf_provisioning/include/nrf_provisioning_cbor_decode.h b/subsys/net/lib/nrf_provisioning/include/nrf_provisioning_cbor_decode.h index 3d3c17bfa217..32423fe7e47d 100644 --- a/subsys/net/lib/nrf_provisioning/include/nrf_provisioning_cbor_decode.h +++ b/subsys/net/lib/nrf_provisioning/include/nrf_provisioning_cbor_decode.h @@ -1,10 +1,9 @@ /* - * Copyright (c) 2023 Nordic Semiconductor ASA + * Copyright (c) 2024 Nordic Semiconductor ASA * * SPDX-License-Identifier: LicenseRef-Nordic-5-Clause - */ -/* - * Generated using zcbor version 0.6.0 + * + * Generated using zcbor version 0.8.1 * https://github.com/NordicSemiconductor/zcbor * Generated with a --default-max-qty of CONFIG_NRF_PROVISIONING_CBOR_RECORDS */ @@ -16,9 +15,12 @@ #include #include #include -#include "zcbor_decode.h" #include "nrf_provisioning_cbor_decode_types.h" +#ifdef __cplusplus +extern "C" { +#endif + #if DEFAULT_MAX_QTY != CONFIG_NRF_PROVISIONING_CBOR_RECORDS #error "The type file was generated with a different default_max_qty than this file" #endif @@ -26,4 +28,8 @@ int cbor_decode_commands(const uint8_t *payload, size_t payload_len, struct commands *result, size_t *payload_len_out); +#ifdef __cplusplus +} +#endif + #endif /* NRF_PROVISIONING_CBOR_DECODE_H__ */ diff --git a/subsys/net/lib/nrf_provisioning/include/nrf_provisioning_cbor_decode_types.h b/subsys/net/lib/nrf_provisioning/include/nrf_provisioning_cbor_decode_types.h index 57b4028dfd47..cafa629bc350 100644 --- a/subsys/net/lib/nrf_provisioning/include/nrf_provisioning_cbor_decode_types.h +++ b/subsys/net/lib/nrf_provisioning/include/nrf_provisioning_cbor_decode_types.h @@ -1,10 +1,9 @@ /* - * Copyright (c) 2023 Nordic Semiconductor ASA + * Copyright (c) 2024 Nordic Semiconductor ASA * * SPDX-License-Identifier: LicenseRef-Nordic-5-Clause - */ -/* - * Generated using zcbor version 0.6.0 + * + * Generated using zcbor version 0.8.1 * https://github.com/NordicSemiconductor/zcbor * Generated with a --default-max-qty of CONFIG_NRF_PROVISIONING_CBOR_RECORDS */ @@ -15,8 +14,11 @@ #include #include #include -#include -#include "zcbor_decode.h" +#include + +#ifdef __cplusplus +extern "C" { +#endif /** Which value for --default-max-qty this file was created with. * @@ -28,38 +30,42 @@ #define DEFAULT_MAX_QTY CONFIG_NRF_PROVISIONING_CBOR_RECORDS struct at_command { - struct zcbor_string _at_command_set_command; - struct zcbor_string _at_command_parameters; - uint32_t _at_command_ignore_cme_errors_uint[6]; - uint_fast32_t _at_command_ignore_cme_errors_uint_count; + struct zcbor_string at_command_set_command; + struct zcbor_string at_command_parameters; + uint32_t at_command_ignore_cme_errors_uint[6]; + size_t at_command_ignore_cme_errors_uint_count; }; struct properties_tstrtstr { - struct zcbor_string _config_properties_tstrtstr_key; - struct zcbor_string _properties_tstrtstr; + struct zcbor_string config_properties_tstrtstr_key; + struct zcbor_string properties_tstrtstr; }; struct config { - struct properties_tstrtstr _properties_tstrtstr[100]; - uint_fast32_t _properties_tstrtstr_count; + struct properties_tstrtstr properties_tstrtstr[100]; + size_t properties_tstrtstr_count; }; struct command { - struct zcbor_string _command__correlation; + struct zcbor_string command_correlation_m; union { - struct at_command _command_union__at_command; - struct config _command_union__config; + struct at_command command_union_at_command_m; + struct config command_union_config_m; }; enum { - _command_union__at_command, - _command_union__config, - _command_union__finished, - } _command_union_choice; + command_union_at_command_m_c, + command_union_config_m_c, + command_union_finished_m_c, + } command_union_choice; }; struct commands { - struct command _commands__command[CONFIG_NRF_PROVISIONING_CBOR_RECORDS]; - uint_fast32_t _commands__command_count; + struct command commands_command_m[CONFIG_NRF_PROVISIONING_CBOR_RECORDS]; + size_t commands_command_m_count; }; +#ifdef __cplusplus +} +#endif + #endif /* NRF_PROVISIONING_CBOR_DECODE_TYPES_H__ */ diff --git a/subsys/net/lib/nrf_provisioning/include/nrf_provisioning_cbor_encode.h b/subsys/net/lib/nrf_provisioning/include/nrf_provisioning_cbor_encode.h index 67f82d9d0261..75f7240ef9cd 100644 --- a/subsys/net/lib/nrf_provisioning/include/nrf_provisioning_cbor_encode.h +++ b/subsys/net/lib/nrf_provisioning/include/nrf_provisioning_cbor_encode.h @@ -1,10 +1,9 @@ /* - * Copyright (c) 2023 Nordic Semiconductor ASA + * Copyright (c) 2024 Nordic Semiconductor ASA * * SPDX-License-Identifier: LicenseRef-Nordic-5-Clause - */ -/* - * Generated using zcbor version 0.6.0 + * + * Generated using zcbor version 0.8.1 * https://github.com/NordicSemiconductor/zcbor * Generated with a --default-max-qty of 1234567890 */ @@ -16,9 +15,12 @@ #include #include #include -#include "zcbor_encode.h" #include "nrf_provisioning_cbor_encode_types.h" +#ifdef __cplusplus +extern "C" { +#endif + #if DEFAULT_MAX_QTY != CONFIG_NRF_PROVISIONING_CBOR_RECORDS #error "The type file was generated with a different default_max_qty than this file" #endif @@ -26,4 +28,8 @@ int cbor_encode_responses(uint8_t *payload, size_t payload_len, const struct responses *input, size_t *payload_len_out); +#ifdef __cplusplus +} +#endif + #endif /* NRF_PROVISIONING_CBOR_ENCODE_H__ */ diff --git a/subsys/net/lib/nrf_provisioning/include/nrf_provisioning_cbor_encode_types.h b/subsys/net/lib/nrf_provisioning/include/nrf_provisioning_cbor_encode_types.h index 1b3b1758f5e3..e1741b410844 100644 --- a/subsys/net/lib/nrf_provisioning/include/nrf_provisioning_cbor_encode_types.h +++ b/subsys/net/lib/nrf_provisioning/include/nrf_provisioning_cbor_encode_types.h @@ -1,10 +1,9 @@ /* - * Copyright (c) 2023 Nordic Semiconductor ASA + * Copyright (c) 2024 Nordic Semiconductor ASA * * SPDX-License-Identifier: LicenseRef-Nordic-5-Clause - */ -/* - * Generated using zcbor version 0.6.0 + * + * Generated using zcbor version 0.8.1 * https://github.com/NordicSemiconductor/zcbor * Generated with a --default-max-qty of 1234567890 */ @@ -15,8 +14,11 @@ #include #include #include -#include -#include "zcbor_encode.h" +#include + +#ifdef __cplusplus +extern "C" { +#endif /** Which value for --default-max-qty this file was created with. * @@ -28,31 +30,35 @@ #define DEFAULT_MAX_QTY CONFIG_NRF_PROVISIONING_CBOR_RECORDS struct error_response { - uint32_t _error_response_cme_error; - struct zcbor_string _error_response_message; + uint32_t error_response_cme_error; + struct zcbor_string error_response_message; }; struct at_response { - struct zcbor_string _at_response_message; + struct zcbor_string at_response_message; }; struct response { - struct zcbor_string _response__correlation; + struct zcbor_string response_correlation_m; union { - struct error_response _response_union__error_response; - struct at_response _response_union__at_response; + struct error_response response_union_error_response_m; + struct at_response response_union_at_response_m; }; enum { - _response_union__error_response, - _response_union__at_response, - _response_union__config_ack, - _response_union__finished_ack, - } _response_union_choice; + response_union_error_response_m_c, + response_union_at_response_m_c, + response_union_config_ack_m_c, + response_union_finished_ack_m_c, + } response_union_choice; }; struct responses { - struct response _responses__response[CONFIG_NRF_PROVISIONING_CBOR_RECORDS]; - uint_fast32_t _responses__response_count; + struct response responses_response_m[CONFIG_NRF_PROVISIONING_CBOR_RECORDS]; + size_t responses_response_m_count; }; +#ifdef __cplusplus +} +#endif + #endif /* NRF_PROVISIONING_CBOR_ENCODE_TYPES_H__ */ diff --git a/subsys/net/lib/nrf_provisioning/nrf_provisioning_cbor.patch b/subsys/net/lib/nrf_provisioning/nrf_provisioning_cbor.patch index d1af10944629..578af5bc6ef0 100644 --- a/subsys/net/lib/nrf_provisioning/nrf_provisioning_cbor.patch +++ b/subsys/net/lib/nrf_provisioning/nrf_provisioning_cbor.patch @@ -1,65 +1,54 @@ diff --git a/subsys/net/lib/nrf_provisioning/include/nrf_provisioning_cbor_encode.h b/subsys/net/lib/nrf_provisioning/include/nrf_provisioning_cbor_encode.h -index 3b6f2a87a..57fcfaf40 100644 --- a/subsys/net/lib/nrf_provisioning/include/nrf_provisioning_cbor_encode.h +++ b/subsys/net/lib/nrf_provisioning/include/nrf_provisioning_cbor_encode.h -@@ -14,7 +14,7 @@ - #include "zcbor_encode.h" - #include "nrf_provisioning_cbor_encode_types.h" +@@ -21,7 +21,7 @@ +extern "C" { +#endif -#if DEFAULT_MAX_QTY != 1234567890 +#if DEFAULT_MAX_QTY != CONFIG_NRF_PROVISIONING_CBOR_RECORDS - #error "The type file was generated with a different default_max_qty than this file" - #endif +#error "The type file was generated with a different default_max_qty than this file" +#endif diff --git a/subsys/net/lib/nrf_provisioning/include/nrf_provisioning_cbor_encode_types.h b/subsys/net/lib/nrf_provisioning/include/nrf_provisioning_cbor_encode_types.h -index 4c512b209..f3dda00ce 100644 --- a/subsys/net/lib/nrf_provisioning/include/nrf_provisioning_cbor_encode_types.h +++ b/subsys/net/lib/nrf_provisioning/include/nrf_provisioning_cbor_encode_types.h -@@ -20,7 +20,7 @@ - * - * See `zcbor --help` for more information about --default-max-qty - */ +@@ -27,7 +27,7 @@ extern "C" { + * + * See `zcbor --help` for more information about --default-max-qty + */ -#define DEFAULT_MAX_QTY 1234567890 +#define DEFAULT_MAX_QTY CONFIG_NRF_PROVISIONING_CBOR_RECORDS - struct error_response { - struct zcbor_string _error_response_error_code; -@@ -46,7 +46,7 @@ struct response { - }; +struct error_response { + uint32_t error_response_cme_error; +@@ -53,7 +53,7 @@ struct response { +}; - struct responses { -- struct response _responses__response[1234567890]; -+ struct response _responses__response[CONFIG_NRF_PROVISIONING_CBOR_RECORDS]; - uint_fast32_t _responses__response_count; - }; +struct responses { +- struct response responses_response_m[1234567890]; ++ struct response responses_response_m[CONFIG_NRF_PROVISIONING_CBOR_RECORDS]; + size_t responses_response_m_count; +}; diff --git a/subsys/net/lib/nrf_provisioning/src/nrf_provisioning_cbor_encode.c b/subsys/net/lib/nrf_provisioning/src/nrf_provisioning_cbor_encode.c -index f65bdfcf2..e1769cc97 100644 --- a/subsys/net/lib/nrf_provisioning/src/nrf_provisioning_cbor_encode.c +++ b/subsys/net/lib/nrf_provisioning/src/nrf_provisioning_cbor_encode.c -@@ -11,7 +11,7 @@ - #include "zcbor_encode.h" - #include "nrf_provisioning_cbor_encode.h" +@@ -16,7 +16,7 @@ +#include "nrf_provisioning_cbor_encode.h" +#include "zcbor_print.h" -#if DEFAULT_MAX_QTY != 1234567890 +#if DEFAULT_MAX_QTY != CONFIG_NRF_PROVISIONING_CBOR_RECORDS - #error "The type file was generated with a different default_max_qty than this file" - #endif +#error "The type file was generated with a different default_max_qty than this file" +#endif -@@ -81,13 +81,13 @@ static bool encode_responses(zcbor_state_t *state, const struct responses *input - zcbor_print("%s\r\n", __func__); +@@ -90,7 +90,7 @@ static bool encode_responses( +{ + zcbor_log("%s\r\n", __func__); - bool tmp_result = -- (((zcbor_list_start_encode(state, 1234567890) && -- ((zcbor_multi_encode_minmax(1, 1234567890, &(*input)._responses__response_count, -+ (((zcbor_list_start_encode(state, DEFAULT_MAX_QTY) && -+ ((zcbor_multi_encode_minmax(1, DEFAULT_MAX_QTY, &(*input)._responses__response_count, - (zcbor_encoder_t *)encode_response, state, - (&(*input)._responses__response), - sizeof(struct response))) || - (zcbor_list_map_end_force_encode(state), false)) && -- zcbor_list_end_encode(state, 1234567890)))); -+ zcbor_list_end_encode(state, DEFAULT_MAX_QTY)))); +- bool tmp_result = (((zcbor_list_start_encode(state, 1234567890) && ((zcbor_multi_encode_minmax(1, 1234567890, &(*input).responses_response_m_count, (zcbor_encoder_t *)encode_response, state, (&(*input).responses_response_m), sizeof(struct response))) || (zcbor_list_map_end_force_encode(state), false)) && zcbor_list_end_encode(state, 1234567890)))); ++ bool tmp_result = (((zcbor_list_start_encode(state, DEFAULT_MAX_QTY) && ((zcbor_multi_encode_minmax(1, DEFAULT_MAX_QTY, &(*input).responses_response_m_count, (zcbor_encoder_t *)encode_response, state, (&(*input).responses_response_m), sizeof(struct response))) || (zcbor_list_map_end_force_encode(state), false)) && zcbor_list_end_encode(state, DEFAULT_MAX_QTY)))); - if (!tmp_result) - zcbor_trace(); + if (!tmp_result) { + zcbor_trace_file(state); diff --git a/subsys/net/lib/nrf_provisioning/nrf_provisioning_cbor_license.patch b/subsys/net/lib/nrf_provisioning/nrf_provisioning_cbor_license.patch deleted file mode 100644 index 6dde0bcddddf..000000000000 --- a/subsys/net/lib/nrf_provisioning/nrf_provisioning_cbor_license.patch +++ /dev/null @@ -1,78 +0,0 @@ -diff --git a/subsys/net/lib/nrf_provisioning/include/nrf_provisioning_cbor_decode.h b/subsys/net/lib/nrf_provisioning/include/nrf_provisioning_cbor_decode.h -index 37f0b7c8e..11e1625cc 100644 ---- a/subsys/net/lib/nrf_provisioning/include/nrf_provisioning_cbor_decode.h -+++ b/subsys/net/lib/nrf_provisioning/include/nrf_provisioning_cbor_decode.h -@@ -1,3 +1,8 @@ -+/* -+ * Copyright (c) 2023 Nordic Semiconductor ASA -+ * -+ * SPDX-License-Identifier: LicenseRef-Nordic-5-Clause -+ */ - /* - * Generated using zcbor version 0.6.0 - * https://github.com/NordicSemiconductor/zcbor -diff --git a/subsys/net/lib/nrf_provisioning/include/nrf_provisioning_cbor_decode_types.h b/subsys/net/lib/nrf_provisioning/include/nrf_provisioning_cbor_decode_types.h -index c0e3599fb..46a7f6c02 100644 ---- a/subsys/net/lib/nrf_provisioning/include/nrf_provisioning_cbor_decode_types.h -+++ b/subsys/net/lib/nrf_provisioning/include/nrf_provisioning_cbor_decode_types.h -@@ -1,3 +1,8 @@ -+/* -+ * Copyright (c) 2023 Nordic Semiconductor ASA -+ * -+ * SPDX-License-Identifier: LicenseRef-Nordic-5-Clause -+ */ - /* - * Generated using zcbor version 0.6.0 - * https://github.com/NordicSemiconductor/zcbor -diff --git a/subsys/net/lib/nrf_provisioning/include/nrf_provisioning_cbor_encode.h b/subsys/net/lib/nrf_provisioning/include/nrf_provisioning_cbor_encode.h -index 57fcfaf40..81e7639f3 100644 ---- a/subsys/net/lib/nrf_provisioning/include/nrf_provisioning_cbor_encode.h -+++ b/subsys/net/lib/nrf_provisioning/include/nrf_provisioning_cbor_encode.h -@@ -1,3 +1,8 @@ -+/* -+ * Copyright (c) 2023 Nordic Semiconductor ASA -+ * -+ * SPDX-License-Identifier: LicenseRef-Nordic-5-Clause -+ */ - /* - * Generated using zcbor version 0.6.0 - * https://github.com/NordicSemiconductor/zcbor -diff --git a/subsys/net/lib/nrf_provisioning/include/nrf_provisioning_cbor_encode_types.h b/subsys/net/lib/nrf_provisioning/include/nrf_provisioning_cbor_encode_types.h -index f3dda00ce..5fe366c01 100644 ---- a/subsys/net/lib/nrf_provisioning/include/nrf_provisioning_cbor_encode_types.h -+++ b/subsys/net/lib/nrf_provisioning/include/nrf_provisioning_cbor_encode_types.h -@@ -1,3 +1,8 @@ -+/* -+ * Copyright (c) 2023 Nordic Semiconductor ASA -+ * -+ * SPDX-License-Identifier: LicenseRef-Nordic-5-Clause -+ */ - /* - * Generated using zcbor version 0.6.0 - * https://github.com/NordicSemiconductor/zcbor -diff --git a/subsys/net/lib/nrf_provisioning/src/nrf_provisioning_cbor_decode.c b/subsys/net/lib/nrf_provisioning/src/nrf_provisioning_cbor_decode.c -index 4a738032e..2af073385 100644 ---- a/subsys/net/lib/nrf_provisioning/src/nrf_provisioning_cbor_decode.c -+++ b/subsys/net/lib/nrf_provisioning/src/nrf_provisioning_cbor_decode.c -@@ -1,3 +1,8 @@ -+/* -+ * Copyright (c) 2023 Nordic Semiconductor ASA -+ * -+ * SPDX-License-Identifier: LicenseRef-Nordic-5-Clause -+ */ - /* - * Generated using zcbor version 0.6.0 - * https://github.com/NordicSemiconductor/zcbor -diff --git a/subsys/net/lib/nrf_provisioning/src/nrf_provisioning_cbor_encode.c b/subsys/net/lib/nrf_provisioning/src/nrf_provisioning_cbor_encode.c -index ef0cb9b3c..35817df1f 100644 ---- a/subsys/net/lib/nrf_provisioning/src/nrf_provisioning_cbor_encode.c -+++ b/subsys/net/lib/nrf_provisioning/src/nrf_provisioning_cbor_encode.c -@@ -1,3 +1,8 @@ -+/* -+ * Copyright (c) 2023 Nordic Semiconductor ASA -+ * -+ * SPDX-License-Identifier: LicenseRef-Nordic-5-Clause -+ */ - /* - * Generated using zcbor version 0.6.0 - * https://github.com/NordicSemiconductor/zcbor diff --git a/subsys/net/lib/nrf_provisioning/nrf_provisioning_cbor_regenerate.sh b/subsys/net/lib/nrf_provisioning/nrf_provisioning_cbor_regenerate.sh index a98d9686e103..77e16ea417d4 100755 --- a/subsys/net/lib/nrf_provisioning/nrf_provisioning_cbor_regenerate.sh +++ b/subsys/net/lib/nrf_provisioning/nrf_provisioning_cbor_regenerate.sh @@ -7,7 +7,10 @@ zcbor code --default-max-qty 1234567890 -c nrf_provisioning_cbor.cddl \ -t responses -e \ --oc src/nrf_provisioning_cbor_encode.c \ --oh include/nrf_provisioning_cbor_encode.h \ - --oht include/nrf_provisioning_cbor_encode_types.h + --oht include/nrf_provisioning_cbor_encode_types.h \ + --file-header "Copyright (c) 2024 Nordic Semiconductor ASA + +SPDX-License-Identifier: LicenseRef-Nordic-5-Clause" if [ $? -ne 0 ]; then echo "Encoder generation failed!" @@ -18,38 +21,35 @@ zcbor code --default-max-qty CONFIG_NRF_PROVISIONING_CBOR_RECORDS -c nrf_provisi -t commands -d \ --oc src/nrf_provisioning_cbor_decode.c \ --oh include/nrf_provisioning_cbor_decode.h \ - --oht include/nrf_provisioning_cbor_decode_types.h + --oht include/nrf_provisioning_cbor_decode_types.h \ + --file-header "Copyright (c) 2024 Nordic Semiconductor ASA + +SPDX-License-Identifier: LicenseRef-Nordic-5-Clause" if [ $? -ne 0 ]; then echo "Decoder generation failed!" exit fi -# Format the generated files -clang-format -i src/nrf_provisioning_cbor*.c -clang-format -i include/nrf_provisioning_cbor*.h - -# Commit the generated files and the matching CDDL file -git add src/nrf_provisioning_cbor*.c include/nrf_provisioning_cbor*.h -git add nrf_provisioning_cbor.cddl - -# Apply required patches -git apply -3 --apply nrf_provisioning_cbor.patch +git add -A +git commit -mdummy # Add dummy commit so apply works if [ $? -ne 0 ]; then - echo "Patching failed!" + echo "dummy git commit failed!" exit fi -# Append license information -git apply -3 --apply nrf_provisioning_cbor_license.patch +# Apply required patch +git apply -3 --apply nrf_provisioning_cbor.patch if [ $? -ne 0 ]; then - echo "Appending license information failed!" + echo "Patching failed!" + git reset HEAD~1 # remove dummy commit exit fi -# Format the patches +git reset HEAD~1 # remove dummy commit + +# Format the generated files clang-format -i src/nrf_provisioning_cbor*.c clang-format -i include/nrf_provisioning_cbor*.h - diff --git a/subsys/net/lib/nrf_provisioning/src/nrf_provisioning_cbor_decode.c b/subsys/net/lib/nrf_provisioning/src/nrf_provisioning_cbor_decode.c index 07d6f4f911fb..c3b08ad9881d 100644 --- a/subsys/net/lib/nrf_provisioning/src/nrf_provisioning_cbor_decode.c +++ b/subsys/net/lib/nrf_provisioning/src/nrf_provisioning_cbor_decode.c @@ -1,10 +1,9 @@ /* - * Copyright (c) 2023 Nordic Semiconductor ASA + * Copyright (c) 2024 Nordic Semiconductor ASA * * SPDX-License-Identifier: LicenseRef-Nordic-5-Clause - */ -/* - * Generated using zcbor version 0.6.0 + * + * Generated using zcbor version 0.8.1 * https://github.com/NordicSemiconductor/zcbor * Generated with a --default-max-qty of CONFIG_NRF_PROVISIONING_CBOR_RECORDS */ @@ -15,6 +14,7 @@ #include #include "zcbor_decode.h" #include "nrf_provisioning_cbor_decode.h" +#include "zcbor_print.h" #if DEFAULT_MAX_QTY != CONFIG_NRF_PROVISIONING_CBOR_RECORDS #error "The type file was generated with a different default_max_qty than this file" @@ -29,22 +29,26 @@ static bool decode_commands(zcbor_state_t *state, struct commands *result); static bool decode_at_command(zcbor_state_t *state, struct at_command *result) { - zcbor_print("%s\r\n", __func__); + zcbor_log("%s\r\n", __func__); bool tmp_result = (((((zcbor_uint32_expect(state, (0)))) && - ((zcbor_tstr_decode(state, (&(*result)._at_command_set_command)))) && - ((zcbor_tstr_decode(state, (&(*result)._at_command_parameters)))) && + ((zcbor_tstr_decode(state, (&(*result).at_command_set_command)))) && + ((zcbor_tstr_decode(state, (&(*result).at_command_parameters)))) && ((zcbor_list_start_decode(state) && - ((zcbor_multi_decode(0, 6, &(*result)._at_command_ignore_cme_errors_uint_count, + ((zcbor_multi_decode(0, 6, &(*result).at_command_ignore_cme_errors_uint_count, (zcbor_decoder_t *)zcbor_uint32_decode, state, - (&(*result)._at_command_ignore_cme_errors_uint), + (&(*result).at_command_ignore_cme_errors_uint), sizeof(uint32_t))) || (zcbor_list_map_end_force_decode(state), false)) && zcbor_list_end_decode(state)))))); - if (!tmp_result) - zcbor_trace(); + if (!tmp_result) { + zcbor_trace_file(state); + zcbor_log("%s error: %s\r\n", __func__, zcbor_error_str(zcbor_peek_error(state))); + } else { + zcbor_log("%s success\r\n", __func__); + } return tmp_result; } @@ -52,83 +56,99 @@ static bool decode_at_command(zcbor_state_t *state, struct at_command *result) static bool decode_repeated_properties_tstrtstr(zcbor_state_t *state, struct properties_tstrtstr *result) { - zcbor_print("%s\r\n", __func__); + zcbor_log("%s\r\n", __func__); bool tmp_result = - ((((zcbor_tstr_decode(state, (&(*result)._config_properties_tstrtstr_key)))) && - (zcbor_tstr_decode(state, (&(*result)._properties_tstrtstr))))); - - if (!tmp_result) - zcbor_trace(); + ((((zcbor_tstr_decode(state, (&(*result).config_properties_tstrtstr_key)))) && + (zcbor_tstr_decode(state, (&(*result).properties_tstrtstr))))); + + if (!tmp_result) { + zcbor_trace_file(state); + zcbor_log("%s error: %s\r\n", __func__, zcbor_error_str(zcbor_peek_error(state))); + } else { + zcbor_log("%s success\r\n", __func__); + } return tmp_result; } static bool decode_config(zcbor_state_t *state, struct config *result) { - zcbor_print("%s\r\n", __func__); + zcbor_log("%s\r\n", __func__); bool tmp_result = (((((zcbor_uint32_expect(state, (1)))) && ((zcbor_map_start_decode(state) && - ((zcbor_multi_decode(0, 100, &(*result)._properties_tstrtstr_count, + ((zcbor_multi_decode(0, 100, &(*result).properties_tstrtstr_count, (zcbor_decoder_t *)decode_repeated_properties_tstrtstr, - state, (&(*result)._properties_tstrtstr), + state, (&(*result).properties_tstrtstr), sizeof(struct properties_tstrtstr))) || (zcbor_list_map_end_force_decode(state), false)) && zcbor_map_end_decode(state)))))); - if (!tmp_result) - zcbor_trace(); + if (!tmp_result) { + zcbor_trace_file(state); + zcbor_log("%s error: %s\r\n", __func__, zcbor_error_str(zcbor_peek_error(state))); + } else { + zcbor_log("%s success\r\n", __func__); + } return tmp_result; } static bool decode_command(zcbor_state_t *state, struct command *result) { - zcbor_print("%s\r\n", __func__); + zcbor_log("%s\r\n", __func__); bool int_res; bool tmp_result = (( (zcbor_list_start_decode(state) && - ((((zcbor_tstr_decode(state, (&(*result)._command__correlation)))) && + ((((zcbor_tstr_decode(state, (&(*result).command_correlation_m)))) && ((zcbor_union_start_code(state) && (int_res = ((((decode_at_command(state, - (&(*result)._command_union__at_command)))) && - (((*result)._command_union_choice = _command_union__at_command), + (&(*result).command_union_at_command_m)))) && + (((*result).command_union_choice = command_union_at_command_m_c), true)) || (zcbor_union_elem_code(state) && - (((decode_config(state, (&(*result)._command_union__config)))) && - (((*result)._command_union_choice = _command_union__config), + (((decode_config(state, (&(*result).command_union_config_m)))) && + (((*result).command_union_choice = command_union_config_m_c), true))) || (((zcbor_uint32_expect_union(state, (2)))) && - (((*result)._command_union_choice = _command_union__finished), + (((*result).command_union_choice = command_union_finished_m_c), true))), zcbor_union_end_code(state), int_res)))) || (zcbor_list_map_end_force_decode(state), false)) && zcbor_list_end_decode(state)))); - if (!tmp_result) - zcbor_trace(); + if (!tmp_result) { + zcbor_trace_file(state); + zcbor_log("%s error: %s\r\n", __func__, zcbor_error_str(zcbor_peek_error(state))); + } else { + zcbor_log("%s success\r\n", __func__); + } return tmp_result; } static bool decode_commands(zcbor_state_t *state, struct commands *result) { - zcbor_print("%s\r\n", __func__); + zcbor_log("%s\r\n", __func__); bool tmp_result = (((zcbor_list_start_decode(state) && ((zcbor_multi_decode(1, CONFIG_NRF_PROVISIONING_CBOR_RECORDS, - &(*result)._commands__command_count, + &(*result).commands_command_m_count, (zcbor_decoder_t *)decode_command, state, - (&(*result)._commands__command), sizeof(struct command))) || + (&(*result).commands_command_m), sizeof(struct command))) || (zcbor_list_map_end_force_decode(state), false)) && zcbor_list_end_decode(state)))); - if (!tmp_result) - zcbor_trace(); + if (!tmp_result) { + zcbor_trace_file(state); + zcbor_log("%s error: %s\r\n", __func__, zcbor_error_str(zcbor_peek_error(state))); + } else { + zcbor_log("%s success\r\n", __func__); + } return tmp_result; } @@ -138,19 +158,7 @@ int cbor_decode_commands(const uint8_t *payload, size_t payload_len, struct comm { zcbor_state_t states[6]; - zcbor_new_state(states, sizeof(states) / sizeof(zcbor_state_t), payload, payload_len, 1); - - bool ret = decode_commands(states, result); - - if (ret && (payload_len_out != NULL)) { - *payload_len_out = MIN(payload_len, (size_t)states[0].payload - (size_t)payload); - } - - if (!ret) { - int err = zcbor_pop_error(states); - - zcbor_print("Return error: %d\r\n", err); - return (err == ZCBOR_SUCCESS) ? ZCBOR_ERR_UNKNOWN : err; - } - return ZCBOR_SUCCESS; + return zcbor_entry_function(payload, payload_len, (void *)result, payload_len_out, states, + (zcbor_decoder_t *)decode_commands, + sizeof(states) / sizeof(zcbor_state_t), 1); } diff --git a/subsys/net/lib/nrf_provisioning/src/nrf_provisioning_cbor_encode.c b/subsys/net/lib/nrf_provisioning/src/nrf_provisioning_cbor_encode.c index e074f8dd65ad..7c5921f58e0c 100644 --- a/subsys/net/lib/nrf_provisioning/src/nrf_provisioning_cbor_encode.c +++ b/subsys/net/lib/nrf_provisioning/src/nrf_provisioning_cbor_encode.c @@ -1,10 +1,9 @@ /* - * Copyright (c) 2023 Nordic Semiconductor ASA + * Copyright (c) 2024 Nordic Semiconductor ASA * * SPDX-License-Identifier: LicenseRef-Nordic-5-Clause - */ -/* - * Generated using zcbor version 0.6.0 + * + * Generated using zcbor version 0.8.1 * https://github.com/NordicSemiconductor/zcbor * Generated with a --default-max-qty of 1234567890 */ @@ -15,6 +14,7 @@ #include #include "zcbor_encode.h" #include "nrf_provisioning_cbor_encode.h" +#include "zcbor_print.h" #if DEFAULT_MAX_QTY != CONFIG_NRF_PROVISIONING_CBOR_RECORDS #error "The type file was generated with a different default_max_qty than this file" @@ -27,76 +27,90 @@ static bool encode_responses(zcbor_state_t *state, const struct responses *input static bool encode_error_response(zcbor_state_t *state, const struct error_response *input) { - zcbor_print("%s\r\n", __func__); + zcbor_log("%s\r\n", __func__); - bool tmp_result = - (((((zcbor_uint32_put(state, (99)))) && - ((zcbor_uint32_encode(state, (&(*input)._error_response_cme_error)))) && - ((zcbor_tstr_encode(state, (&(*input)._error_response_message))))))); + bool tmp_result = (((((zcbor_uint32_put(state, (99)))) && + ((zcbor_uint32_encode(state, (&(*input).error_response_cme_error)))) && + ((zcbor_tstr_encode(state, (&(*input).error_response_message))))))); - if (!tmp_result) - zcbor_trace(); + if (!tmp_result) { + zcbor_trace_file(state); + zcbor_log("%s error: %s\r\n", __func__, zcbor_error_str(zcbor_peek_error(state))); + } else { + zcbor_log("%s success\r\n", __func__); + } return tmp_result; } static bool encode_at_response(zcbor_state_t *state, const struct at_response *input) { - zcbor_print("%s\r\n", __func__); + zcbor_log("%s\r\n", __func__); bool tmp_result = (((((zcbor_uint32_put(state, (100)))) && - ((zcbor_tstr_encode(state, (&(*input)._at_response_message))))))); + ((zcbor_tstr_encode(state, (&(*input).at_response_message))))))); - if (!tmp_result) - zcbor_trace(); + if (!tmp_result) { + zcbor_trace_file(state); + zcbor_log("%s error: %s\r\n", __func__, zcbor_error_str(zcbor_peek_error(state))); + } else { + zcbor_log("%s success\r\n", __func__); + } return tmp_result; } static bool encode_response(zcbor_state_t *state, const struct response *input) { - zcbor_print("%s\r\n", __func__); - - bool tmp_result = - (((zcbor_list_start_encode(state, 4) && - ((((zcbor_tstr_encode(state, (&(*input)._response__correlation)))) && - ((((*input)._response_union_choice == _response_union__error_response) ? - ((encode_error_response( - state, (&(*input)._response_union__error_response)))) : - (((*input)._response_union_choice == _response_union__at_response) ? - ((encode_at_response( - state, (&(*input)._response_union__at_response)))) : - (((*input)._response_union_choice == - _response_union__config_ack) ? - ((zcbor_uint32_put(state, (101)))) : - (((*input)._response_union_choice == - _response_union__finished_ack) ? - ((zcbor_uint32_put(state, (102)))) : - false)))))) || - (zcbor_list_map_end_force_encode(state), false)) && - zcbor_list_end_encode(state, 4)))); - - if (!tmp_result) - zcbor_trace(); + zcbor_log("%s\r\n", __func__); + + bool tmp_result = (( + (zcbor_list_start_encode(state, 4) && + ((((zcbor_tstr_encode(state, (&(*input).response_correlation_m)))) && + ((((*input).response_union_choice == response_union_error_response_m_c) + ? ((encode_error_response( + state, (&(*input).response_union_error_response_m)))) + : (((*input).response_union_choice == response_union_at_response_m_c) + ? ((encode_at_response( + state, (&(*input).response_union_at_response_m)))) + : (((*input).response_union_choice == + response_union_config_ack_m_c) + ? ((zcbor_uint32_put(state, (101)))) + : (((*input).response_union_choice == + response_union_finished_ack_m_c) + ? ((zcbor_uint32_put(state, (102)))) + : false)))))) || + (zcbor_list_map_end_force_encode(state), false)) && + zcbor_list_end_encode(state, 4)))); + + if (!tmp_result) { + zcbor_trace_file(state); + zcbor_log("%s error: %s\r\n", __func__, zcbor_error_str(zcbor_peek_error(state))); + } else { + zcbor_log("%s success\r\n", __func__); + } return tmp_result; } static bool encode_responses(zcbor_state_t *state, const struct responses *input) { - zcbor_print("%s\r\n", __func__); + zcbor_log("%s\r\n", __func__); - bool tmp_result = - (((zcbor_list_start_encode(state, DEFAULT_MAX_QTY) && + bool tmp_result = (((zcbor_list_start_encode(state, DEFAULT_MAX_QTY) && ((zcbor_multi_encode_minmax( - 1, DEFAULT_MAX_QTY, &(*input)._responses__response_count, + 1, DEFAULT_MAX_QTY, &(*input).responses_response_m_count, (zcbor_encoder_t *)encode_response, state, - (&(*input)._responses__response), sizeof(struct response))) || + (&(*input).responses_response_m), sizeof(struct response))) || (zcbor_list_map_end_force_encode(state), false)) && zcbor_list_end_encode(state, DEFAULT_MAX_QTY)))); - if (!tmp_result) - zcbor_trace(); + if (!tmp_result) { + zcbor_trace_file(state); + zcbor_log("%s error: %s\r\n", __func__, zcbor_error_str(zcbor_peek_error(state))); + } else { + zcbor_log("%s success\r\n", __func__); + } return tmp_result; } @@ -106,19 +120,7 @@ int cbor_encode_responses(uint8_t *payload, size_t payload_len, const struct res { zcbor_state_t states[5]; - zcbor_new_state(states, sizeof(states) / sizeof(zcbor_state_t), payload, payload_len, 1); - - bool ret = encode_responses(states, input); - - if (ret && (payload_len_out != NULL)) { - *payload_len_out = MIN(payload_len, (size_t)states[0].payload - (size_t)payload); - } - - if (!ret) { - int err = zcbor_pop_error(states); - - zcbor_print("Return error: %d\r\n", err); - return (err == ZCBOR_SUCCESS) ? ZCBOR_ERR_UNKNOWN : err; - } - return ZCBOR_SUCCESS; + return zcbor_entry_function(payload, payload_len, (void *)input, payload_len_out, states, + (zcbor_decoder_t *)encode_responses, + sizeof(states) / sizeof(zcbor_state_t), 1); } diff --git a/subsys/net/lib/nrf_provisioning/src/nrf_provisioning_codec.c b/subsys/net/lib/nrf_provisioning/src/nrf_provisioning_codec.c index 3ce4c9866ad6..c8353045e16e 100644 --- a/subsys/net/lib/nrf_provisioning/src/nrf_provisioning_codec.c +++ b/subsys/net/lib/nrf_provisioning/src/nrf_provisioning_codec.c @@ -30,13 +30,13 @@ LOG_MODULE_REGISTER(nrf_provisioning_codec, CONFIG_NRF_PROVISIONING_LOG_LEVEL); #define CDC_OPKT_SZ_PTR(ctx) (&(ctx)->opkt_sz) #define CDC_IFMT_DATA_PTR(ctx) ((struct cdc_in_fmt_data *)(ctx)->i_data) -#define CDC_IFMT_CMD_I_GET(ctx, i) (&(CDC_IFMT_DATA_PTR(ctx))->cmds._commands__command[(i)]) +#define CDC_IFMT_CMD_I_GET(ctx, i) (&(CDC_IFMT_DATA_PTR(ctx))->cmds.commands_command_m[(i)]) #define CDC_OFMT_DATA_PTR(ctx) ((struct cdc_out_fmt_data *)(ctx)->o_data) #define CDC_OFMT_RESPONSES_GET(ctx) (&CDC_OFMT_DATA_PTR(ctx)->rsps) #define CDC_OFMT_RESPONSE_CONSUME(ofd) \ - (&((ofd)->rsps._responses__response[(ofd)->rsps._responses__response_count++])) + (&((ofd)->rsps.responses_response_m[(ofd)->rsps.responses_response_m_count++])) #define AT_RESP_MAX_SIZE 4096 @@ -105,7 +105,7 @@ int nrf_provisioning_codec_teardown(void) static int fmt_range_check(struct cdc_out_fmt_data *fd) { - if (fd->rsps._responses__response_count >= CONFIG_NRF_PROVISIONING_CBOR_RECORDS) { + if (fd->rsps.responses_response_m_count >= CONFIG_NRF_PROVISIONING_CBOR_RECORDS) { LOG_ERR("CONFIG_NRF_PROVISIONING_CBOR_RECORDS too small"); return -ENOMEM; } @@ -123,8 +123,8 @@ static int put_finished_resp(struct command *cmd_req, struct cdc_out_fmt_data *o struct response *rsp = CDC_OFMT_RESPONSE_CONSUME(out); - rsp->_response_union_choice = _response_union__finished_ack; - rsp->_response__correlation = cmd_req->_command__correlation; + rsp->response_union_choice = response_union_finished_ack_m_c; + rsp->response_correlation_m = cmd_req->command_correlation_m; return 0; } @@ -139,10 +139,10 @@ static int put_at_resp(struct command *cmd_req, struct cdc_out_fmt_data *out, co struct response *rsp = CDC_OFMT_RESPONSE_CONSUME(out); - rsp->_response__correlation = cmd_req->_command__correlation; - rsp->_response_union_choice = _response_union__at_response; - rsp->_response_union__at_response._at_response_message.value = msg; - rsp->_response_union__at_response._at_response_message.len = strlen(msg); + rsp->response_correlation_m = cmd_req->command_correlation_m; + rsp->response_union_choice = response_union_at_response_m_c; + rsp->response_union_at_response_m.at_response_message.value = msg; + rsp->response_union_at_response_m.at_response_message.len = strlen(msg); return 0; } @@ -157,8 +157,8 @@ static int put_config_resp(struct command *cmd_req, struct cdc_out_fmt_data *out struct response *rsp = CDC_OFMT_RESPONSE_CONSUME(out); - rsp->_response__correlation = cmd_req->_command__correlation; - rsp->_response_union_choice = _response_union__config_ack; + rsp->response_correlation_m = cmd_req->command_correlation_m; + rsp->response_union_choice = response_union_config_ack_m_c; return 0; } @@ -177,11 +177,11 @@ static int put_err_resp(struct command *cmd_req, struct cdc_out_fmt_data *out, struct response *rsp = CDC_OFMT_RESPONSE_CONSUME(out); - rsp->_response__correlation = cmd_req->_command__correlation; - rsp->_response_union_choice = _response_union__error_response; - rsp->_response_union__error_response._error_response_cme_error = cme_error; - rsp->_response_union__error_response._error_response_message.value = msg; - rsp->_response_union__error_response._error_response_message.len = strlen(msg); + rsp->response_correlation_m = cmd_req->command_correlation_m; + rsp->response_union_choice = response_union_error_response_m_c; + rsp->response_union_error_response_m.error_response_cme_error = cme_error; + rsp->response_union_error_response_m.error_response_message.value = msg; + rsp->response_union_error_response_m.error_response_message.len = strlen(msg); return 0; } @@ -220,7 +220,7 @@ static int form_at_str(struct command *cmd_req, char *cmd, size_t cmd_sz) slen += ret; ret = charseq2cstr(cmd + slen, - &cmd_req->_command_union__at_command._at_command_set_command, + &cmd_req->command_union_at_command_m.at_command_set_command, cmd_sz - slen); if (ret < 0) { goto out; @@ -235,7 +235,7 @@ static int form_at_str(struct command *cmd_req, char *cmd, size_t cmd_sz) slen += ret; ret = charseq2cstr(cmd + strlen(cmd), - &cmd_req->_command_union__at_command._at_command_parameters, + &cmd_req->command_union_at_command_m.at_command_parameters, cmd_sz - slen); if (ret < 0) { goto out; @@ -254,10 +254,10 @@ int filter_cme_error(struct command *cmd, int cme_error) { bool filtered = false; - struct at_command *at_cmd = &cmd->_command_union__at_command; + struct at_command *at_cmd = &cmd->command_union_at_command_m; - for (int i = 0; i < at_cmd->_at_command_ignore_cme_errors_uint_count; i++) { - if (at_cmd->_at_command_ignore_cme_errors_uint[i] == cme_error) { + for (int i = 0; i < at_cmd->at_command_ignore_cme_errors_uint_count; i++) { + if (at_cmd->at_command_ignore_cme_errors_uint[i] == cme_error) { LOG_DBG("Filtered CME error %d", cme_error); filtered = true; } @@ -348,7 +348,7 @@ static int exec_at_cmd(struct command *cmd_req, struct cdc_out_fmt_data *out) static int write_config(struct command *cmd_req, struct cdc_out_fmt_data *out) { - struct config *aconf = &cmd_req->_command_union__config; + struct config *aconf = &cmd_req->command_union_config_m; int max_key_sz = 1; int max_value_sz = 1; struct properties_tstrtstr *pair; @@ -360,11 +360,11 @@ static int write_config(struct command *cmd_req, struct cdc_out_fmt_data *out) size_t resp_sz = CONFIG_NRF_PROVISIONING_CODEC_RX_SZ_START; /* Figure out the max key and value legths */ - for (int i = 0; i < aconf->_properties_tstrtstr_count; i++) { - pair = &aconf->_properties_tstrtstr[i]; + for (int i = 0; i < aconf->properties_tstrtstr_count; i++) { + pair = &aconf->properties_tstrtstr[i]; - max_key_sz = MAX(max_key_sz, pair->_config_properties_tstrtstr_key.len + 1); - max_value_sz = MAX(max_value_sz, pair->_properties_tstrtstr.len + 1); + max_key_sz = MAX(max_key_sz, pair->config_properties_tstrtstr_key.len + 1); + max_value_sz = MAX(max_value_sz, pair->properties_tstrtstr.len + 1); } key = k_malloc(max_key_sz); @@ -385,19 +385,19 @@ static int write_config(struct command *cmd_req, struct cdc_out_fmt_data *out) goto exit; } - LOG_DBG("Storing %d key-value pair/s", aconf->_properties_tstrtstr_count); + LOG_DBG("Storing %d key-value pair/s", aconf->properties_tstrtstr_count); - for (int i = 0; i < aconf->_properties_tstrtstr_count; i++) { - pair = &aconf->_properties_tstrtstr[i]; + for (int i = 0; i < aconf->properties_tstrtstr_count; i++) { + pair = &aconf->properties_tstrtstr[i]; - ret = charseq2cstr(key, &pair->_config_properties_tstrtstr_key, max_key_sz); + ret = charseq2cstr(key, &pair->config_properties_tstrtstr_key, max_key_sz); if (ret < 0) { LOG_WRN("Unable to store key: %s; err: %d", key, ret); snprintk(resp, resp_sz, "key [%d](0-indexed) too big", i); goto exit; } - ret = charseq2cstr(value, &pair->_properties_tstrtstr, max_value_sz); + ret = charseq2cstr(value, &pair->properties_tstrtstr, max_value_sz); if (ret < 0) { LOG_WRN("Unable to store value: %s; err: %d", value, ret); snprintk(resp, resp_sz, "value [%d](0-indexed) too big", i); @@ -485,21 +485,21 @@ int nrf_provisioning_codec_process_commands(void) cmee_orig = nrf_provisioning_at_cmee_enable(); - LOG_DBG("Received %d commands, size %d", ifd->cmds._commands__command_count, + LOG_DBG("Received %d commands, size %d", ifd->cmds.commands_command_m_count, cctx->i_data_sz); - for (int i = 0; i < ifd->cmds._commands__command_count; i++) { + for (int i = 0; i < ifd->cmds.commands_command_m_count; i++) { /* Stop immediately processing if any command has failed */ if (ofd->errors) { goto stop_provisioning; } - switch (CDC_IFMT_CMD_I_GET(cctx, i)->_command_union_choice) { - case _command_union__finished: + switch (CDC_IFMT_CMD_I_GET(cctx, i)->command_union_choice) { + case command_union_finished_m_c: fpos = i; /* Defer writing FINISHED until we know if we have errors */ break; - case _command_union__at_command: + case command_union_at_command_m_c: mret = mm.cb(LTE_LC_FUNC_MODE_OFFLINE, mm.user_data); if (mret < 0) { goto stop_provisioning; @@ -510,7 +510,7 @@ int nrf_provisioning_codec_process_commands(void) goto stop_provisioning; } break; - case _command_union__config: + case command_union_config_m_c: ret = write_config(CDC_IFMT_CMD_I_GET(cctx, i), cctx->o_data); if (ret < 0) { goto stop_provisioning; @@ -524,10 +524,10 @@ int nrf_provisioning_codec_process_commands(void) /* Mark as the latest successful provisioning command */ memcpy(nrf_provisioning_latest_corr_id, - CDC_IFMT_CMD_I_GET(cctx, i)->_command__correlation.value, - CDC_IFMT_CMD_I_GET(cctx, i)->_command__correlation.len); + CDC_IFMT_CMD_I_GET(cctx, i)->command_correlation_m.value, + CDC_IFMT_CMD_I_GET(cctx, i)->command_correlation_m.len); nrf_provisioning_latest_corr_id[ - CDC_IFMT_CMD_I_GET(cctx, i)->_command__correlation.len] = '\0'; + CDC_IFMT_CMD_I_GET(cctx, i)->command_correlation_m.len] = '\0'; } stop_provisioning: diff --git a/tests/modules/lib/zcbor/decode/src/main.c b/tests/modules/lib/zcbor/decode/src/main.c index 4998a7694890..2dc94381cbb3 100644 --- a/tests/modules/lib/zcbor/decode/src/main.c +++ b/tests/modules/lib/zcbor/decode/src/main.c @@ -20,13 +20,13 @@ ZTEST(lib_zcbor_test1, test_decode) int int_res; /* Initialize struct to ensure test isn't checking uninitialized pointers */ - test._Test_name_tstr[0] = (struct zcbor_string){NULL, 0}; - test._Test_name_tstr[1] = (struct zcbor_string){NULL, 0}; + test.Test_name_tstr[0] = (struct zcbor_string){NULL, 0}; + test.Test_name_tstr[1] = (struct zcbor_string){NULL, 0}; res = zcbor_list_start_encode(states, 3); res |= zcbor_list_start_encode(states, 2); - res |= zcbor_tstr_put_term(states, "Foo"); - res |= zcbor_tstr_put_term(states, "Bar"); + res |= zcbor_tstr_put_lit(states, "Foo"); + res |= zcbor_tstr_put_lit(states, "Bar"); res |= zcbor_list_end_encode(states, 0); res |= zcbor_bstr_put_arr(states, time); res |= zcbor_int32_put(states, 2); @@ -39,8 +39,8 @@ ZTEST(lib_zcbor_test1, test_decode) zassert_equal(ZCBOR_SUCCESS, int_res, "Decoding should have been successful\n"); - zassert_mem_equal(test._Test_name_tstr[0].value, "Foo", test._Test_name_tstr[0].len, NULL); - zassert_mem_equal(test._Test_name_tstr[1].value, "Bar", test._Test_name_tstr[1].len, NULL); + zassert_mem_equal(test.Test_name_tstr[0].value, "Foo", test.Test_name_tstr[0].len, NULL); + zassert_mem_equal(test.Test_name_tstr[1].value, "Bar", test.Test_name_tstr[1].len, NULL); } ZTEST_SUITE(lib_zcbor_test1, NULL, NULL, NULL, NULL, NULL); diff --git a/tests/modules/lib/zcbor/encode/src/main.c b/tests/modules/lib/zcbor/encode/src/main.c index 052193cf8858..9d5350ce9ca7 100644 --- a/tests/modules/lib/zcbor/encode/src/main.c +++ b/tests/modules/lib/zcbor/encode/src/main.c @@ -15,13 +15,13 @@ ZTEST(lib_zcbor_test, test_encode) uint8_t last_name[] = "Bar"; uint8_t time[] = {1, 2, 3, 4, 5, 6, 7, 8}; struct Test test = { - ._Test_name_tstr = { + .Test_name_tstr = { {.value = first_name, .len = sizeof(first_name) - 1}, {.value = last_name, .len = sizeof(last_name) - 1}, }, - ._Test_name_tstr_count = 2, - ._Test_timestamp = {.value = time, .len = sizeof(time)}, - ._Test_types_choice = _Test_types_something, + .Test_name_tstr_count = 2, + .Test_timestamp = {.value = time, .len = sizeof(time)}, + .Test_types_choice = Test_types_something_c, }; int res = cbor_encode_Test(payload, sizeof(payload), &test, &payload_len); diff --git a/tests/modules/lib/zcbor/raw_encode/src/main.c b/tests/modules/lib/zcbor/raw_encode/src/main.c index fcbc538d8f87..4acd730179ce 100644 --- a/tests/modules/lib/zcbor/raw_encode/src/main.c +++ b/tests/modules/lib/zcbor/raw_encode/src/main.c @@ -16,8 +16,8 @@ ZTEST(lib_zcbor_test3, test_raw_encode) res = zcbor_list_start_encode(states, 3); res |= zcbor_list_start_encode(states, 2); - res |= zcbor_tstr_put_term(states, "Foo"); - res |= zcbor_tstr_put_term(states, "Bar"); + res |= zcbor_tstr_put_lit(states, "Foo"); + res |= zcbor_tstr_put_lit(states, "Bar"); res |= zcbor_list_end_encode(states, 0); res |= zcbor_bstr_put_arr(states, time); res |= zcbor_int32_put(states, 2); diff --git a/tests/subsys/dfu/dfu_target/smp/src/img_gr_stub.c b/tests/subsys/dfu/dfu_target/smp/src/img_gr_stub.c index a19be4e83077..0905a7c90c4d 100644 --- a/tests/subsys/dfu/dfu_target/smp/src/img_gr_stub.c +++ b/tests/subsys/dfu/dfu_target/smp/src/img_gr_stub.c @@ -120,9 +120,9 @@ void img_read_response(int count) zcbor_tstr_put_lit(zse, "slot") && zcbor_uint32_put(zse, image_dummy_info[i].slot_num) && zcbor_tstr_put_lit(zse, "version") && - zcbor_tstr_put_term(zse, image_dummy_info[i].version) && - - zcbor_tstr_put_term(zse, "hash") && + zcbor_tstr_put_term(zse, image_dummy_info[i].version, + sizeof(image_dummy_info[i].version)) && + zcbor_tstr_put_lit(zse, "hash") && zcbor_bstr_encode_ptr(zse, image_dummy_info[i].hash, IMG_MGMT_DATA_SHA_LEN) && ZCBOR_ENCODE_FLAG(zse, "bootable", image_dummy_info[i].flags.bootable) && ZCBOR_ENCODE_FLAG(zse, "pending", image_dummy_info[i].flags.pending) && @@ -196,7 +196,8 @@ void img_state_write_verify(struct net_buf *nb) ZCBOR_MAP_DECODE_KEY_DECODER("hash", zcbor_bstr_decode, &hash) }; - zcbor_new_decode_state(zsd, ARRAY_SIZE(zsd), nb->data + sizeof(struct smp_hdr), nb->len, 1); + zcbor_new_decode_state(zsd, ARRAY_SIZE(zsd), nb->data + sizeof(struct smp_hdr), nb->len, 1, + NULL, 0); decoded = 0; /* Init buffer values */ @@ -247,7 +248,8 @@ void img_upload_init_verify(struct net_buf *nb) ZCBOR_MAP_DECODE_KEY_DECODER("sha", zcbor_bstr_decode, &sha) }; - zcbor_new_decode_state(zsd, ARRAY_SIZE(zsd), nb->data + sizeof(struct smp_hdr), nb->len, 1); + zcbor_new_decode_state(zsd, ARRAY_SIZE(zsd), nb->data + sizeof(struct smp_hdr), nb->len, 1, + NULL, 0); decoded = 0; /* Init buffer values */ diff --git a/tests/subsys/dfu/dfu_target/smp/src/os_gr_stub.c b/tests/subsys/dfu/dfu_target/smp/src/os_gr_stub.c index d68bc970ed6c..7381b15179d2 100644 --- a/tests/subsys/dfu/dfu_target/smp/src/os_gr_stub.c +++ b/tests/subsys/dfu/dfu_target/smp/src/os_gr_stub.c @@ -81,7 +81,8 @@ void os_echo_verify(struct net_buf *nb) ZCBOR_MAP_DECODE_KEY_DECODER("d", zcbor_tstr_decode, &echo_data) }; - zcbor_new_decode_state(zsd, ARRAY_SIZE(zsd), nb->data + sizeof(struct smp_hdr), nb->len, 1); + zcbor_new_decode_state(zsd, ARRAY_SIZE(zsd), nb->data + sizeof(struct smp_hdr), nb->len, 1, + NULL, 0); echo_data.len = 0; rc = zcbor_map_decode_bulk(zsd, list_res_decode, ARRAY_SIZE(list_res_decode), &decoded); diff --git a/west.yml b/west.yml index 3cbde3ed2e62..7166c4c91528 100644 --- a/west.yml +++ b/west.yml @@ -61,7 +61,7 @@ manifest: # https://developer.nordicsemi.com/nRF_Connect_SDK/doc/latest/zephyr/guides/modules.html - name: zephyr repo-path: sdk-zephyr - revision: ea1fd932d014b49f27482463ce291b5697df9b38 + revision: c5c7fb3967905dcaef1035ac8d5b234176a2cc0a import: # In addition to the zephyr repository itself, NCS also # imports the contents of zephyr/west.yml at the above @@ -129,7 +129,7 @@ manifest: compare-by-default: true - name: mcuboot repo-path: sdk-mcuboot - revision: 3fe867f113215074b586d4a58164ae72cefbb3f8 + revision: 55a0f64dbdbead3b8a9120af6e23f20e3521a37a path: bootloader/mcuboot - name: qcbor url: https://github.com/laurencelundblade/QCBOR.git @@ -142,7 +142,7 @@ manifest: - name: nrfxlib repo-path: sdk-nrfxlib path: nrfxlib - revision: 3cfb84ef2ecbfaa0b5dcdefa94cf51c65647780f + revision: d80b51a1e198ea984612b884545ee7aae2325629 - name: trusted-firmware-m repo-path: sdk-trusted-firmware-m path: modules/tee/tf-m/trusted-firmware-m @@ -154,7 +154,7 @@ manifest: - name: matter repo-path: sdk-connectedhomeip path: modules/lib/matter - revision: c36fcaf148cf12d28a4e7a976a8aef9727ee73f1 + revision: a4d48b7c8b55cbe6c27665cd90e33ceba2e78615 submodules: - name: nlio path: third_party/nlio/repo @@ -196,7 +196,7 @@ manifest: compare-by-default: false - name: sidewalk repo-path: sdk-sidewalk - revision: 08d999c83a5776e77c466aa824324dbaab1fafed + revision: 389f338df3ae0026319aef6a920bf112d5af866a groups: - sidewalk - name: find-my