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

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

Merge "Use PDL for standard inquiry results" into main am: 1c8458dd am: bf3eef4e

parents 971e5a66 bf3eef4e
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:
    case bluetooth::hci::EventCode::INQUIRY_RESULT_WITH_RSSI:
    case bluetooth::hci::EventCode::EXTENDED_INQUIRY_RESULT:

+25 −21
Original line number Diff line number Diff line
@@ -26,6 +26,7 @@
 ******************************************************************************/

#include "hci_error_code.h"
#include "main/shim/helpers.h"
#include "neighbor_inquiry.h"
#define LOG_TAG "bluetooth"

@@ -689,6 +690,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,
        get_main_thread()->Bind([](bluetooth::hci::EventView event) {
          on_incoming_hci_event(event);
        }));

    btm_cb.btm_inq_vars.registered_for_hci_events = true;
  }
@@ -1320,9 +1326,7 @@ tINQ_DB_ENT* btm_inq_db_new(const RawAddress& p_bda, bool is_ble) {
 * Returns          void
 *
 ******************************************************************************/
static void btm_process_inq_results_standard(const uint8_t* p,
                                             uint8_t hci_evt_len) {
  uint8_t num_resp, xx;
static void btm_process_inq_results_standard(bluetooth::hci::EventView event) {
  RawAddress bda;
  tINQ_DB_ENT* p_i;
  tBTM_INQ_RESULTS* p_cur = NULL;
@@ -1344,27 +1348,24 @@ static void btm_process_inq_results_standard(const uint8_t* p,
    return;
  }

  STREAM_TO_UINT8(num_resp, p);
  auto standard_view = bluetooth::hci::InquiryResultView::Create(event);
  ASSERT(standard_view.IsValid());
  auto responses = standard_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) {
    /* 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.bd_addr_);
    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_UINT8(page_scan_mode, 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];

    STREAM_TO_DEVCLASS(dc, p);
    STREAM_TO_UINT16(clock_offset, p);
    clock_offset = response.clock_offset_;

    p_i = btm_inq_db_find(bda);

@@ -1766,7 +1767,7 @@ void btm_process_inq_results(const uint8_t* p, uint8_t hci_evt_len,
                             uint8_t inq_res_mode) {
  switch (inq_res_mode) {
    case BTM_INQ_RESULT_STANDARD:
      btm_process_inq_results_standard(p, 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);
@@ -2525,6 +2526,9 @@ static void on_incoming_hci_event(bluetooth::hci::EventView event) {
    case bluetooth::hci::EventCode::INQUIRY_COMPLETE:
      on_inquiry_complete(event);
      break;
    case bluetooth::hci::EventCode::INQUIRY_RESULT:
      btm_process_inq_results_standard(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_RESULT_EVT:
      btm_process_inq_results(p, hci_evt_len, BTM_INQ_RESULT_STANDARD);
      break;
    case HCI_INQUIRY_RSSI_RESULT_EVT:
      btm_process_inq_results(p, hci_evt_len, BTM_INQ_RESULT_WITH_RSSI);
      break;