-
Notifications
You must be signed in to change notification settings - Fork 7.3k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Bluetooth: SDP: fix 32 and 128-bit UUID configuration (IDFGH-10312) #11572
Conversation
} else if (rec->hdr.bt_uuid.len == 2) { | ||
memcpy(&service, &rec->hdr.bt_uuid.uuid.uuid16, sizeof(service)); | ||
UINT8_TO_BE_STREAM (p_temp, (UUID_DESC_TYPE << 3) | SIZE_TWO_BYTES); | ||
UINT16_TO_BE_STREAM (p_temp, rec->hdr.bt_uuid.uuid.uuid16); | ||
} else if (rec->hdr.bt_uuid.len == 4) { | ||
memcpy(&service, &rec->hdr.bt_uuid.uuid.uuid16, sizeof(service)); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I want to convert 32 bit or 128 bit uuid to 16 bit uuid.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Hi!
What is the purpose of converting them to 16-bit UUID?
I dug down and realized that we must patch bta_sys_add_uuid(UINT16 uuid16) and other functions in the chain to support 32 and 128 bit UUIDs as well.
I will do that to fix the issue #11529 , but it exceeds this pull request.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Maybe we don't need to modify bta_sys_add_uuid
. Just need to convert them to 16 bit uuid.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
That is not the topic of this PR, but I want to explain myself:
Bluedroid in some places has the ability to use 128-bit UUID.
For example, in the bta_dm_set_eir() code checks for the 128-bit UUIDs.
But the problem is that these 128 and 32-bit UUIDs are nowhere saved in the bta_dm_cb.custom_uuid[] array. Only 16-bit values are stored.
That's why I want to modify bta_sys_add_uuid
one day.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
you are right. In order to support 128 and 32-bit UUIDs need to modify bta_sys_add_uuid
.
} else { | ||
SDP_DeleteRecord(sdp_handle); | ||
sdp_handle = 0; | ||
return sdp_handle; | ||
} | ||
/* add service class */ | ||
status &= SDP_AddServiceClassIdList(sdp_handle, 1, &service); | ||
status &= SDP_AddAttribute (sdp_handle, ATTR_ID_SERVICE_CLASS_ID_LIST, |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Please delete the trailing-whitespace.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Done
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I'm very sorry, maybe I expressed it wrong. It is necessary to delete the space behind ,
.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Oh, got it.
Fixed!
} else if (rec->hdr.bt_uuid.len == 2) { | ||
memcpy(&service, &rec->hdr.bt_uuid.uuid.uuid16, sizeof(service)); | ||
UINT8_TO_BE_STREAM (p_temp, (UUID_DESC_TYPE << 3) | SIZE_TWO_BYTES); | ||
UINT16_TO_BE_STREAM (p_temp, rec->hdr.bt_uuid.uuid.uuid16); | ||
} else if (rec->hdr.bt_uuid.len == 4) { | ||
memcpy(&service, &rec->hdr.bt_uuid.uuid.uuid16, sizeof(service)); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Maybe we don't need to modify bta_sys_add_uuid
. Just need to convert them to 16 bit uuid.
160cb23
to
26d2437
Compare
26d2437
to
1b4286f
Compare
Added proper conversion of 4 and 16-byte UUIDs values to binary streams. UUIDs now set with SDP_AddAttribute() instead of SDP_AddServiceClassIdList().
1b4286f
to
418ffd1
Compare
The problem:
esp_sdp_create_record()
can't create SDP records with 32 and 128-bit UUIDs.Summary
Added proper conversion of 4 and 16-byte UUIDs values to binary streams.
UUIDs are now set with
SDP_AddAttribute()
instead ofSDP_AddServiceClassIdList()
.Changes were tested with the following code:
sdptool scan
outputs will be:Caveats
There are still some strange things like
memcpy(&service, &rec->hdr.bt_uuid.uuid.uuid16, sizeof(service));
I plan to rework them when I will fix #11528