You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
// when the attribute name string is not empty, the attribute identifier is incremented in order to be encoded in the message if the _lightPayload flag is set
// if the value in the cbor message is a string, it corresponds to the name of the property to be updated (int the form [property_name]:[attribute_name])
315
332
char * val = nullptr;
316
333
size_t val_size = 0;
317
334
if (cbor_value_dup_text_string(value_iter, &val, &val_size, value_iter) == CborNoError) {
@@ -326,8 +343,26 @@ ArduinoCloudThing::MapParserState ArduinoCloudThing::handle_Name(CborValue * val
326
343
map_data->attribute_name.set(attribute_name);
327
344
next_state = MapParserState::MapKey;
328
345
}
346
+
} elseif (cbor_value_is_integer(value_iter)) {
347
+
// if the value in the cbor message is an integer, a light payload has been used and an integer identifier should be decode in order to retrieve the corresponding property and attribute name to be updated
348
+
int val = 0;
349
+
if (cbor_value_get_int(value_iter, &val) == CborNoError) {
350
+
map_data->light_payload.set(true);
351
+
map_data->name_identifier.set(val & 255);
352
+
map_data->attribute_identifier.set(val >> 8);
353
+
map_data->light_payload.set(true);
354
+
String name = getPropertyNameByIdentifier(val);
355
+
map_data->name.set(name);
356
+
357
+
358
+
if (cbor_value_advance(value_iter) == CborNoError) {
//if propertyIdentifier is different from -1, an integer identifier is associated to the added property to be use instead of the property name when the parameter lightPayload is true in the encode method
/* encode return > 0 if a property has changed and encodes the changed properties in CBOR format into the provided buffer */
84
-
intencode(uint8_t * data, size_tconst size);
84
+
/* if lightPayload is true the integer identifier of the property will be encoded in the message instead of the property name in order to reduce the size of the message payload*/
0 commit comments