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

Commit d15bfe14 authored by Jakub Pawlowski's avatar Jakub Pawlowski Committed by Gerrit Code Review
Browse files

Merge "Advertising data handling improvements"

parents 96fb3b43 8b2a1912
Loading
Loading
Loading
Loading
+11 −6
Original line number Diff line number Diff line
@@ -52,7 +52,8 @@
#include "gap_api.h"
#endif

static void bta_dm_inq_results_cb(tBTM_INQ_RESULTS* p_inq, uint8_t* p_eir);
static void bta_dm_inq_results_cb(tBTM_INQ_RESULTS* p_inq, uint8_t* p_eir,
                                  uint8_t eir_len);
static void bta_dm_inq_cmpl_cb(void* p_result);
static void bta_dm_service_search_remname_cback(BD_ADDR bd_addr, DEV_CLASS dc,
                                                BD_NAME bd_name);
@@ -144,7 +145,8 @@ static void bta_dm_ctrl_features_rd_cmpl_cback(tBTM_STATUS result);

static void bta_dm_reset_sec_dev_pending(BD_ADDR remote_bd_addr);
static void bta_dm_remove_sec_dev_entry(BD_ADDR remote_bd_addr);
static void bta_dm_observe_results_cb(tBTM_INQ_RESULTS* p_inq, uint8_t* p_eir);
static void bta_dm_observe_results_cb(tBTM_INQ_RESULTS* p_inq, uint8_t* p_eir,
                                      uint8_t eir_len);
static void bta_dm_observe_cmpl_cb(void* p_result);
static void bta_dm_delay_role_switch_cback(void* data);
static void bta_dm_disable_timer_cback(void* data);
@@ -2220,7 +2222,8 @@ static void bta_dm_sdp_callback(uint16_t sdp_status) {
 * Returns          void
 *
 ******************************************************************************/
static void bta_dm_inq_results_cb(tBTM_INQ_RESULTS* p_inq, uint8_t* p_eir) {
static void bta_dm_inq_results_cb(tBTM_INQ_RESULTS* p_inq, uint8_t* p_eir,
                                  uint8_t eir_len) {
  tBTA_DM_SEARCH result;
  tBTM_INQ_INFO* p_inq_info;
  uint16_t service_class;
@@ -2239,6 +2242,7 @@ static void bta_dm_inq_results_cb(tBTM_INQ_RESULTS* p_inq, uint8_t* p_eir) {

  /* application will parse EIR to find out remote device name */
  result.inq_res.p_eir = p_eir;
  result.inq_res.eir_len = eir_len;

  p_inq_info = BTM_InqDbRead(p_inq->remote_bd_addr);
  if (p_inq_info != NULL) {
@@ -3930,11 +3934,11 @@ bool bta_dm_check_if_only_hd_connected(BD_ADDR peer_addr) {
 * Returns          void
 *
 ******************************************************************************/
static void bta_dm_observe_results_cb(tBTM_INQ_RESULTS* p_inq, uint8_t* p_eir) {
  ;
static void bta_dm_observe_results_cb(tBTM_INQ_RESULTS* p_inq, uint8_t* p_eir,
                                      uint8_t eir_len) {
  tBTA_DM_SEARCH result;
  tBTM_INQ_INFO* p_inq_info;
  APPL_TRACE_DEBUG("bta_dm_observe_results_cb")
  APPL_TRACE_DEBUG("bta_dm_observe_results_cb");

  bdcpy(result.inq_res.bd_addr, p_inq->remote_bd_addr);
  result.inq_res.rssi = p_inq->rssi;
@@ -3951,6 +3955,7 @@ static void bta_dm_observe_results_cb(tBTM_INQ_RESULTS* p_inq, uint8_t* p_eir) {

  /* application will parse EIR to find out remote device name */
  result.inq_res.p_eir = p_eir;
  result.inq_res.eir_len = eir_len;

  p_inq_info = BTM_InqDbRead(p_inq->remote_bd_addr);
  if (p_inq_info != NULL) {
+4 −2
Original line number Diff line number Diff line
@@ -494,14 +494,16 @@ tBTA_STATUS BTA_DmRemoveDevice(BD_ADDR bd_addr) {
 *
 ******************************************************************************/
extern const uint16_t bta_service_id_to_uuid_lkup_tbl[];
void BTA_GetEirService(uint8_t* p_eir, tBTA_SERVICE_MASK* p_services) {
void BTA_GetEirService(uint8_t* p_eir, size_t eir_len,
                       tBTA_SERVICE_MASK* p_services) {
  uint8_t xx, yy;
  uint8_t num_uuid, max_num_uuid = 32;
  uint8_t uuid_list[32 * LEN_UUID_16];
  uint16_t* p_uuid16 = (uint16_t*)uuid_list;
  tBTA_SERVICE_MASK mask;

  BTM_GetEirUuidList(p_eir, LEN_UUID_16, &num_uuid, uuid_list, max_num_uuid);
  BTM_GetEirUuidList(p_eir, eir_len, LEN_UUID_16, &num_uuid, uuid_list,
                     max_num_uuid);
  for (xx = 0; xx < num_uuid; xx++) {
    mask = 1;
    for (yy = 0; yy < BTA_MAX_SERVICE_ID; yy++) {
+4 −1
Original line number Diff line number Diff line
@@ -728,6 +728,7 @@ typedef struct {
  bool is_limited; /* true, if the limited inquiry bit is set in the CoD */
  int8_t rssi;     /* The rssi value */
  uint8_t* p_eir;  /* received EIR */
  uint8_t eir_len; /* received EIR length */
  uint8_t inq_result_type;
  uint8_t ble_addr_type;
  uint16_t ble_evt_type;
@@ -1307,12 +1308,14 @@ extern tBTA_STATUS BTA_DmRemoveDevice(BD_ADDR bd_addr);
 * Description      This function is called to get BTA service mask from EIR.
 *
 * Parameters       p_eir - pointer of EIR significant part
 *                  eir_len - EIR length
 *                  p_services - return the BTA service mask
 *
 * Returns          None
 *
 ******************************************************************************/
extern void BTA_GetEirService(uint8_t* p_eir, tBTA_SERVICE_MASK* p_services);
extern void BTA_GetEirService(uint8_t* p_eir, size_t eir_len,
                              tBTA_SERVICE_MASK* p_services);

/*******************************************************************************
 *
+7 −10
Original line number Diff line number Diff line
@@ -223,16 +223,15 @@ void bta_scan_results_cb_impl(bt_bdaddr_t bd_addr, tBT_DEVICE_TYPE device_type,
                              uint16_t ble_periodic_adv_int,
                              vector<uint8_t> value) {
  uint8_t remote_name_len;
  const uint8_t* p_eir_remote_name = NULL;
  bt_device_type_t dev_type;
  bt_property_t properties;

  p_eir_remote_name = BTM_CheckEirData(
      value.data(), BTM_EIR_COMPLETE_LOCAL_NAME_TYPE, &remote_name_len);
  const uint8_t* p_eir_remote_name = BTM_CheckAdvData(
      value, BTM_EIR_COMPLETE_LOCAL_NAME_TYPE, &remote_name_len);

  if (p_eir_remote_name == NULL) {
    p_eir_remote_name = BTM_CheckEirData(
        value.data(), BT_EIR_SHORTENED_LOCAL_NAME_TYPE, &remote_name_len);
    p_eir_remote_name = BTM_CheckAdvData(
        value, BT_EIR_SHORTENED_LOCAL_NAME_TYPE, &remote_name_len);
  }

  if ((addr_type != BLE_ADDR_RANDOM) || (p_eir_remote_name)) {
@@ -258,7 +257,6 @@ void bta_scan_results_cb_impl(bt_bdaddr_t bd_addr, tBT_DEVICE_TYPE device_type,
  btif_storage_set_remote_device_property(&(bd_addr), &properties);

  btif_storage_set_remote_addr_type(&bd_addr, addr_type);

  HAL_CBACK(bt_gatt_callbacks, scanner->scan_result_cb, ble_evt_type, addr_type,
            &bd_addr, ble_primary_phy, ble_secondary_phy, ble_advertising_sid,
            ble_tx_power, rssi, ble_periodic_adv_int, std::move(value));
@@ -278,13 +276,12 @@ void bta_scan_results_cb(tBTA_DM_SEARCH_EVT event, tBTA_DM_SEARCH* p_data) {
    return;
  }

  vector<uint8_t> value(BTGATT_MAX_ATTR_LEN);
  vector<uint8_t> value;
  if (p_data->inq_res.p_eir) {
    value.insert(value.begin(), p_data->inq_res.p_eir,
                 p_data->inq_res.p_eir + 62);
                 p_data->inq_res.p_eir + p_data->inq_res.eir_len);

    if (BTM_CheckEirData(p_data->inq_res.p_eir,
                         BTM_EIR_COMPLETE_LOCAL_NAME_TYPE, &len)) {
    if (BTM_CheckAdvData(value, BTM_EIR_COMPLETE_LOCAL_NAME_TYPE, &len)) {
      p_data->inq_res.remt_name_not_required = true;
    }
  }
+8 −7
Original line number Diff line number Diff line
@@ -348,12 +348,12 @@ static bool check_eir_remote_name(tBTA_DM_SEARCH* p_search_data,

  /* Check EIR for remote name and services */
  if (p_search_data->inq_res.p_eir) {
    p_eir_remote_name =
        BTM_CheckEirData(p_search_data->inq_res.p_eir,
    p_eir_remote_name = BTM_CheckEirData(
        p_search_data->inq_res.p_eir, p_search_data->inq_res.eir_len,
        BTM_EIR_COMPLETE_LOCAL_NAME_TYPE, &remote_name_len);
    if (!p_eir_remote_name) {
      p_eir_remote_name =
          BTM_CheckEirData(p_search_data->inq_res.p_eir,
      p_eir_remote_name = BTM_CheckEirData(
          p_search_data->inq_res.p_eir, p_search_data->inq_res.eir_len,
          BTM_EIR_SHORTENED_LOCAL_NAME_TYPE, &remote_name_len);
    }

@@ -1273,7 +1273,8 @@ static void btif_dm_search_devices_evt(uint16_t event, char* p_param) {

      /* Check EIR for remote name and services */
      if (p_search_data->inq_res.p_eir) {
        BTA_GetEirService(p_search_data->inq_res.p_eir, &services);
        BTA_GetEirService(p_search_data->inq_res.p_eir,
                          p_search_data->inq_res.eir_len, &services);
        BTIF_TRACE_DEBUG("%s()EIR BTA services = %08X", __func__,
                         (uint32_t)services);
        /* TODO:  Get the service list and check to see which uuids we got and
Loading