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

Commit 6e7ede38 authored by Treehugger Robot's avatar Treehugger Robot Committed by Gerrit Code Review
Browse files

Merge changes I9c6cce21,I808a6fd2,I263e4cfd,I522fcfa3,I6abb2319, ...

* changes:
  Remove unused stack/btm/btm_ble_int_types::tINQ_LE_BDADDR
  Remove constant var tBTM_CB::tBTM_BLE_CB::tBTM_BLE_INQ_CB::scan_duplicate_filter
  Remove never-set vars tBTM_CB::tBTM_BLE_CB::tBTM_BLE_INQ_CB::
  Add Api tBTM_CB::tBTM_BLE_CB::tBTM_BLE_INQ_CB::adv_mode
  Remove unused vars tBTM_CB::tBTM_BLE_CB::tBTM_BLE_INQ_CB
  Expand clever stack/btm/btm_ble_gap::btm_set_conn_mode_adv_init_addr
  Remove tBTM_CB::tBTM_BLE_CB::tBTM_BLE_INQ_CB::tx_power
  Remove unused vars tBTM_CB::tBTM_BLE_CB::tBTM_LE_RANDOM_CB
  Remove never-set var tBTM_CB::tBTM_BLE_CB::mixed_mode
  Const-ify size tBTM_CB::tBTM_BLE_CB::link_count[]
  Remove unused var tBTM_CB::tBTM_BLE_CB::enabled
  Add Api around tBTM_CB::paging
  Remove tBTM_CB::discing can never be true
parents f8a5cd3c 9cb1e52a
Loading
Loading
Loading
Loading
+13 −21
Original line number Diff line number Diff line
@@ -2329,13 +2329,6 @@ void btm_acl_reset_paging(void) {
void btm_acl_paging(BT_HDR* p, const RawAddress& bda) {
  tBTM_SEC_DEV_REC* p_dev_rec;

  VLOG(2) << __func__ << ":" << btm_cb.discing << " , paging:" << btm_cb.paging
          << " BDA: " << bda;

  if (btm_cb.discing) {
    btm_cb.paging = true;
    fixed_queue_enqueue(btm_cb.page_queue, p);
  } else {
  if (!BTM_IsAclConnectionUp(bda, BT_TRANSPORT_BR_EDR)) {
    VLOG(1) << "connecting_bda: " << btm_cb.connecting_bda;
    if (btm_cb.paging && bda == btm_cb.connecting_bda) {
@@ -2354,7 +2347,6 @@ void btm_acl_paging(BT_HDR* p, const RawAddress& bda) {
    btu_hcif_send_cmd(LOCAL_BR_EDR_CONTROLLER_ID, p);
  }
}
}

/*******************************************************************************
 *
+28 −34
Original line number Diff line number Diff line
@@ -420,7 +420,6 @@ tBTM_STATUS BTM_BleObserve(bool start, uint8_t duration,
          p_inq->scan_type, (uint16_t)scan_interval, (uint16_t)scan_window,
          btm_cb.ble_ctr_cb.addr_mgnt_cb.own_addr_type, BTM_BLE_DEFAULT_SFP);

      p_inq->scan_duplicate_filter = BTM_BLE_DUPLICATE_DISABLE;
      status = btm_ble_start_scan();
    }

@@ -603,9 +602,7 @@ bool BTM_BleConfigPrivacy(bool privacy_mode) {
     * address in controller */
    if (controller_get_interface()->supports_ble_privacy()) {
      gap_ble_attr_value.addr_resolution = 1;
      /* check vendor specific capability */
      p_cb->privacy_mode =
          btm_cb.ble_ctr_cb.mixed_mode ? BTM_PRIVACY_MIXED : BTM_PRIVACY_1_2;
      p_cb->privacy_mode = BTM_PRIVACY_1_2;
    } else /* 4.1/4.0 controller */
      p_cb->privacy_mode = BTM_PRIVACY_1_1;
  }
@@ -675,10 +672,15 @@ static uint8_t btm_set_conn_mode_adv_init_addr(
  uint8_t evt_type;
  tBTM_SEC_DEV_REC* p_dev_rec;

  evt_type =
      (p_cb->connectable_mode == BTM_BLE_NON_CONNECTABLE)
          ? ((p_cb->scan_rsp) ? BTM_BLE_DISCOVER_EVT : BTM_BLE_NON_CONNECT_EVT)
          : BTM_BLE_CONNECT_EVT;
  if (p_cb->connectable_mode == BTM_BLE_NON_CONNECTABLE) {
    if (p_cb->scan_rsp) {
      evt_type = BTM_BLE_DISCOVER_EVT;
    } else {
      evt_type = BTM_BLE_NON_CONNECT_EVT;
    }
  } else {
    evt_type = BTM_BLE_CONNECT_EVT;
  }

  if (evt_type == BTM_BLE_CONNECT_EVT) {
    evt_type = p_cb->directed_conn;
@@ -833,11 +835,6 @@ uint16_t BTM_BleReadConnectability() {
static void btm_ble_select_adv_interval(uint8_t evt_type,
                                        uint16_t* p_adv_int_min,
                                        uint16_t* p_adv_int_max) {
  tBTM_BLE_INQ_CB* p_cb = &btm_cb.ble_ctr_cb.inq_var;
  if (p_cb->adv_interval_min && p_cb->adv_interval_max) {
    *p_adv_int_min = p_cb->adv_interval_min;
    *p_adv_int_max = p_cb->adv_interval_max;
  } else {
  switch (evt_type) {
    case BTM_BLE_CONNECT_EVT:
    case BTM_BLE_CONNECT_LO_DUTY_DIR_EVT:
@@ -860,8 +857,6 @@ static void btm_ble_select_adv_interval(uint8_t evt_type,
      break;
  }
}
  return;
}

/*******************************************************************************
 *
@@ -1170,7 +1165,6 @@ tBTM_STATUS btm_ble_start_inquiry(uint8_t duration) {
    /* enable IRK list */
    btm_ble_enable_resolving_list_for_platform(BTM_BLE_RL_SCAN);
    p_ble_cb->inq_var.scan_type = BTM_BLE_SCAN_MODE_ACTI;
    p_ble_cb->inq_var.scan_duplicate_filter = BTM_BLE_DUPLICATE_DISABLE;
    status = btm_ble_start_scan();
  } else if ((p_ble_cb->inq_var.scan_interval !=
              BTM_BLE_LOW_LATENCY_SCAN_INT) ||
@@ -1924,7 +1918,7 @@ void btm_ble_process_phy_update_pkt(uint8_t len, uint8_t* data) {
tBTM_STATUS btm_ble_start_scan(void) {
  tBTM_BLE_INQ_CB* p_inq = &btm_cb.ble_ctr_cb.inq_var;
  /* start scan, disable duplicate filtering */
  btm_send_hci_scan_enable(BTM_BLE_SCAN_ENABLE, p_inq->scan_duplicate_filter);
  btm_send_hci_scan_enable(BTM_BLE_SCAN_ENABLE, BTM_BLE_DUPLICATE_DISABLE);

  if (p_inq->scan_type == BTM_BLE_SCAN_MODE_ACTI)
    btm_ble_set_topology_mask(BTM_BLE_STATE_ACTIVE_SCAN_BIT);
+12 −22
Original line number Diff line number Diff line
@@ -96,15 +96,6 @@ typedef struct {
  uint8_t* p_pad;
} tBTM_BLE_LOCAL_ADV_DATA;

typedef struct {
  /* Used for determining if a response has already been received for the
   * current inquiry operation. (We do not want to flood the caller with
   * multiple responses from the same device. */
  uint32_t inq_count;
  bool scan_rsp;
  tBLE_BD_ADDR le_bda;
} tINQ_LE_BDADDR;

#define BTM_BLE_ISVALID_PARAM(x, min, max) \
  (((x) >= (min) && (x) <= (max)) || ((x) == BTM_BLE_CONN_PARAM_UNDEF))

@@ -114,30 +105,32 @@ typedef struct {
  uint32_t scan_window;
  uint32_t scan_interval;
  uint8_t scan_type;             /* current scan type: active or passive */
  uint8_t scan_duplicate_filter; /* duplicate filter enabled for scan */
  uint16_t adv_interval_min;
  uint16_t adv_interval_max;

  tBTM_BLE_AFP afp; /* advertising filter policy */
  tBTM_BLE_SFP sfp; /* scanning filter policy */

  tBLE_ADDR_TYPE adv_addr_type;
  uint8_t evt_type;

  uint8_t adv_mode;
  void enable_advertising_mode() { adv_mode = BTM_BLE_ADV_ENABLE; }
  void disable_advertising_mode() { adv_mode = BTM_BLE_ADV_DISABLE; }
  bool is_advertising_mode_enabled() const {
    return (adv_mode == BTM_BLE_ADV_ENABLE);
  }

  tBLE_BD_ADDR direct_bda;
  tBTM_BLE_EVT directed_conn;
  bool fast_adv_on;
  alarm_t* fast_adv_timer;

  /* inquiry BD addr database */
  uint8_t num_bd_entries;
  uint8_t max_bd_entries;
  tBTM_BLE_LOCAL_ADV_DATA adv_data;
  tBTM_BLE_ADV_CHNL_MAP adv_chnl_map;

  alarm_t* inquiry_timer;
  bool scan_rsp;
  uint8_t state; /* Current state that the inquiry process is in */
  int8_t tx_power;
} tBTM_BLE_INQ_CB;

/* random address resolving complete callback */
@@ -149,9 +142,6 @@ typedef void(tBTM_BLE_ADDR_CBACK)(const RawAddress& static_random, void* p);
typedef struct {
  tBLE_ADDR_TYPE own_addr_type; /* local device LE address type */
  RawAddress private_addr;
  RawAddress random_bda;
  tBTM_BLE_ADDR_CBACK* p_generate_cback;
  void* p;
  alarm_t* refresh_raddr_timer;
} tBTM_LE_RANDOM_CB;

@@ -224,6 +214,7 @@ typedef uint8_t tBTM_PRIVACY_MODE;
*/
constexpr uint8_t kBTM_BLE_INQUIRY_ACTIVE = 0x10;
constexpr uint8_t kBTM_BLE_OBSERVE_ACTIVE = 0x80;
constexpr size_t kMasterAndSlaveCount = 2;

typedef struct {
 private:
@@ -289,9 +280,6 @@ typedef struct {
  /* random address management control block */
  tBTM_LE_RANDOM_CB addr_mgnt_cb;

  bool enabled;

  bool mixed_mode;                   /* privacy 1.2 mixed mode is on or not */
  tBTM_PRIVACY_MODE privacy_mode;    /* privacy mode */
  uint8_t resolving_list_avail_size; /* resolving list available size */
  tBTM_BLE_RESOLVE_Q resolving_list_pend_q; /* Resolving list queue */
@@ -301,7 +289,9 @@ typedef struct {

  /* current BLE link state */
  tBTM_BLE_STATE_MASK cur_states; /* bit mask of tBTM_BLE_STATE */
  uint8_t link_count[2];          /* total link count master and slave*/

  uint8_t
      link_count[kMasterAndSlaveCount]; /* total link count master and slave*/
} tBTM_BLE_CB;

#endif  // BTM_BLE_INT_TYPES_H
+7 −1
Original line number Diff line number Diff line
@@ -259,8 +259,14 @@ typedef struct {
  bool is_paging;     /* true, if paging is in progess */
  bool is_inquiry;    /* true, if inquiry is in progess */
  fixed_queue_t* page_queue;

  bool paging;
  bool discing;
  void set_paging() { paging = true; }
  void reset_paging() { paging = false; }
  bool is_paging_active() const {
    return paging;
  }  // TODO remove all this paging state

  fixed_queue_t* sec_pending_q; /* pending sequrity requests in
                                   tBTM_SEC_QUEUE_ENTRY format */

+0 −3
Original line number Diff line number Diff line
@@ -3706,9 +3706,6 @@ void btm_sec_disconnected(uint16_t handle, uint8_t reason) {
  tBTM_SEC_CALLBACK* p_callback = NULL;
  tBT_TRANSPORT transport = BT_TRANSPORT_BR_EDR;

  /* If page was delayed for disc complete, can do it now */
  btm_cb.discing = false;

  btm_acl_resubmit_page();

  if (!p_dev_rec) return;