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

Commit 12cd88cd authored by Łukasz Rymanowski's avatar Łukasz Rymanowski
Browse files

btm: Enhance with targeted announcements

This allows to register for the observer for targeted announcements.

Bug: 248340126
Tag: #feature
Test: atest BluetoothInstrumentationTests

Merged-In: Ic33306aa81d0c35332be9c73741fc2e7eaea0f51
Change-Id: Ic33306aa81d0c35332be9c73741fc2e7eaea0f51
(cherry picked from commit d78b174a)
parent 7d817c1a
Loading
Loading
Loading
Loading
+9 −0
Original line number Diff line number Diff line
@@ -726,6 +726,15 @@ void bluetooth::shim::BTM_BleOpportunisticObserve(
  }
}

void bluetooth::shim::BTM_BleTargetAnnouncementObserve(
    bool enable, tBTM_INQ_RESULTS_CB* p_results_cb) {
  if (enable) {
    btm_cb.ble_ctr_cb.p_target_announcement_obs_results_cb = p_results_cb;
  } else {
    btm_cb.ble_ctr_cb.p_target_announcement_obs_results_cb = nullptr;
  }
}

void bluetooth::shim::BTM_EnableInterlacedPageScan() {
  Stack::GetInstance()->GetBtm()->SetInterlacedPageScan();
}
+17 −0
Original line number Diff line number Diff line
@@ -123,6 +123,23 @@ tBTM_STATUS BTM_BleObserve(bool start, uint8_t duration,
void BTM_BleOpportunisticObserve(bool enable,
                                 tBTM_INQ_RESULTS_CB* p_results_cb);

/*******************************************************************************
 *
 * Function         BTM_BleTargetAnnouncementObserve
 *
 * Description      Register/Unregister client interested in the targeted
 *                  announcements. Not that it is client responsible for parsing
 *                  advertising data.
 *
 * Parameters       start: start or stop observe.
 *                  p_results_cb: callback for results.
 *
 * Returns          void
 *
 ******************************************************************************/
void BTM_BleTargetAnnouncementObserve(bool enable,
                                      tBTM_INQ_RESULTS_CB* p_results_cb);

void BTM_EnableInterlacedInquiryScan();

void BTM_EnableInterlacedPageScan();
+32 −1
Original line number Diff line number Diff line
@@ -464,6 +464,21 @@ void BTM_BleOpportunisticObserve(bool enable,
  }
}

void BTM_BleTargetAnnouncementObserve(bool enable,
                                      tBTM_INQ_RESULTS_CB* p_results_cb) {
  if (bluetooth::shim::is_gd_shim_enabled()) {
    bluetooth::shim::BTM_BleTargetAnnouncementObserve(enable, p_results_cb);
    // NOTE: passthrough, no return here. GD would send the results back to BTM,
    // and it needs the callbacks set properly.
  }

  if (enable) {
    btm_cb.ble_ctr_cb.p_target_announcement_obs_results_cb = p_results_cb;
  } else {
    btm_cb.ble_ctr_cb.p_target_announcement_obs_results_cb = NULL;
  }
}

/*******************************************************************************
 *
 * Function         BTM_BleObserve
@@ -2759,6 +2774,14 @@ void btm_ble_process_adv_pkt_cont(uint16_t evt_type, tBLE_ADDR_TYPE addr_type,
                                     adv_data.size());
  }

  tBTM_INQ_RESULTS_CB* p_target_announcement_obs_results_cb =
      btm_cb.ble_ctr_cb.p_target_announcement_obs_results_cb;
  if (p_target_announcement_obs_results_cb) {
    (p_target_announcement_obs_results_cb)(
        (tBTM_INQ_RESULTS*)&p_i->inq_info.results,
        const_cast<uint8_t*>(adv_data.data()), adv_data.size());
  }

  uint8_t result = btm_ble_is_discoverable(bda, adv_data);
  if (result == 0) {
    // Device no longer discoverable so discard outstanding advertising packet
@@ -2856,6 +2879,14 @@ void btm_ble_process_adv_pkt_cont_for_inquiry(
        const_cast<uint8_t*>(advertising_data.data()), advertising_data.size());
  }

  tBTM_INQ_RESULTS_CB* p_target_announcement_obs_results_cb =
      btm_cb.ble_ctr_cb.p_target_announcement_obs_results_cb;
  if (p_target_announcement_obs_results_cb) {
    (p_target_announcement_obs_results_cb)(
        (tBTM_INQ_RESULTS*)&p_i->inq_info.results,
        const_cast<uint8_t*>(advertising_data.data()), advertising_data.size());
  }

  uint8_t result = btm_ble_is_discoverable(bda, advertising_data);
  if (result == 0) {
    return;
+3 −0
Original line number Diff line number Diff line
@@ -245,6 +245,9 @@ typedef struct {
  /* opportunistic observer */
  tBTM_INQ_RESULTS_CB* p_opportunistic_obs_results_cb;

  /* target announcement observer */
  tBTM_INQ_RESULTS_CB* p_target_announcement_obs_results_cb;

  /* background connection procedure cb value */
  uint16_t scan_int;
  uint16_t scan_win;
+17 −0
Original line number Diff line number Diff line
@@ -194,6 +194,23 @@ extern tBTM_STATUS BTM_BleObserve(bool start, uint8_t duration,
extern void BTM_BleOpportunisticObserve(bool enable,
                                        tBTM_INQ_RESULTS_CB* p_results_cb);

/*******************************************************************************
 *
 * Function         BTM_BleTargetAnnouncementObserve
 *
 * Description      Register/Unregister client interested in the targeted
 *                  announcements. Not that it is client responsible for parsing
 *                  advertising data.
 *
 * Parameters       start: start or stop observe.
 *                  p_results_cb: callback for results.
 *
 * Returns          void
 *
 ******************************************************************************/
extern void BTM_BleTargetAnnouncementObserve(bool enable,
                                             tBTM_INQ_RESULTS_CB* p_results_cb);

/** Returns local device encryption root (ER) */
const Octet16& BTM_GetDeviceEncRoot();

Loading