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

Commit f6f5b442 authored by Myles Watson's avatar Myles Watson Committed by Automerger Merge Worker
Browse files

Merge "Use PDL for inquiry results with rssi" into main am: 39fd9338 am: ee43793a

parents 2ccecacf ee43793a
Loading
Loading
Loading
Loading
+0 −1
Original line number Diff line number Diff line
@@ -63,7 +63,6 @@ namespace {
bool register_event_code(bluetooth::hci::EventCode event_code) {
  switch (event_code) {
    // Inquiry
    case bluetooth::hci::EventCode::INQUIRY_RESULT_WITH_RSSI:
    case bluetooth::hci::EventCode::EXTENDED_INQUIRY_RESULT:

    // SCO
+26 −21
Original line number Diff line number Diff line
@@ -695,6 +695,11 @@ tBTM_STATUS BTM_StartInquiry(tBTM_INQ_RESULTS_CB* p_results_cb,
        get_main_thread()->Bind([](bluetooth::hci::EventView event) {
          on_incoming_hci_event(event);
        }));
    bluetooth::shim::GetHciLayer()->RegisterEventHandler(
        bluetooth::hci::EventCode::INQUIRY_RESULT_WITH_RSSI,
        get_main_thread()->Bind([](bluetooth::hci::EventView event) {
          on_incoming_hci_event(event);
        }));

    btm_cb.btm_inq_vars.registered_for_hci_events = true;
  }
@@ -1443,9 +1448,7 @@ static void btm_process_inq_results_standard(bluetooth::hci::EventView event) {
 * Returns          void
 *
 ******************************************************************************/
static void btm_process_inq_results_rssi(const uint8_t* p,
                                         uint8_t hci_evt_len) {
  uint8_t num_resp, xx;
static void btm_process_inq_results_rssi(bluetooth::hci::EventView event) {
  RawAddress bda;
  tINQ_DB_ENT* p_i;
  tBTM_INQ_RESULTS* p_cur = NULL;
@@ -1470,27 +1473,26 @@ static void btm_process_inq_results_rssi(const uint8_t* p,
    return;
  }

  STREAM_TO_UINT8(num_resp, p);
  auto rssi_view = bluetooth::hci::InquiryResultWithRssiView::Create(event);
  ASSERT(rssi_view.IsValid());
  auto responses = rssi_view.GetResponses();

  {
    constexpr uint16_t inquiry_result_size = 14;
    if (hci_evt_len < num_resp * inquiry_result_size) {
      log::error("can't fit {} results in {} bytes", num_resp, hci_evt_len);
      return;
    }
  }

  btm_cb.neighbor.classic_inquiry.results += num_resp;
  for (xx = 0; xx < num_resp; xx++) {
  btm_cb.neighbor.classic_inquiry.results += responses.size();
  for (const auto& response : responses) {
    update = false;
    /* Extract inquiry results */
    STREAM_TO_BDADDR(bda, p);
    STREAM_TO_UINT8(page_scan_rep_mode, p);
    STREAM_TO_UINT8(page_scan_per_mode, p);
    bda = bluetooth::ToRawAddress(response.address_);
    page_scan_rep_mode =
        static_cast<uint8_t>(response.page_scan_repetition_mode_);
    page_scan_per_mode = 0;  // reserved
    page_scan_mode = 0;      // reserved

    STREAM_TO_DEVCLASS(dc, p);
    STREAM_TO_UINT16(clock_offset, p);
    STREAM_TO_UINT8(rssi, p);
    dc[0] = response.class_of_device_.cod[2];
    dc[1] = response.class_of_device_.cod[1];
    dc[2] = response.class_of_device_.cod[0];

    clock_offset = response.clock_offset_;
    rssi = response.rssi_;

    p_i = btm_inq_db_find(bda);

@@ -1770,7 +1772,7 @@ void btm_process_inq_results(const uint8_t* p, uint8_t hci_evt_len,
      LOG_ALWAYS_FATAL("Please use PDL for STANDARD results");
      break;
    case BTM_INQ_RESULT_WITH_RSSI:
      btm_process_inq_results_rssi(p, hci_evt_len);
      LOG_ALWAYS_FATAL("Please use PDL for RSSI results");
      break;
    case BTM_INQ_RESULT_EXTENDED:
      btm_process_inq_results_extended(p, hci_evt_len);
@@ -2529,6 +2531,9 @@ static void on_incoming_hci_event(bluetooth::hci::EventView event) {
    case bluetooth::hci::EventCode::INQUIRY_RESULT:
      btm_process_inq_results_standard(event);
      break;
    case bluetooth::hci::EventCode::INQUIRY_RESULT_WITH_RSSI:
      btm_process_inq_results_rssi(event);
      break;
    default:
      log::warn("Dropping unhandled event: {}",
                bluetooth::hci::EventCodeText(event_code));
+0 −3
Original line number Diff line number Diff line
@@ -232,9 +232,6 @@ void btu_hcif_process_event(UNUSED_ATTR uint8_t controller_id,
  btu_hcif_log_event_metrics(hci_evt_code, p);

  switch (hci_evt_code) {
    case HCI_INQUIRY_RSSI_RESULT_EVT:
      btm_process_inq_results(p, hci_evt_len, BTM_INQ_RESULT_WITH_RSSI);
      break;
    case HCI_EXTENDED_INQUIRY_RESULT_EVT:
      btm_process_inq_results(p, hci_evt_len, BTM_INQ_RESULT_EXTENDED);
      break;