mirror of
https://github.com/bluekitchen/btstack.git
synced 2025-01-07 09:55:45 +00:00
converted sdp_get_attribute_value_for_attribute_id to new traversal helper
This commit is contained in:
parent
be3deeedc2
commit
478a4824bb
@ -336,26 +336,18 @@ int sdp_append_attributes_in_attributeIDList(uint8_t *record, uint8_t *attribute
|
|||||||
|
|
||||||
#pragma mark Get AttributeValue for AttributeID
|
#pragma mark Get AttributeValue for AttributeID
|
||||||
// find attribute (ELEMENT) by ID
|
// find attribute (ELEMENT) by ID
|
||||||
// context { attribute ptr, attributeQueryID }
|
|
||||||
struct sdp_context_attribute_by_id {
|
struct sdp_context_attribute_by_id {
|
||||||
uint16_t attributeID;
|
uint16_t attributeID;
|
||||||
uint8_t * attributeValue;
|
uint8_t * attributeValue;
|
||||||
uint8_t attributeFound;
|
uint8_t attributeFound;
|
||||||
uint16_t index;
|
uint16_t index;
|
||||||
};
|
};
|
||||||
static int sdp_traversal_attribute_by_id(uint8_t * element, de_type_t attributeType, de_size_t size, void *my_context){
|
static int sdp_traversal_attribute_by_id(uint16_t attributeID, uint8_t * attributeValue, de_type_t attributeType, de_size_t size, void *my_context){
|
||||||
struct sdp_context_attribute_by_id * context = (struct sdp_context_attribute_by_id *) my_context;
|
struct sdp_context_attribute_by_id * context = (struct sdp_context_attribute_by_id *) my_context;
|
||||||
if ((context->index & 1) == 0) {
|
if (attributeID == context->attributeID) {
|
||||||
if (attributeType == DE_UINT && size == DE_SIZE_16){
|
context->attributeFound = 1;
|
||||||
if (READ_NET_16(element, 1) == context->attributeID){
|
context->attributeValue = attributeValue;
|
||||||
context->attributeFound = 1;
|
return 1;
|
||||||
}
|
|
||||||
}
|
|
||||||
} else {
|
|
||||||
if (context->attributeFound) {
|
|
||||||
context->attributeValue = element;
|
|
||||||
return 1;
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
context->index++;
|
context->index++;
|
||||||
return 0;
|
return 0;
|
||||||
@ -367,7 +359,7 @@ uint8_t * sdp_get_attribute_value_for_attribute_id(uint8_t * record, uint16_t at
|
|||||||
context.attributeID = attributeID;
|
context.attributeID = attributeID;
|
||||||
context.attributeFound = 0;
|
context.attributeFound = 0;
|
||||||
context.index = 0;
|
context.index = 0;
|
||||||
de_traverse_sequence(record, sdp_traversal_attribute_by_id, &context);
|
sdp_attribute_list_traverse_sequence(record, sdp_traversal_attribute_by_id, &context);
|
||||||
return context.attributeValue;
|
return context.attributeValue;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user