Skip to content

Add classes for standard cbor encoders/decoders #33

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 1 commit into
base: main
Choose a base branch
from

Conversation

fabik111
Copy link
Collaborator

@fabik111 fabik111 commented Jun 4, 2025

Changes

  • Add class structures for standard common cbor encoder and decoders
  • Add a cbor encoder for WiFi FW Version

Copy link

codecov bot commented Jun 4, 2025

Codecov Report

Attention: Patch coverage is 72.72727% with 3 lines in your changes missing coverage. Please review.

Project coverage is 30.21%. Comparing base (4db4576) to head (4e40624).

Files with missing lines Patch % Lines
src/cbor/standards/StandardEncoders.cpp 66.66% 3 Missing ⚠️
Additional details and impacted files
@@            Coverage Diff             @@
##             main      #33      +/-   ##
==========================================
+ Coverage   29.85%   30.21%   +0.36%     
==========================================
  Files          27       29       +2     
  Lines        1819     1830      +11     
==========================================
+ Hits          543      553      +10     
- Misses       1276     1277       +1     

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.

Copy link

github-actions bot commented Jun 4, 2025

Memory usage change @ 4e40624

Board flash % RAM for global variables %
arduino:esp32:nano_nora 🔺 +172 - +2608 +0.01 - +0.08 🔺 +24 - +76 +0.01 - +0.02
arduino:mbed_edge:edge_control 🔺 +152 - +6400 +0.02 - +0.65 🔺 +32 - +56 +0.01 - +0.02
arduino:mbed_giga:giga 🔺 +152 - +4792 +0.01 - +0.24 🔺 +40 - +56 +0.01 - +0.01
arduino:mbed_nano:nanorp2040connect 🔺 +160 - +1350 0.0 - +0.01 🔺 +28 - +52 +0.01 - +0.02
arduino:mbed_nicla:nicla_vision 🔺 +160 - +4784 +0.01 - +0.24 🔺 +40 - +56 +0.01 - +0.01
arduino:mbed_opta:opta 🔺 +160 - +4792 +0.01 - +0.24 🔺 +40 - +56 +0.01 - +0.01
arduino:mbed_portenta:envie_m7 N/A N/A N/A N/A
arduino:renesas_portenta:portenta_c33 🔺 +144 - +1584 +0.01 - +0.08 🔺 +32 - +56 +0.01 - +0.01
arduino:renesas_uno:unor4wifi 🔺 +148 - +1372 +0.06 - +0.52 🔺 +32 - +52 +0.1 - +0.16
arduino:samd:mkr1000 🔺 +160 - +20120 +0.06 - +7.68 🔺 +28 - +416 +0.09 - +1.27
arduino:samd:mkrgsm1400 🔺 +160 - +20136 +0.06 - +7.68 🔺 +28 - +428 +0.09 - +1.31
arduino:samd:mkrnb1500 🔺 +160 - +20136 +0.06 - +7.68 🔺 +28 - +428 +0.09 - +1.31
arduino:samd:mkrwan1300 🔺 +152 - +20120 +0.06 - +7.68 🔺 +28 - +416 +0.09 - +1.27
arduino:samd:mkrwifi1010 🔺 +160 - +20136 +0.06 - +7.68 🔺 +28 - +428 +0.09 - +1.31
arduino:samd:nano_33_iot 🔺 +164 - +20124 +0.06 - +7.68 🔺 +32 - +420 +0.1 - +1.28
esp32:esp32:esp32 🔺 +220 - +1996 +0.02 - +0.15 🔺 +24 - +88 +0.01 - +0.03
rp2040:rp2040:rpipicow 🔺 +140 - +1532 +0.01 - +0.07 🔺 +24 - +184 +0.01 - +0.07
Click for full report table
Board examples/lzssDecoder
flash
% examples/lzssDecoder
RAM for global variables
% examples/crc32
flash
% examples/crc32
RAM for global variables
% examples/crc16
flash
% examples/crc16
RAM for global variables
% examples/sha256
flash
% examples/sha256
RAM for global variables
% examples/customCborDecoder
flash
% examples/customCborDecoder
RAM for global variables
% examples/customCborEncoder
flash
% examples/customCborEncoder
RAM for global variables
% examples/timedBlink
flash
% examples/timedBlink
RAM for global variables
% examples/flashFormatter
flash
% examples/flashFormatter
RAM for global variables
%
arduino:esp32:nano_nora 2440 0.08 76 0.02 2592 0.08 76 0.02 2592 0.08 76 0.02 2608 0.08 76 0.02 1376 0.04 48 0.01 172 0.01 24 0.01 2608 0.08 76 0.02 2608 0.08 76 0.02
arduino:mbed_edge:edge_control 6392 0.65 48 0.02 6400 0.65 56 0.02 6400 0.65 56 0.02 6400 0.65 56 0.02 1320 0.13 48 0.02 152 0.02 32 0.01 6392 0.65 48 0.02 6392 0.65 48 0.02
arduino:mbed_giga:giga 4776 0.24 48 0.01 4776 0.24 48 0.01 4712 0.24 48 0.01 4776 0.24 48 0.01 1320 0.07 56 0.01 152 0.01 40 0.01 4792 0.24 56 0.01 4784 0.24 56 0.01
arduino:mbed_nano:nanorp2040connect 1350 0.01 44 0.02 1350 0.01 52 0.02 1350 0.01 52 0.02 1350 0.01 52 0.02 1350 0.01 44 0.02 160 0.0 28 0.01 1350 0.01 44 0.02 1350 0.01 52 0.02
arduino:mbed_nicla:nicla_vision 4720 0.24 48 0.01 4720 0.24 48 0.01 4784 0.24 48 0.01 4784 0.24 48 0.01 1328 0.07 56 0.01 160 0.01 40 0.01 4720 0.24 56 0.01 4784 0.24 56 0.01
arduino:mbed_opta:opta 4784 0.24 48 0.01 4784 0.24 48 0.01 4720 0.24 48 0.01 4720 0.24 48 0.01 1328 0.07 56 0.01 160 0.01 40 0.01 4784 0.24 56 0.01 4792 0.24 56 0.01
arduino:mbed_portenta:envie_m7 N/A N/A N/A N/A N/A N/A N/A N/A N/A N/A N/A N/A N/A N/A N/A N/A N/A N/A N/A N/A N/A N/A N/A N/A N/A N/A N/A N/A N/A N/A N/A N/A
arduino:renesas_portenta:portenta_c33 1584 0.08 52 0.01 1584 0.08 52 0.01 1584 0.08 52 0.01 1584 0.08 52 0.01 1300 0.06 48 0.01 144 0.01 32 0.01 1584 0.08 56 0.01 1300 0.06 52 0.01
arduino:renesas_uno:unor4wifi 1372 0.52 48 0.15 1348 0.51 48 0.15 1348 0.51 48 0.15 1356 0.52 48 0.15 1308 0.5 48 0.15 148 0.06 32 0.1 1356 0.52 52 0.16 1348 0.51 48 0.15
arduino:samd:mkr1000 19916 7.6 412 1.26 20120 7.68 412 1.26 20116 7.67 412 1.26 20100 7.67 412 1.26 1336 0.51 44 0.13 160 0.06 28 0.09 20116 7.67 416 1.27 20072 7.66 412 1.26
arduino:samd:mkrgsm1400 19932 7.6 428 1.31 20136 7.68 428 1.31 20132 7.68 428 1.31 20116 7.67 428 1.31 1336 0.51 44 0.13 160 0.06 28 0.09 20116 7.67 416 1.27 20072 7.66 412 1.26
arduino:samd:mkrnb1500 19932 7.6 428 1.31 20136 7.68 428 1.31 20132 7.68 428 1.31 20116 7.67 428 1.31 1336 0.51 44 0.13 160 0.06 28 0.09 20116 7.67 416 1.27 20072 7.66 412 1.26
arduino:samd:mkrwan1300 19912 7.6 412 1.26 20116 7.67 412 1.26 20120 7.68 412 1.26 20096 7.67 412 1.26 1328 0.51 44 0.13 152 0.06 28 0.09 20120 7.68 416 1.27 20068 7.66 412 1.26
arduino:samd:mkrwifi1010 19932 7.6 428 1.31 20136 7.68 428 1.31 20132 7.68 428 1.31 20116 7.67 428 1.31 1336 0.51 44 0.13 160 0.06 28 0.09 20116 7.67 416 1.27 20072 7.66 412 1.26
arduino:samd:nano_33_iot 19920 7.6 416 1.27 20124 7.68 416 1.27 20120 7.68 416 1.27 20104 7.67 416 1.27 1340 0.51 48 0.15 164 0.06 32 0.1 20120 7.68 420 1.28 20072 7.66 412 1.26
esp32:esp32:esp32 1980 0.15 80 0.02 1980 0.15 80 0.02 1980 0.15 80 0.02 1980 0.15 80 0.02 1140 0.09 48 0.01 220 0.02 24 0.01 1996 0.15 88 0.03 1996 0.15 80 0.02
rp2040:rp2040:rpipicow 1516 0.07 184 0.07 1532 0.07 184 0.07 1532 0.07 184 0.07 1524 0.07 184 0.07 1204 0.06 44 0.02 140 0.01 24 0.01 1532 0.07 184 0.07 1516 0.07 184 0.07
Click for full report CSV
Board,examples/lzssDecoder<br>flash,%,examples/lzssDecoder<br>RAM for global variables,%,examples/crc32<br>flash,%,examples/crc32<br>RAM for global variables,%,examples/crc16<br>flash,%,examples/crc16<br>RAM for global variables,%,examples/sha256<br>flash,%,examples/sha256<br>RAM for global variables,%,examples/customCborDecoder<br>flash,%,examples/customCborDecoder<br>RAM for global variables,%,examples/customCborEncoder<br>flash,%,examples/customCborEncoder<br>RAM for global variables,%,examples/timedBlink<br>flash,%,examples/timedBlink<br>RAM for global variables,%,examples/flashFormatter<br>flash,%,examples/flashFormatter<br>RAM for global variables,%
arduino:esp32:nano_nora,2440,0.08,76,0.02,2592,0.08,76,0.02,2592,0.08,76,0.02,2608,0.08,76,0.02,1376,0.04,48,0.01,172,0.01,24,0.01,2608,0.08,76,0.02,2608,0.08,76,0.02
arduino:mbed_edge:edge_control,6392,0.65,48,0.02,6400,0.65,56,0.02,6400,0.65,56,0.02,6400,0.65,56,0.02,1320,0.13,48,0.02,152,0.02,32,0.01,6392,0.65,48,0.02,6392,0.65,48,0.02
arduino:mbed_giga:giga,4776,0.24,48,0.01,4776,0.24,48,0.01,4712,0.24,48,0.01,4776,0.24,48,0.01,1320,0.07,56,0.01,152,0.01,40,0.01,4792,0.24,56,0.01,4784,0.24,56,0.01
arduino:mbed_nano:nanorp2040connect,1350,0.01,44,0.02,1350,0.01,52,0.02,1350,0.01,52,0.02,1350,0.01,52,0.02,1350,0.01,44,0.02,160,0.0,28,0.01,1350,0.01,44,0.02,1350,0.01,52,0.02
arduino:mbed_nicla:nicla_vision,4720,0.24,48,0.01,4720,0.24,48,0.01,4784,0.24,48,0.01,4784,0.24,48,0.01,1328,0.07,56,0.01,160,0.01,40,0.01,4720,0.24,56,0.01,4784,0.24,56,0.01
arduino:mbed_opta:opta,4784,0.24,48,0.01,4784,0.24,48,0.01,4720,0.24,48,0.01,4720,0.24,48,0.01,1328,0.07,56,0.01,160,0.01,40,0.01,4784,0.24,56,0.01,4792,0.24,56,0.01
arduino:mbed_portenta:envie_m7,N/A,N/A,N/A,N/A,N/A,N/A,N/A,N/A,N/A,N/A,N/A,N/A,N/A,N/A,N/A,N/A,N/A,N/A,N/A,N/A,N/A,N/A,N/A,N/A,N/A,N/A,N/A,N/A,N/A,N/A,N/A,N/A
arduino:renesas_portenta:portenta_c33,1584,0.08,52,0.01,1584,0.08,52,0.01,1584,0.08,52,0.01,1584,0.08,52,0.01,1300,0.06,48,0.01,144,0.01,32,0.01,1584,0.08,56,0.01,1300,0.06,52,0.01
arduino:renesas_uno:unor4wifi,1372,0.52,48,0.15,1348,0.51,48,0.15,1348,0.51,48,0.15,1356,0.52,48,0.15,1308,0.5,48,0.15,148,0.06,32,0.1,1356,0.52,52,0.16,1348,0.51,48,0.15
arduino:samd:mkr1000,19916,7.6,412,1.26,20120,7.68,412,1.26,20116,7.67,412,1.26,20100,7.67,412,1.26,1336,0.51,44,0.13,160,0.06,28,0.09,20116,7.67,416,1.27,20072,7.66,412,1.26
arduino:samd:mkrgsm1400,19932,7.6,428,1.31,20136,7.68,428,1.31,20132,7.68,428,1.31,20116,7.67,428,1.31,1336,0.51,44,0.13,160,0.06,28,0.09,20116,7.67,416,1.27,20072,7.66,412,1.26
arduino:samd:mkrnb1500,19932,7.6,428,1.31,20136,7.68,428,1.31,20132,7.68,428,1.31,20116,7.67,428,1.31,1336,0.51,44,0.13,160,0.06,28,0.09,20116,7.67,416,1.27,20072,7.66,412,1.26
arduino:samd:mkrwan1300,19912,7.6,412,1.26,20116,7.67,412,1.26,20120,7.68,412,1.26,20096,7.67,412,1.26,1328,0.51,44,0.13,152,0.06,28,0.09,20120,7.68,416,1.27,20068,7.66,412,1.26
arduino:samd:mkrwifi1010,19932,7.6,428,1.31,20136,7.68,428,1.31,20132,7.68,428,1.31,20116,7.67,428,1.31,1336,0.51,44,0.13,160,0.06,28,0.09,20116,7.67,416,1.27,20072,7.66,412,1.26
arduino:samd:nano_33_iot,19920,7.6,416,1.27,20124,7.68,416,1.27,20120,7.68,416,1.27,20104,7.67,416,1.27,1340,0.51,48,0.15,164,0.06,32,0.1,20120,7.68,420,1.28,20072,7.66,412,1.26
esp32:esp32:esp32,1980,0.15,80,0.02,1980,0.15,80,0.02,1980,0.15,80,0.02,1980,0.15,80,0.02,1140,0.09,48,0.01,220,0.02,24,0.01,1996,0.15,88,0.03,1996,0.15,80,0.02
rp2040:rp2040:rpipicow,1516,0.07,184,0.07,1532,0.07,184,0.07,1532,0.07,184,0.07,1524,0.07,184,0.07,1204,0.06,44,0.02,140,0.01,24,0.01,1532,0.07,184,0.07,1516,0.07,184,0.07

Copy link
Collaborator

Choose a reason for hiding this comment

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

Instead of WiFIFWVersionMessageEncoder, why don't we call it VersionMessageEncoder? We can make it generic and reuse it by providing a Cbor tag and message id as parameters in the constructor, like this:

struct VersionMessage {
  Message c;
  struct {
    const char *versionString;
  } params;
};

VersionMessageEncoder(CborTag tag, MessageId id)
: CBORMessageEncoderInterface(tag, id) {}

VersionMessageEncoder WiFiFWVersionEncoder(CBORWiFiFWVersionMessage, WiFiFWVersionMessageId);

typedef VersionMessage WiFiFWVersionMessage;

In this way we can encode all kind of version messages with just this class.

Copy link
Collaborator

Choose a reason for hiding this comment

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

Can you add some examples to improve code coverage?

Comment on lines +32 to 34
ArduinoStandardMessageStartId = 0x000,
ArduinoIOTCloudStartMessageId = 0x100,
ArduinoProvisioningStartMessageId = 0x200,
Copy link
Collaborator

Choose a reason for hiding this comment

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

Suggested change
ArduinoStandardMessageStartId = 0x000,
ArduinoIOTCloudStartMessageId = 0x100,
ArduinoProvisioningStartMessageId = 0x200,
ArduinoMessageStartId = 0x000,
ArduinoIOTCloudStartMessageId = 0x100,
ArduinoProvisioningStartMessageId = 0x200,
ArduinoVersionsStartId = 0x300,

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
topic: code Related to content of the project itself type: enhancement Proposed improvement
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants