mirror of
https://github.com/espressif/esp-idf.git
synced 2025-09-30 19:19:21 +00:00
Merge branch 'feature/support_for_32_and_128_bit_custom_uuids_v5.2' into 'release/v5.2'
feat(bt/bluedroid): Add new APIs for 32 and 128-bit UUIDs (backport v5.2) See merge request espressif/esp-idf!27229
This commit is contained in:
@@ -2535,9 +2535,125 @@ void BTM_AddEirService( UINT32 *p_eir_uuid, UINT16 uuid16 )
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
/*******************************************************************************
|
||||
**
|
||||
** Function BTM_RemoveEirService
|
||||
** Function btm_compare_uuid
|
||||
**
|
||||
** Description Helper function for custom service managing routines.
|
||||
**
|
||||
** Parameters uuid1 - pointer to the first tBT_UUID struct
|
||||
** uuid2 - pointer to the second tBT_UUID struct
|
||||
**
|
||||
** Returns true if UUID structs are identical
|
||||
**
|
||||
*******************************************************************************/
|
||||
static bool btm_compare_uuid(tBT_UUID *uuid1, tBT_UUID *uuid2)
|
||||
{
|
||||
if (uuid1->len != uuid2->len) {
|
||||
return FALSE;
|
||||
}
|
||||
|
||||
return (memcmp(&uuid1->uu, &uuid2->uu, uuid1->len) == 0);
|
||||
}
|
||||
|
||||
/*******************************************************************************
|
||||
**
|
||||
** Function btm_find_empty_custom_uuid_slot
|
||||
**
|
||||
** Description Helper function for custom service managing routines.
|
||||
**
|
||||
** Parameters custom_uuid - pointer to custom_uuid array in tBTA_DM_CB
|
||||
** uuid - UUID struct
|
||||
**
|
||||
** Returns Slot number if there is empty slot,
|
||||
** otherwise - BTA_EIR_SERVER_NUM_CUSTOM_UUID
|
||||
**
|
||||
*******************************************************************************/
|
||||
static UINT8 btm_find_empty_custom_uuid_slot(tBT_UUID *custom_uuid, tBT_UUID uuid)
|
||||
{
|
||||
for (UINT8 xx = 0; xx < BTA_EIR_SERVER_NUM_CUSTOM_UUID; xx++) {
|
||||
if (custom_uuid[xx].len == 0) {
|
||||
return xx;
|
||||
}
|
||||
}
|
||||
return BTA_EIR_SERVER_NUM_CUSTOM_UUID;
|
||||
}
|
||||
|
||||
/*******************************************************************************
|
||||
**
|
||||
** Function btm_find_match_custom_uuid_slot
|
||||
**
|
||||
** Description Helper function for custom service managing routines.
|
||||
**
|
||||
** Parameters custom_uuid - pointer to custom_uuid array in tBTA_DM_CB
|
||||
** uuid - UUID struct
|
||||
**
|
||||
** Returns Slot number if given UUID is already in slots array,
|
||||
** otherwise - BTA_EIR_SERVER_NUM_CUSTOM_UUID
|
||||
**
|
||||
*******************************************************************************/
|
||||
static UINT8 btm_find_match_custom_uuid_slot(tBT_UUID *custom_uuid, tBT_UUID uuid)
|
||||
{
|
||||
for (UINT8 xx = 0; xx < BTA_EIR_SERVER_NUM_CUSTOM_UUID; xx++) {
|
||||
if (btm_compare_uuid(&custom_uuid[xx], &uuid)) {
|
||||
return xx;
|
||||
}
|
||||
}
|
||||
return BTA_EIR_SERVER_NUM_CUSTOM_UUID;
|
||||
}
|
||||
|
||||
/*******************************************************************************
|
||||
**
|
||||
** Function BTM_HasCustomEirService
|
||||
**
|
||||
** Description This function is called to know if UUID is already in custom
|
||||
** UUID list.
|
||||
**
|
||||
** Parameters custom_uuid - pointer to custom_uuid array in tBTA_DM_CB
|
||||
** uuid - UUID struct
|
||||
**
|
||||
** Returns TRUE - if found
|
||||
** FALSE - if not found
|
||||
**
|
||||
*******************************************************************************/
|
||||
BOOLEAN BTM_HasCustomEirService(tBT_UUID *custom_uuid, tBT_UUID uuid)
|
||||
{
|
||||
UINT8 match_slot = btm_find_match_custom_uuid_slot(custom_uuid, uuid);
|
||||
|
||||
if (match_slot == BTA_EIR_SERVER_NUM_CUSTOM_UUID) {
|
||||
return FALSE;
|
||||
}
|
||||
return TRUE;
|
||||
}
|
||||
|
||||
/*******************************************************************************
|
||||
**
|
||||
** Function BTM_AddCustomEirService
|
||||
**
|
||||
** Description This function is called to add a custom UUID.
|
||||
**
|
||||
** Parameters custom_uuid - pointer to custom_uuid array in tBTA_DM_CB
|
||||
** uuid - UUID struct
|
||||
**
|
||||
** Returns None
|
||||
**
|
||||
*******************************************************************************/
|
||||
void BTM_AddCustomEirService(tBT_UUID *custom_uuid, tBT_UUID uuid)
|
||||
{
|
||||
UINT8 empty_slot = btm_find_empty_custom_uuid_slot(custom_uuid, uuid);
|
||||
|
||||
if (empty_slot == BTA_EIR_SERVER_NUM_CUSTOM_UUID) {
|
||||
BTM_TRACE_WARNING("No space to add UUID for EIR");
|
||||
} else {
|
||||
memcpy(&(custom_uuid[empty_slot]), &(uuid), sizeof(tBT_UUID));
|
||||
BTM_TRACE_EVENT("UUID saved in %d slot", empty_slot);
|
||||
}
|
||||
}
|
||||
|
||||
/*******************************************************************************
|
||||
**
|
||||
** Function BTM_RemoveCustomEirService
|
||||
**
|
||||
** Description This function is called to remove a service in bit map of UUID list.
|
||||
**
|
||||
@@ -2557,6 +2673,30 @@ void BTM_RemoveEirService( UINT32 *p_eir_uuid, UINT16 uuid16 )
|
||||
}
|
||||
}
|
||||
|
||||
/*******************************************************************************
|
||||
**
|
||||
** Function BTM_RemoveCustomEirService
|
||||
**
|
||||
** Description This function is called to remove a a custom UUID.
|
||||
**
|
||||
** Parameters custom_uuid - pointer to custom_uuid array in tBTA_DM_CB
|
||||
** uuid - UUID struct
|
||||
**
|
||||
** Returns None
|
||||
**
|
||||
*******************************************************************************/
|
||||
void BTM_RemoveCustomEirService(tBT_UUID *custom_uuid, tBT_UUID uuid)
|
||||
{
|
||||
UINT8 match_slot = btm_find_match_custom_uuid_slot(custom_uuid, uuid);
|
||||
|
||||
if (match_slot == BTA_EIR_SERVER_NUM_CUSTOM_UUID) {
|
||||
BTM_TRACE_WARNING("UUID is not found for EIR");
|
||||
return;
|
||||
} else {
|
||||
memset(&(custom_uuid[match_slot]), 0, sizeof(tBT_UUID));
|
||||
}
|
||||
}
|
||||
|
||||
/*******************************************************************************
|
||||
**
|
||||
** Function BTM_GetEirSupportedServices
|
||||
|
@@ -4080,6 +4080,22 @@ BOOLEAN BTM_HasEirService( UINT32 *p_eir_uuid, UINT16 uuid16 );
|
||||
tBTM_EIR_SEARCH_RESULT BTM_HasInquiryEirService( tBTM_INQ_RESULTS *p_results,
|
||||
UINT16 uuid16 );
|
||||
|
||||
/*******************************************************************************
|
||||
**
|
||||
** Function BTM_HasCustomEirService
|
||||
**
|
||||
** Description This function is called to know if UUID is already in custom
|
||||
** UUID list.
|
||||
**
|
||||
** Parameters custom_uuid - pointer to custom_uuid array in tBTA_DM_CB
|
||||
** uuid - UUID struct
|
||||
**
|
||||
** Returns TRUE - if found
|
||||
** FALSE - if not found
|
||||
**
|
||||
*******************************************************************************/
|
||||
BOOLEAN BTM_HasCustomEirService( tBT_UUID *custom_uuid, tBT_UUID uuid );
|
||||
|
||||
/*******************************************************************************
|
||||
**
|
||||
** Function BTM_AddEirService
|
||||
@@ -4095,6 +4111,20 @@ tBTM_EIR_SEARCH_RESULT BTM_HasInquiryEirService( tBTM_INQ_RESULTS *p_results,
|
||||
//extern
|
||||
void BTM_AddEirService( UINT32 *p_eir_uuid, UINT16 uuid16 );
|
||||
|
||||
/*******************************************************************************
|
||||
**
|
||||
** Function BTM_AddCustomEirService
|
||||
**
|
||||
** Description This function is called to add a custom UUID.
|
||||
**
|
||||
** Parameters custom_uuid - pointer to custom_uuid array in tBTA_DM_CB
|
||||
** uuid - UUID struct
|
||||
**
|
||||
** Returns None
|
||||
**
|
||||
*******************************************************************************/
|
||||
void BTM_AddCustomEirService(tBT_UUID *custom_uuid, tBT_UUID uuid);
|
||||
|
||||
/*******************************************************************************
|
||||
**
|
||||
** Function BTM_RemoveEirService
|
||||
@@ -4110,6 +4140,20 @@ void BTM_AddEirService( UINT32 *p_eir_uuid, UINT16 uuid16 );
|
||||
//extern
|
||||
void BTM_RemoveEirService( UINT32 *p_eir_uuid, UINT16 uuid16 );
|
||||
|
||||
/*******************************************************************************
|
||||
**
|
||||
** Function BTM_RemoveCustomEirService
|
||||
**
|
||||
** Description This function is called to remove a a custom UUID.
|
||||
**
|
||||
** Parameters custom_uuid - pointer to custom_uuid array in tBTA_DM_CB
|
||||
uuid - UUID struct
|
||||
**
|
||||
** Returns None
|
||||
**
|
||||
*******************************************************************************/
|
||||
void BTM_RemoveCustomEirService(tBT_UUID *custom_uuid, tBT_UUID uuid);
|
||||
|
||||
/*******************************************************************************
|
||||
**
|
||||
** Function BTM_GetEirSupportedServices
|
||||
|
Reference in New Issue
Block a user