Skip to content

Commit f47d0f2

Browse files
Mattia Bertorellomattiabertorello
Mattia Bertorello
authored andcommitted
Add automatically decode for V1 and V2 cloud protocol
Remove the fixed protocol decision in the decode method Now the library can decode the V1 or V2 without configuration
1 parent b3fc51f commit f47d0f2

File tree

1 file changed

+2
-12
lines changed

1 file changed

+2
-12
lines changed

ArduinoCloudThing.cpp

+2-12
Original file line numberDiff line numberDiff line change
@@ -224,10 +224,7 @@ ArduinoCloudThing::MapParserState ArduinoCloudThing::handle_MapKey(CborValue * v
224224

225225
if(cbor_value_at_end(value_iter)) {
226226
next_state = MapParserState::LeaveMap;
227-
}
228-
else {
229-
if(_cloud_protocol == CloudProtocol::V1) {
230-
if(cbor_value_is_text_string(value_iter)) {
227+
} else if(cbor_value_is_text_string(value_iter)) {
231228
char * val = 0;
232229
size_t val_size = 0;
233230
if(cbor_value_dup_text_string(value_iter, &val, &val_size, value_iter) == CborNoError) {
@@ -242,11 +239,7 @@ ArduinoCloudThing::MapParserState ArduinoCloudThing::handle_MapKey(CborValue * v
242239
else next_state = MapParserState::UndefinedKey;
243240
free(val);
244241
}
245-
}
246-
}
247-
248-
if(_cloud_protocol == CloudProtocol::V2) {
249-
if(cbor_value_is_integer(value_iter)) {
242+
} else if (cbor_value_is_integer(value_iter)) {
250243
int val = 0;
251244
if(cbor_value_get_int(value_iter, &val) == CborNoError) {
252245
if(cbor_value_advance(value_iter) == CborNoError) {
@@ -261,10 +254,7 @@ ArduinoCloudThing::MapParserState ArduinoCloudThing::handle_MapKey(CborValue * v
261254
else next_state = MapParserState::UndefinedKey;
262255
}
263256
}
264-
}
265-
}
266257
}
267-
268258
return next_state;
269259
}
270260

0 commit comments

Comments
 (0)