sdp support create and search PBAPC record

This commit is contained in:
xiongweichao
2022-05-08 19:55:37 +08:00
committed by BOT
parent a317cb1b0a
commit 4faf4e760a
2 changed files with 78 additions and 3 deletions

View File

@@ -50,6 +50,9 @@ static const uint8_t UUID_OBEX_OBJECT_PUSH[] = {0x00, 0x00, 0x11, 0x05, 0x00, 0
static const uint8_t UUID_PBAP_PSE[] = {0x00, 0x00, 0x11, 0x2F, 0x00, 0x00, 0x10, 0x00, static const uint8_t UUID_PBAP_PSE[] = {0x00, 0x00, 0x11, 0x2F, 0x00, 0x00, 0x10, 0x00,
0x80, 0x00, 0x00, 0x80, 0x5F, 0x9B, 0x34, 0xFB 0x80, 0x00, 0x00, 0x80, 0x5F, 0x9B, 0x34, 0xFB
}; };
static const uint8_t UUID_PBAP_PCE[] = {0x00, 0x00, 0x11, 0x2E, 0x00, 0x00, 0x10, 0x00,
0x80, 0x00, 0x00, 0x80, 0x5F, 0x9B, 0x34, 0xFB
};
static const uint8_t UUID_MAP_MAS[] = {0x00, 0x00, 0x11, 0x32, 0x00, 0x00, 0x10, 0x00, static const uint8_t UUID_MAP_MAS[] = {0x00, 0x00, 0x11, 0x32, 0x00, 0x00, 0x10, 0x00,
0x80, 0x00, 0x00, 0x80, 0x5F, 0x9B, 0x34, 0xFB 0x80, 0x00, 0x00, 0x80, 0x5F, 0x9B, 0x34, 0xFB
}; };
@@ -223,6 +226,28 @@ static void bta_create_pse_sdp_record(bluetooth_sdp_record *record, tSDP_DISC_RE
} }
} }
static void bta_create_pce_sdp_record(bluetooth_sdp_record *record, tSDP_DISC_REC *p_rec)
{
tSDP_DISC_ATTR *p_attr;
UINT16 pversion;
record->pce.hdr.type = SDP_TYPE_PBAP_PCE;
record->pce.hdr.service_name_length = 0;
record->pce.hdr.service_name = NULL;
record->pce.hdr.rfcomm_channel_number = 0; // unused
record->pce.hdr.l2cap_psm = -1; // unused
record->pce.hdr.profile_version = 0;
if ((p_attr = SDP_FindAttributeInRec(p_rec, ATTR_ID_SERVICE_NAME)) != NULL) {
record->pce.hdr.service_name_length = SDP_DISC_ATTR_LEN(p_attr->attr_len_type);
record->pce.hdr.service_name = (char *)p_attr->attr_value.v.array;
}
if (SDP_FindProfileVersionInRec(p_rec, UUID_SERVCLASS_PHONE_ACCESS, &pversion)) {
record->pce.hdr.profile_version = pversion;
}
}
static void bta_create_ops_sdp_record(bluetooth_sdp_record *record, tSDP_DISC_REC *p_rec) static void bta_create_ops_sdp_record(bluetooth_sdp_record *record, tSDP_DISC_REC *p_rec)
{ {
tSDP_DISC_ATTR *p_attr, *p_sattr; tSDP_DISC_ATTR *p_attr, *p_sattr;
@@ -395,6 +420,9 @@ static void bta_sdp_search_cback(UINT16 result, void *user_data)
} else if (IS_UUID(UUID_PBAP_PSE, uuid->uu.uuid128)) { } else if (IS_UUID(UUID_PBAP_PSE, uuid->uu.uuid128)) {
APPL_TRACE_DEBUG("%s() - found PBAP (PSE) uuid\n", __func__); APPL_TRACE_DEBUG("%s() - found PBAP (PSE) uuid\n", __func__);
bta_create_pse_sdp_record(&evt_data.records[count], p_rec); bta_create_pse_sdp_record(&evt_data.records[count], p_rec);
} else if (IS_UUID(UUID_PBAP_PCE, uuid->uu.uuid128)) {
APPL_TRACE_DEBUG("%s() - found PBAP (PCE) uuid\n", __func__);
bta_create_pce_sdp_record(&evt_data.records[count], p_rec);
} else if (IS_UUID(UUID_OBEX_OBJECT_PUSH, uuid->uu.uuid128)) { } else if (IS_UUID(UUID_OBEX_OBJECT_PUSH, uuid->uu.uuid128)) {
APPL_TRACE_DEBUG("%s() - found Object Push Server (OPS) uuid\n", __func__); APPL_TRACE_DEBUG("%s() - found Object Push Server (OPS) uuid\n", __func__);
bta_create_ops_sdp_record(&evt_data.records[count], p_rec); bta_create_ops_sdp_record(&evt_data.records[count], p_rec);

View File

@@ -484,7 +484,53 @@ static int add_pbaps_sdp(const bluetooth_sdp_pse_record* rec)
if (!status) { if (!status) {
SDP_DeleteRecord(sdp_handle); SDP_DeleteRecord(sdp_handle);
sdp_handle = 0; sdp_handle = 0;
BTC_TRACE_ERROR("%s() FAILED", __func__); BTC_TRACE_ERROR("%s() FAILED, status = %d", __func__, status);
} else {
bta_sys_add_uuid(service); /* UUID_SERVCLASS_MESSAGE_ACCESS */
BTC_TRACE_DEBUG("%s(): SDP Registered (handle 0x%08x)", __func__, sdp_handle);
}
return sdp_handle;
}
/* Create a PBAP Client SDP record based on information stored in a bluetooth_sdp_pse_record */
static int add_pbapc_sdp(const bluetooth_sdp_pce_record* rec)
{
UINT16 service = UUID_SERVCLASS_PBAP_PCE;
UINT16 browse = UUID_SERVCLASS_PUBLIC_BROWSE_GROUP;
bool status = true;
UINT32 sdp_handle = 0;
BTC_TRACE_DEBUG("%s(): scn 0x%02x, psm = 0x%04x\n service name %s", __func__,
rec->hdr.rfcomm_channel_number, rec->hdr.l2cap_psm, rec->hdr.service_name);
if ((sdp_handle = SDP_CreateRecord()) == 0) {
BTC_TRACE_ERROR("%s(): Unable to register PBAP Client Service", __func__);
return sdp_handle;
}
/* add service class */
status &= SDP_AddServiceClassIdList(sdp_handle, 1, &service);
/* Add a name entry */
status &= SDP_AddAttribute(sdp_handle,
(UINT16)ATTR_ID_SERVICE_NAME,
(UINT8)TEXT_STR_DESC_TYPE,
(UINT32)(rec->hdr.service_name_length + 1),
(UINT8 *)rec->hdr.service_name);
/* Add in the Bluetooth Profile Descriptor List */
status &= SDP_AddProfileDescriptorList(sdp_handle,
UUID_SERVCLASS_PHONE_ACCESS,
rec->hdr.profile_version);
/* Make the service browseable */
status &= SDP_AddUuidSequence (sdp_handle, ATTR_ID_BROWSE_GROUP_LIST, 1, &browse);
if (!status) {
SDP_DeleteRecord(sdp_handle);
sdp_handle = 0;
BTC_TRACE_ERROR("%s() FAILED, status = %d", __func__, status);
} else { } else {
bta_sys_add_uuid(service); /* UUID_SERVCLASS_MESSAGE_ACCESS */ bta_sys_add_uuid(service); /* UUID_SERVCLASS_MESSAGE_ACCESS */
BTC_TRACE_DEBUG("%s(): SDP Registered (handle 0x%08x)", __func__, sdp_handle); BTC_TRACE_DEBUG("%s(): SDP Registered (handle 0x%08x)", __func__, sdp_handle);
@@ -663,14 +709,15 @@ static int btc_handle_create_record_event(int id)
case SDP_TYPE_PBAP_PSE: case SDP_TYPE_PBAP_PSE:
handle = add_pbaps_sdp(&record->pse); handle = add_pbaps_sdp(&record->pse);
break; break;
case SDP_TYPE_PBAP_PCE:
handle = add_pbapc_sdp(&record->pce);
break;
case SDP_TYPE_OPP_SERVER: case SDP_TYPE_OPP_SERVER:
handle = add_opps_sdp(&record->ops); handle = add_opps_sdp(&record->ops);
break; break;
case SDP_TYPE_SAP_SERVER: case SDP_TYPE_SAP_SERVER:
handle = add_saps_sdp(&record->sap); handle = add_saps_sdp(&record->sap);
break; break;
case SDP_TYPE_PBAP_PCE:
// break; not yet supported
default: default:
BTC_TRACE_DEBUG("Record type %d is not supported",record->hdr.type); BTC_TRACE_DEBUG("Record type %d is not supported",record->hdr.type);
break; break;