cbor_encoder_init(&encoder, outPayload, *size, 0);
- CborEncoder rootArray;
- err = err | cbor_encoder_create_array(&encoder, &rootArray, 1);
CborEncoder map;
- err = err | cbor_encoder_create_map(&rootArray, &map, CborIndefiniteLength);
+ err = err | cbor_encoder_create_map(&encoder, &map, CborIndefiniteLength);
if(payload->securityData)
{
- err = err | AddTextStringToMap(&map, OC_RSRVD_REPRESENTATION,
- sizeof(OC_RSRVD_REPRESENTATION) - 1,
- payload->securityData);
+ err = err | cbor_encode_text_string(&map, payload->securityData,
+ strlen(payload->securityData));
}
- err = err | cbor_encoder_close_container(&rootArray, &map);
-
- err = err | cbor_encoder_close_container(&encoder, &rootArray);
+ err = err | cbor_encoder_close_container(&encoder, &map);
return checkError(err, &encoder, outPayload, size);
}
bool err = false;
char * securityData = NULL;
- CborValue arrayVal;
- err = err || cbor_value_enter_container(rootValue, &arrayVal);
+ CborValue map;
+ err = err || cbor_value_enter_container(rootValue, &map);
- if(cbor_value_is_map(&arrayVal))
+ if(cbor_value_is_map(&map))
{
- CborValue curVal;
- err = err || cbor_value_map_find_value(&arrayVal, OC_RSRVD_REPRESENTATION, &curVal);
-
- if(cbor_value_is_valid(&curVal))
- {
- size_t len;
- err = err || cbor_value_dup_text_string(&curVal, &securityData, &len, NULL);
- }
+ size_t len;
+ err = err || cbor_value_dup_text_string(&map, &securityData, &len, NULL);
}
else
{
return OC_STACK_MALFORMED_RESPONSE;
}
- err = err || cbor_value_advance(&arrayVal);
- err = err || cbor_value_leave_container(rootValue, &arrayVal);
+ err = err || cbor_value_leave_container(rootValue, &map);
if(err)
{