Skip to content

modules: main: Add CDDL CBOR encoding of device shadow#117

Merged
jtguggedal merged 1 commit intomainfrom
decodeincomingmdata
Mar 18, 2025
Merged

modules: main: Add CDDL CBOR encoding of device shadow#117
jtguggedal merged 1 commit intomainfrom
decodeincomingmdata

Conversation

@simensrostad
Copy link
Copy Markdown
Contributor

Add missing CDDL CBOR decoding of incoming data.
Used to decode update interval set in cloud.

Copy link
Copy Markdown
Contributor

@github-actions github-actions bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🎯 Core Changes

  • The main purpose of this PR is to integrate CDDL CBOR decoding for incoming data, specifically to decode the update interval set in the cloud.
  • Added zcbor command in CMakeLists.txt to generate encoder code using a CDDL file.
  • Updated cbor_helper.c to decode CBOR data and extract the update interval.
  • Modified the test suite to include tests for the new CBOR decoding functionality.

⚠️ Concerns

  • No critical concerns identified. The changes appear to be well-integrated and tested.

Verdict:

  • Approve: The changes are well-structured, and the added functionality is covered by tests. The integration of CBOR decoding is a necessary enhancement for handling cloud data efficiently.

Code review performed by OPENAI - gpt-4o.

# generated code and the necessary zcbor C code files.
include(${CMAKE_CURRENT_BINARY_DIR}/device_shadow.cmake)

# Ensure that the cmake reconfiguration is triggerred everytime the cddl file changes.
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Typo: 'triggerred' should be 'triggered'.


int err = cbor_decode_config_object(cbor, len, &object, &not_used);

if (err) {
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Consider adding error logging for cbor_decode_config_object to provide more context in case of failure.

static void send_config(uint64_t interval)
static void twelve_hour_interval_set(void)
{
// MISSING: set interval for 12 hours, or even different intervals.
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The comment mentions a missing feature to set different intervals. Consider implementing this to enhance test coverage.

Copy link
Copy Markdown
Contributor

@github-actions github-actions bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🎯 Core Changes

  • The primary goal of this PR is to integrate CDDL CBOR decoding for incoming data, particularly to decode the update interval set in the cloud. This involves generating encoder code using zcbor and updating the CMakeLists to include the necessary steps for code generation and linking.
  • The cbor_helper.c file has been updated to include decoding logic using the cbor_decode_config_object function, replacing the previous hardcoded interval.
  • The device_shadow.cddl file has been simplified to focus on the config-object with an update_interval field.
  • The state machine in main.c has been adjusted to handle the decoded update interval and manage state transitions accordingly.
  • Additional test cases and utility functions have been added to ensure the correct behavior of the CBOR decoding and state transitions.

⚠️ Concerns

  • There is a potential risk of symbol name collisions due to the use of --short-names in the zcbor command.
  1. Verdict:
    • Approve: The changes introduce necessary functionality for CBOR decoding and are well-integrated into the existing codebase. The updates include comprehensive test coverage to ensure reliability.

Code review performed by OPENAI - gpt-4o.

Add missing CDDL CBOR decoding of incoming data.
Used to decode update interval set in cloud.

Tests are updated to check new configuration, in addition
to using some convenience functions for expected events.

Signed-off-by: Simen S. Røstad <simen.rostad@nordicsemi.no>
@jtguggedal jtguggedal force-pushed the decodeincomingmdata branch from d1334dd to cd935f0 Compare March 18, 2025 17:12
@sonarqubecloud
Copy link
Copy Markdown

@jtguggedal jtguggedal merged commit 26543a4 into main Mar 18, 2025
4 checks passed
@jtguggedal jtguggedal deleted the decodeincomingmdata branch March 18, 2025 17:17
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants