Skip to content

Commit 92360bb

Browse files
Mattia Bertorellomattiabertorello
Mattia Bertorello
authored andcommitted
Add some comments to explain which protocol version the decode will use
1 parent 8b6a40f commit 92360bb

File tree

1 file changed

+5
-0
lines changed

1 file changed

+5
-0
lines changed

ArduinoCloudThing.cpp

+5
Original file line numberDiff line numberDiff line change
@@ -224,6 +224,9 @@ ArduinoCloudThing::MapParserState ArduinoCloudThing::handle_MapKey(CborValue * v
224224

225225
if(cbor_value_at_end(value_iter)) {
226226
next_state = MapParserState::LeaveMap;
227+
// If the key is a string means that the Map use the string keys (protocol V1)
228+
// https://tools.ietf.org/html/rfc8428#section-4.3
229+
// example [{"n": "temperature", "v": 25}]
227230
} else if(cbor_value_is_text_string(value_iter)) {
228231
char * val = 0;
229232
size_t val_size = 0;
@@ -239,6 +242,8 @@ ArduinoCloudThing::MapParserState ArduinoCloudThing::handle_MapKey(CborValue * v
239242
else next_state = MapParserState::UndefinedKey;
240243
free(val);
241244
}
245+
// If the key is a number means that the Map use the CBOR Label (protocol V2)
246+
// example [{0: "temperature", 2: 25}]
242247
} else if (cbor_value_is_integer(value_iter)) {
243248
int val = 0;
244249
if(cbor_value_get_int(value_iter, &val) == CborNoError) {

0 commit comments

Comments
 (0)