Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit e635328c authored by Hsin-chen Chuang's avatar Hsin-chen Chuang
Browse files

btif: create_sdp_record: Add MPS record support

Bug: 264820755
Tag: #floss
Test: ./build.py --target test
Change-Id: Id7ee9fb59c10f60fc598497acd02ec04b5e41b32
parent 987aebf8
Loading
Loading
Loading
Loading
+53 −0
Original line number Diff line number Diff line
@@ -75,6 +75,7 @@ static int add_pbapc_sdp(const bluetooth_sdp_pce_record* rec);
static int add_pbaps_sdp(const bluetooth_sdp_pse_record* rec);
static int add_opps_sdp(const bluetooth_sdp_ops_record* rec);
static int add_saps_sdp(const bluetooth_sdp_sap_record* rec);
static int add_mps_sdp(const bluetooth_sdp_mps_record* rec);
bt_status_t remove_sdp_record(int record_id);
static int free_sdp_slot(int id);

@@ -376,6 +377,9 @@ void on_create_record_event(int id) {
        handle = add_pbapc_sdp(&record->pce);
        service_id = BTA_PCE_SERVICE_ID;
        break;
      case SDP_TYPE_MPS:
        handle = add_mps_sdp(&record->mps);
        break;
      default:
        BTIF_TRACE_DEBUG("Record type %d is not supported", record->hdr.type);
        break;
@@ -854,3 +858,52 @@ static int add_saps_sdp(const bluetooth_sdp_sap_record* rec) {
  }
  return sdp_handle;
}

/* Create a Multi-Profile Specification SDP record based on information stored
 * in a bluetooth_sdp_mps_record */
static int add_mps_sdp(const bluetooth_sdp_mps_record* rec) {
  uint16_t service = UUID_SERVCLASS_MPS_SC;
  uint16_t browse = UUID_SERVCLASS_PUBLIC_BROWSE_GROUP;
  bool status = true;
  uint32_t sdp_handle = 0;

  sdp_handle = SDP_CreateRecord();
  if (sdp_handle == 0) {
    LOG_ERROR("Unable to register MPS record");
    return sdp_handle;
  }

  status &= SDP_AddServiceClassIdList(sdp_handle, 1, &service);

  /* Add in the Bluetooth Profile Descriptor List */
  status &= SDP_AddProfileDescriptorList(sdp_handle, UUID_SERVCLASS_MPS_PROFILE,
                                         rec->hdr.profile_version);

  /* Add supported scenarios MPSD */
  status &= SDP_AddAttribute(sdp_handle, ATTR_ID_MPS_SUPPORTED_SCENARIOS_MPSD,
                             UINT_DESC_TYPE, (uint32_t)8,
                             (uint8_t*)&rec->supported_scenarios_mpsd);
  /* Add supported scenarios MPMD */
  status &= SDP_AddAttribute(sdp_handle, ATTR_ID_MPS_SUPPORTED_SCENARIOS_MPMD,
                             UINT_DESC_TYPE, (uint32_t)8,
                             (uint8_t*)&rec->supported_scenarios_mpmd);
  /* Add supported dependencies */
  status &= SDP_AddAttribute(sdp_handle, ATTR_ID_MPS_SUPPORTED_DEPENDENCIES,
                             UINT_DESC_TYPE, (uint32_t)2,
                             (uint8_t*)&rec->supported_dependencies);

  /* 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;
    APPL_TRACE_ERROR("%s() FAILED", __func__);
    return sdp_handle;
  }
  bta_sys_add_uuid(service); /* UUID_SERVCLASS_MPS_SC */
  APPL_TRACE_DEBUG("%s():  SDP Registered (handle 0x%08x)", __func__,
                   sdp_handle);
  return sdp_handle;
}
+11 −2
Original line number Diff line number Diff line
@@ -36,7 +36,8 @@ typedef enum {
  SDP_TYPE_PBAP_PCE,    // Phone Book Profile - Client
  SDP_TYPE_OPP_SERVER,  // Object Push Profile
  SDP_TYPE_SAP_SERVER,  // SIM Access Profile
  SDP_TYPE_DIP           // Device Identification Profile
  SDP_TYPE_DIP,         // Device Identification Profile
  SDP_TYPE_MPS          // Multi-Profile Specification
} bluetooth_sdp_types;

typedef struct _bluetooth_sdp_hdr {
@@ -111,6 +112,13 @@ typedef struct _bluetooth_sdp_dip_record {
  bool primary_record;
} bluetooth_sdp_dip_record;

typedef struct _bluetooth_sdp_mps_record {
  bluetooth_sdp_hdr_overlay hdr;
  uint8_t supported_scenarios_mpsd[8];
  uint8_t supported_scenarios_mpmd[8];
  uint8_t supported_dependencies[2];
} bluetooth_sdp_mps_record;

typedef union {
  bluetooth_sdp_hdr_overlay hdr;
  bluetooth_sdp_mas_record mas;
@@ -120,6 +128,7 @@ typedef union {
  bluetooth_sdp_ops_record ops;
  bluetooth_sdp_sap_record sap;
  bluetooth_sdp_dip_record dip;
  bluetooth_sdp_mps_record mps;
} bluetooth_sdp_record;

/** Callback for SDP search */
+9 −0
Original line number Diff line number Diff line
@@ -70,6 +70,11 @@
#define ATTR_ID_MAP_SUPPORTED_FEATURES 0x0317  /* MAP profile */
#define ATTR_ID_PBAP_SUPPORTED_FEATURES 0x0317 /* PBAP profile */

/* These values are for the MPS (Multi-Profile Specification) */
#define ATTR_ID_MPS_SUPPORTED_SCENARIOS_MPSD 0x0200
#define ATTR_ID_MPS_SUPPORTED_SCENARIOS_MPMD 0x0201
#define ATTR_ID_MPS_SUPPORTED_DEPENDENCIES 0x0202

/* These values are for the PAN profile */
#define ATTR_ID_SECURITY_DESCRIPTION 0x030A
#define ATTR_ID_NET_ACCESS_TYPE 0x030B
@@ -167,6 +172,10 @@
#define UUID_SERVCLASS_PBAP_PSE 0X112F /* Phonebook Access - PSE */
#define UUID_SERVCLASS_PHONE_ACCESS 0x1130
#define UUID_SERVCLASS_HEADSET_HS 0x1131      /* Headset - HS, from HSP v1.2 */
#define UUID_SERVCLASS_MPS_PROFILE \
  0x113A /* Multi-Profile Specification - Profile */
#define UUID_SERVCLASS_MPS_SC \
  0x113B /* Multi-Profile Specification - Service Class */
#define UUID_SERVCLASS_PNP_INFORMATION 0X1200 /* Device Identification */
#define UUID_SERVCLASS_GENERIC_NETWORKING 0X1201
#define UUID_SERVCLASS_GENERIC_FILETRANSFER 0X1202