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

Commit 9a778265 authored by Myles Watson's avatar Myles Watson Committed by Gerrit Code Review
Browse files

Merge changes I83e7a6ee,I96dcc035,I9e99e7fd,I151db255,Ibfd5939b into main

* changes:
  Remove unused btm_ble_process_ functions
  Remove LE Events that aren't handled in btu_hcif
  Clean up LE event registration in the shim
  Skip btu_hcif for BQR events
  Move parsing of BQR into hci
parents e65a8cc0 975b94e4
Loading
Loading
Loading
Loading
+12 −75
Original line number Diff line number Diff line
@@ -37,6 +37,7 @@
#include "stack/include/bt_hdr.h"
#include "stack/include/bt_types.h"
#include "stack/include/btm_iso_api.h"
#include "stack/include/dev_hci_link_interface.h"
#include "stack/include/hcimsgs.h"
#include "stack/include/main_thread.h"

@@ -76,72 +77,10 @@ bool register_event_code(bluetooth::hci::EventCode event_code) {
  }
};

bool is_valid_subevent_code(bluetooth::hci::SubeventCode subevent_code) {
static bool register_subevent_code(bluetooth::hci::SubeventCode subevent_code) {
  switch (subevent_code) {
    case bluetooth::hci::SubeventCode::CONNECTION_UPDATE_COMPLETE:
    case bluetooth::hci::SubeventCode::DATA_LENGTH_CHANGE:
    case bluetooth::hci::SubeventCode::ENHANCED_CONNECTION_COMPLETE:
    case bluetooth::hci::SubeventCode::PHY_UPDATE_COMPLETE:
    case bluetooth::hci::SubeventCode::READ_REMOTE_FEATURES_COMPLETE:
    case bluetooth::hci::SubeventCode::REMOTE_CONNECTION_PARAMETER_REQUEST:
    case bluetooth::hci::SubeventCode::READ_LOCAL_P256_PUBLIC_KEY_COMPLETE:
    case bluetooth::hci::SubeventCode::GENERATE_DHKEY_COMPLETE:
    case bluetooth::hci::SubeventCode::DIRECTED_ADVERTISING_REPORT:
    case bluetooth::hci::SubeventCode::EXTENDED_ADVERTISING_REPORT:
    case bluetooth::hci::SubeventCode::PERIODIC_ADVERTISING_SYNC_ESTABLISHED:
    case bluetooth::hci::SubeventCode::PERIODIC_ADVERTISING_REPORT:
    case bluetooth::hci::SubeventCode::PERIODIC_ADVERTISING_SYNC_LOST:
    case bluetooth::hci::SubeventCode::SCAN_TIMEOUT:
    case bluetooth::hci::SubeventCode::ADVERTISING_SET_TERMINATED:
    case bluetooth::hci::SubeventCode::SCAN_REQUEST_RECEIVED:
    case bluetooth::hci::SubeventCode::CHANNEL_SELECTION_ALGORITHM:
    case bluetooth::hci::SubeventCode::CONNECTIONLESS_IQ_REPORT:
    case bluetooth::hci::SubeventCode::CONNECTION_IQ_REPORT:
    case bluetooth::hci::SubeventCode::CTE_REQUEST_FAILED:
    case bluetooth::hci::SubeventCode::
        PERIODIC_ADVERTISING_SYNC_TRANSFER_RECEIVED:
    case bluetooth::hci::SubeventCode::CIS_ESTABLISHED:
    case bluetooth::hci::SubeventCode::CIS_REQUEST:
    case bluetooth::hci::SubeventCode::CREATE_BIG_COMPLETE:
    case bluetooth::hci::SubeventCode::TERMINATE_BIG_COMPLETE:
    case bluetooth::hci::SubeventCode::BIG_SYNC_ESTABLISHED:
    case bluetooth::hci::SubeventCode::BIG_SYNC_LOST:
    case bluetooth::hci::SubeventCode::REQUEST_PEER_SCA_COMPLETE:
    case bluetooth::hci::SubeventCode::PATH_LOSS_THRESHOLD:
    case bluetooth::hci::SubeventCode::TRANSMIT_POWER_REPORTING:
    case bluetooth::hci::SubeventCode::BIG_INFO_ADVERTISING_REPORT:
    case bluetooth::hci::SubeventCode::ADVERTISING_REPORT:
    case bluetooth::hci::SubeventCode::LONG_TERM_KEY_REQUEST:
      return true;
    default:
      return false;
  }
}

static bool subevent_already_registered_in_le_hci_layer(
    bluetooth::hci::SubeventCode subevent_code) {
  switch (subevent_code) {
    case bluetooth::hci::SubeventCode::CONNECTION_COMPLETE:
    case bluetooth::hci::SubeventCode::CONNECTION_UPDATE_COMPLETE:
    case bluetooth::hci::SubeventCode::DATA_LENGTH_CHANGE:
    case bluetooth::hci::SubeventCode::ENHANCED_CONNECTION_COMPLETE:
    case bluetooth::hci::SubeventCode::PHY_UPDATE_COMPLETE:
    case bluetooth::hci::SubeventCode::REMOTE_CONNECTION_PARAMETER_REQUEST:
    case bluetooth::hci::SubeventCode::ADVERTISING_SET_TERMINATED:
    case bluetooth::hci::SubeventCode::SCAN_REQUEST_RECEIVED:
    case bluetooth::hci::SubeventCode::SCAN_TIMEOUT:
    case bluetooth::hci::SubeventCode::ADVERTISING_REPORT:
    case bluetooth::hci::SubeventCode::DIRECTED_ADVERTISING_REPORT:
    case bluetooth::hci::SubeventCode::EXTENDED_ADVERTISING_REPORT:
    case bluetooth::hci::SubeventCode::PERIODIC_ADVERTISING_REPORT:
    case bluetooth::hci::SubeventCode::PERIODIC_ADVERTISING_SYNC_ESTABLISHED:
    case bluetooth::hci::SubeventCode::PERIODIC_ADVERTISING_SYNC_LOST:
    case bluetooth::hci::SubeventCode::
        PERIODIC_ADVERTISING_SYNC_TRANSFER_RECEIVED:
    case bluetooth::hci::SubeventCode::TRANSMIT_POWER_REPORTING:
    case bluetooth::hci::SubeventCode::BIG_INFO_ADVERTISING_REPORT:
      return true;
    case bluetooth::hci::SubeventCode::READ_REMOTE_FEATURES_COMPLETE:
    case bluetooth::hci::SubeventCode::READ_LOCAL_P256_PUBLIC_KEY_COMPLETE:
    case bluetooth::hci::SubeventCode::GENERATE_DHKEY_COMPLETE:
    case bluetooth::hci::SubeventCode::CHANNEL_SELECTION_ALGORITHM:
@@ -156,7 +95,7 @@ static bool subevent_already_registered_in_le_hci_layer(
    case bluetooth::hci::SubeventCode::BIG_SYNC_LOST:
    case bluetooth::hci::SubeventCode::REQUEST_PEER_SCA_COMPLETE:
    case bluetooth::hci::SubeventCode::PATH_LOSS_THRESHOLD:
    case bluetooth::hci::SubeventCode::LONG_TERM_KEY_REQUEST:
      return true;
    default:
      return false;
  }
@@ -214,12 +153,15 @@ static void subevent_callback(

static void vendor_specific_event_callback(
    bluetooth::hci::VendorSpecificEventView vendor_specific_event_view) {
  if (!send_data_upwards) {
  auto bqr =
      bluetooth::hci::BqrEventView::CreateOptional(vendor_specific_event_view);
  if (!bqr) {
    return;
  }
  send_data_upwards.Run(
      FROM_HERE,
      WrapPacketAndCopy(MSG_HC_TO_STACK_HCI_EVT, &vendor_specific_event_view));

  auto payload = vendor_specific_event_view.GetPayload();
  std::vector<uint8_t> bytes{payload.begin(), payload.end()};
  btm_vendor_specific_evt(bytes.data(), bytes.size());
}

void OnTransmitPacketCommandComplete(command_complete_cb complete_callback,
@@ -440,21 +382,16 @@ void bluetooth::shim::hci_on_reset_complete() {
       subevent_code_raw++) {
    auto subevent_code =
        static_cast<bluetooth::hci::SubeventCode>(subevent_code_raw);
    if (!is_valid_subevent_code(subevent_code)) {
    if (!register_subevent_code(subevent_code)) {
      continue;
    }
    if (subevent_already_registered_in_le_hci_layer(subevent_code)) {
      continue;
    }

    cpp::register_le_event(subevent_code);
  }

  // TODO handle BQR event in GD
  auto handler = bluetooth::shim::GetGdShimHandler();
  bluetooth::shim::GetVendorSpecificEventManager()->RegisterEventHandler(
      bluetooth::hci::VseSubeventCode::BQR_EVENT,
      handler->Bind(cpp::vendor_specific_event_callback));
      get_main_thread()->Bind(cpp::vendor_specific_event_callback));

  cpp::register_for_iso();
}
+0 −195
Original line number Diff line number Diff line
@@ -2428,185 +2428,6 @@ void btm_ble_process_adv_addr(RawAddress& bda, tBLE_ADDR_TYPE* addr_type) {
  }
}

/**
 * This function is called when extended advertising report event is received .
 * It updates the inquiry database. If the inquiry database is full, the oldest
 * entry is discarded.
 */
void btm_ble_process_ext_adv_pkt(uint8_t data_len, const uint8_t* data) {
  RawAddress bda, direct_address;
  const uint8_t* p = data;
  uint8_t addr_type, num_reports, pkt_data_len, primary_phy, secondary_phy,
      advertising_sid;
  int8_t rssi, tx_power;
  uint16_t event_type, periodic_adv_int, direct_address_type;
  size_t bytes_to_process;

  /* Only process the results if the inquiry is still active */
  if (!btm_cb.ble_ctr_cb.is_ble_scan_active()) return;

  bytes_to_process = 1;

  if (data_len < bytes_to_process) {
    log::error(
        "Malformed LE extended advertising packet: not enough room for num "
        "reports");
    return;
  }

  /* Extract the number of reports in this event. */
  STREAM_TO_UINT8(num_reports, p);

  while (num_reports--) {
    bytes_to_process += 24;
    if (data_len < bytes_to_process) {
      log::error(
          "Malformed LE extended advertising packet: not enough room for "
          "metadata");
      return;
    }

    /* Extract inquiry results */
    STREAM_TO_UINT16(event_type, p);
    STREAM_TO_UINT8(addr_type, p);
    STREAM_TO_BDADDR(bda, p);
    STREAM_TO_UINT8(primary_phy, p);
    STREAM_TO_UINT8(secondary_phy, p);
    STREAM_TO_UINT8(advertising_sid, p);
    STREAM_TO_INT8(tx_power, p);
    STREAM_TO_INT8(rssi, p);
    STREAM_TO_UINT16(periodic_adv_int, p);
    STREAM_TO_UINT8(direct_address_type, p);
    STREAM_TO_BDADDR(direct_address, p);
    STREAM_TO_UINT8(pkt_data_len, p);

    const uint8_t* pkt_data = p;
    p += pkt_data_len; /* Advance to the the next packet*/

    bytes_to_process += pkt_data_len;
    if (data_len < bytes_to_process) {
      log::error(
          "Malformed LE extended advertising packet: not enough room for "
          "packet data");
      return;
    }

    if (rssi >= 21 && rssi <= 126) {
      log::error("bad rssi value in advertising report: {}", rssi);
    }

    // Store this to pass up the callback chain to GattService#onScanResult for
    // the check in ScanFilter#matches
    RawAddress original_bda = bda;

    if (addr_type != BLE_ADDR_ANONYMOUS) {
      btm_ble_process_adv_addr(bda, &addr_type);
    }

    btm_ble_process_adv_pkt_cont(
        event_type, addr_type, bda, primary_phy, secondary_phy, advertising_sid,
        tx_power, rssi, periodic_adv_int, pkt_data_len, pkt_data, original_bda);
  }
}

/**
 * This function is called when advertising report event is received. It updates
 * the inquiry database. If the inquiry database is full, the oldest entry is
 * discarded.
 */
void btm_ble_process_adv_pkt(uint8_t data_len, const uint8_t* data) {
  RawAddress bda;
  const uint8_t* p = data;
  uint8_t legacy_evt_type, addr_type, num_reports, pkt_data_len;
  int8_t rssi;
  size_t bytes_to_process;

  /* Only process the results if the inquiry is still active */
  if (!btm_cb.ble_ctr_cb.is_ble_scan_active()) return;

  bytes_to_process = 1;

  if (data_len < bytes_to_process) {
    log::error(
        "Malformed LE advertising packet: not enough room for num reports");
    return;
  }

  /* Extract the number of reports in this event. */
  STREAM_TO_UINT8(num_reports, p);

  while (num_reports--) {
    bytes_to_process += 9;

    if (data_len < bytes_to_process) {
      log::error(
          "Malformed LE advertising packet: not enough room for metadata");
      return;
    }

    /* Extract inquiry results */
    STREAM_TO_UINT8(legacy_evt_type, p);
    STREAM_TO_UINT8(addr_type, p);
    STREAM_TO_BDADDR(bda, p);
    STREAM_TO_UINT8(pkt_data_len, p);

    const uint8_t* pkt_data = p;
    p += pkt_data_len; /* Advance to the the rssi byte */

    // include rssi for this check
    bytes_to_process += pkt_data_len + 1;
    if (data_len < bytes_to_process) {
      log::error(
          "Malformed LE advertising packet: not enough room for packet data "
          "and/or RSSI");
      return;
    }

    STREAM_TO_INT8(rssi, p);

    if (rssi >= 21 && rssi <= 126) {
      log::error("bad rssi value in advertising report: {}", rssi);
    }

    // Pass up the address to GattService#onScanResult to use in
    // ScanFilter#matches
    RawAddress original_bda = bda;

    btm_ble_process_adv_addr(bda, &addr_type);

    uint16_t event_type;
    event_type = 1 << BLE_EVT_LEGACY_BIT;
    if (legacy_evt_type == BTM_BLE_ADV_IND_EVT) {
      event_type |=
          (1 << BLE_EVT_CONNECTABLE_BIT) | (1 << BLE_EVT_SCANNABLE_BIT);
    } else if (legacy_evt_type == BTM_BLE_ADV_DIRECT_IND_EVT) {
      event_type |=
          (1 << BLE_EVT_CONNECTABLE_BIT) | (1 << BLE_EVT_DIRECTED_BIT);
    } else if (legacy_evt_type == BTM_BLE_ADV_SCAN_IND_EVT) {
      event_type |= (1 << BLE_EVT_SCANNABLE_BIT);
    } else if (legacy_evt_type == BTM_BLE_ADV_NONCONN_IND_EVT) {
      event_type = (1 << BLE_EVT_LEGACY_BIT);              // 0x0010;
    } else if (legacy_evt_type == BTM_BLE_SCAN_RSP_EVT) {  // SCAN_RSP;
      // We can't distinguish between "SCAN_RSP to an ADV_IND", and "SCAN_RSP to
      // an ADV_SCAN_IND", so always return "SCAN_RSP to an ADV_IND"
      event_type |= (1 << BLE_EVT_CONNECTABLE_BIT) |
                    (1 << BLE_EVT_SCANNABLE_BIT) |
                    (1 << BLE_EVT_SCAN_RESPONSE_BIT);
    } else {
      log::error(
          "Malformed LE Advertising Report Event - unsupported "
          "legacy_event_type 0x{:02x}",
          legacy_evt_type);
      return;
    }

    btm_ble_process_adv_pkt_cont(
        event_type, addr_type, bda, PHY_LE_1M, PHY_LE_NO_PACKET, NO_ADI_PRESENT,
        TX_POWER_NOT_PRESENT, rssi, 0x00 /* no periodic adv */, pkt_data_len,
        pkt_data, original_bda);
  }
}

/**
 * This function is called after random address resolution is done, and proceed
 * to process adv packet.
@@ -2861,22 +2682,6 @@ void btm_ble_process_adv_pkt_cont_for_inquiry(
  }
}

void btm_ble_process_phy_update_pkt(uint8_t len, uint8_t* data) {
  uint8_t status, tx_phy, rx_phy;
  uint16_t handle;

  LOG_ASSERT(len == 5);
  uint8_t* p = data;
  STREAM_TO_UINT8(status, p);
  STREAM_TO_UINT16(handle, p);
  handle = handle & 0x0FFF;
  STREAM_TO_UINT8(tx_phy, p);
  STREAM_TO_UINT8(rx_phy, p);

  gatt_notify_phy_updated(static_cast<tHCI_STATUS>(status), handle, tx_phy,
                          rx_phy);
}

/*******************************************************************************
 *
 * Function         btm_ble_start_scan
+16 −22
Original line number Diff line number Diff line
@@ -48,6 +48,7 @@
#include "stack/include/bt_types.h"
#include "stack/include/btm_api.h"
#include "stack/include/btm_ble_privacy.h"
#include "stack/include/hcidefs.h"
#include "stack/include/l2cap_controller_interface.h"
#include "types/raw_address.h"

@@ -514,32 +515,18 @@ tBTM_STATUS BTM_RegisterForVSEvents(tBTM_VS_EVT_CB* p_cb, bool is_register) {
 *
 * Function         btm_vendor_specific_evt
 *
 * Description      Process event HCI_VENDOR_SPECIFIC_EVT
 * Description      Process event HCI_VENDOR_SPECIFIC_EVT (BQR)
 *
 * Returns          void
 *
 ******************************************************************************/
void btm_vendor_specific_evt(const uint8_t* p, uint8_t evt_len) {
  uint8_t i;
  uint8_t sub_event_code = HCI_VSE_SUBCODE_BQR_SUB_EVT;
  uint8_t bqr_parameter_length = evt_len;
  const uint8_t* p_bqr_event = p;

  log::verbose("BTM Event: Vendor Specific event from controller");

  // Handle BQR events
  const uint8_t* bqr_ptr = p;
  uint8_t event_code;
  uint8_t len;

  if (evt_len >= 2) {
    STREAM_TO_UINT8(event_code, bqr_ptr);
    STREAM_TO_UINT8(len, bqr_ptr);
    // Check if there's at least a subevent code
    if (len > 1 && evt_len >= 2 + 1 && event_code == HCI_VENDOR_SPECIFIC_EVT) {
      uint8_t sub_event_code;
      STREAM_TO_UINT8(sub_event_code, bqr_ptr);
      if (sub_event_code == HCI_VSE_SUBCODE_BQR_SUB_EVT) {
        // Excluding the HCI Event packet header and 1 octet sub-event code
        int16_t bqr_parameter_length = evt_len - HCIE_PREAMBLE_SIZE - 1;
        const uint8_t* p_bqr_event = bqr_ptr;
        // The stream currently points to the BQR sub-event parameters
        switch (sub_event_code) {
        case bluetooth::bqr::QUALITY_REPORT_ID_LMP_LL_MESSAGE_TRACE:
@@ -563,13 +550,20 @@ void btm_vendor_specific_evt(const uint8_t* p, uint8_t evt_len) {
        default:
          log::info("Unhandled BQR subevent 0x{:02x}x", sub_event_code);
        }
      }
    }

        uint8_t i;
        std::vector<uint8_t> reconstructed_event;
        reconstructed_event[0] = HCI_VENDOR_SPECIFIC_EVT;
        reconstructed_event[1] = 3 + bqr_parameter_length;  // event size
        reconstructed_event[2] = HCI_VSE_SUBCODE_BQR_SUB_EVT;
        for (i = 0; i < bqr_parameter_length; i++) {
          reconstructed_event.emplace_back(p[i]);
        }

  for (i = 0; i < BTM_MAX_VSE_CALLBACKS; i++) {
    if (btm_cb.devcb.p_vend_spec_cb[i])
      (*btm_cb.devcb.p_vend_spec_cb[i])(evt_len, p);
      (*btm_cb.devcb.p_vend_spec_cb[i])(reconstructed_event.size(),
                                        reconstructed_event.data());
  }
}

+1 −106
Original line number Diff line number Diff line
@@ -112,11 +112,8 @@ static void btu_hcif_read_local_oob_complete(const uint8_t* p,
static void btu_hcif_io_cap_request_evt(const uint8_t* p);
static void btu_hcif_io_cap_response_evt(const uint8_t* p);

static void btu_ble_ll_conn_param_upd_evt(uint8_t* p, uint16_t evt_len);
static void btu_ble_proc_ltk_req(uint8_t* p, uint16_t evt_len);
static void btu_hcif_encryption_key_refresh_cmpl_evt(uint8_t* p);
static void btu_ble_data_length_change_evt(uint8_t* p, uint16_t evt_len);
static void btu_ble_rc_param_req_evt(uint8_t* p, uint8_t len);

/**
 * Log HCI event metrics that are not handled in special functions
@@ -328,32 +325,12 @@ void btu_hcif_process_event(UNUSED_ATTR uint8_t controller_id,

      uint8_t ble_evt_len = hci_evt_len - 1;
      switch (ble_sub_code) {
        case HCI_BLE_ADV_PKT_RPT_EVT: /* result of inquiry */
          btm_ble_process_adv_pkt(ble_evt_len, p);
          break;
        case HCI_BLE_LL_CONN_PARAM_UPD_EVT:
          btu_ble_ll_conn_param_upd_evt(p, ble_evt_len);
          break;
        case HCI_BLE_READ_REMOTE_FEAT_CMPL_EVT:
          btm_ble_read_remote_features_complete(p, ble_evt_len);
          break;
        case HCI_BLE_LTK_REQ_EVT: /* received only at peripheral device */
          btu_ble_proc_ltk_req(p, ble_evt_len);
          break;
        case HCI_BLE_RC_PARAM_REQ_EVT:
          btu_ble_rc_param_req_evt(p, ble_evt_len);
          break;
        case HCI_BLE_DATA_LENGTH_CHANGE_EVT:
          btu_ble_data_length_change_evt(p, hci_evt_len);
          break;

        case HCI_BLE_PHY_UPDATE_COMPLETE_EVT:
          btm_ble_process_phy_update_pkt(ble_evt_len, p);
          break;

        case HCI_LE_EXTENDED_ADVERTISING_REPORT_EVT:
          btm_ble_process_ext_adv_pkt(hci_evt_len, p);
          break;

        case HCI_BLE_REQ_PEER_SCA_CPL_EVT:
          btm_acl_process_sca_cmpl_pkt(ble_evt_len, p);
@@ -369,18 +346,6 @@ void btu_hcif_process_event(UNUSED_ATTR uint8_t controller_id,
                                                    ble_evt_len);
          break;

        case HCI_LE_PERIODIC_ADV_SYNC_TRANSFERE_RECEIVED_EVT:
          btm_ble_periodic_adv_sync_tx_rcvd(p, hci_evt_len);
          break;

        case HCI_LE_BIGINFO_ADVERTISING_REPORT_EVT:
          btm_ble_biginfo_adv_report_rcvd(p, hci_evt_len);
          break;

          // Events are now captured by gd/hci/le_acl_connection_interface.h
        case HCI_BLE_CONN_COMPLETE_EVT:  // SubeventCode::CONNECTION_COMPLETE
        case HCI_BLE_ENHANCED_CONN_COMPLETE_EVT:  // SubeventCode::ENHANCED_CONNECTION_COMPLETE
        case HCI_LE_SUBRATE_CHANGE_EVT:  // SubeventCode::LE_SUBRATE_CHANGE
        default:
          log::error(
              "Unexpectedly received LE sub_event_code:0x{:02x} that should "
@@ -390,11 +355,8 @@ void btu_hcif_process_event(UNUSED_ATTR uint8_t controller_id,
      }
    } break;

    case HCI_VENDOR_SPECIFIC_EVT:
      btm_vendor_specific_evt(const_cast<const uint8_t*>(p), hci_evt_len);
      break;

      // Events now captured by gd::hci_layer module
    case HCI_VENDOR_SPECIFIC_EVT:
    case HCI_HARDWARE_ERROR_EVT:
    case HCI_NUM_COMPL_DATA_PKTS_EVT:  // EventCode::NUMBER_OF_COMPLETED_PACKETS
    case HCI_CONNECTION_COMP_EVT:  // EventCode::CONNECTION_COMPLETE
@@ -1521,31 +1483,6 @@ static void btu_hcif_encryption_key_refresh_cmpl_evt(uint8_t* p) {
 * BLE Events
 **********************************************/

static void btu_ble_ll_conn_param_upd_evt(uint8_t* p, uint16_t evt_len) {
  /* LE connection update has completed successfully as a central. */
  /* We can enable the update request if the result is a success. */
  /* extract the HCI handle first */
  uint8_t status;
  uint16_t handle;
  uint16_t interval;
  uint16_t latency;
  uint16_t timeout;

  if (evt_len < 9) {
    log::error("Malformated event packet, too short");
    return;
  }

  STREAM_TO_UINT8(status, p);
  STREAM_TO_UINT16(handle, p);
  STREAM_TO_UINT16(interval, p);
  STREAM_TO_UINT16(latency, p);
  STREAM_TO_UINT16(timeout, p);

  acl_ble_update_event_received(static_cast<tHCI_STATUS>(status), handle,
                                interval, latency, timeout);
}

static void btu_ble_proc_ltk_req(uint8_t* p, uint16_t evt_len) {
  uint16_t ediv, handle;
  uint8_t* pp;
@@ -1569,48 +1506,6 @@ static void btu_ble_proc_ltk_req(uint8_t* p, uint16_t evt_len) {
  /* This is empty until an upper layer cares about returning event */
}

static void btu_ble_data_length_change_evt(uint8_t* p, uint16_t evt_len) {
  uint16_t handle;
  uint16_t tx_data_len;
  uint16_t rx_data_len;

  if (!controller_get_interface()->SupportsBleDataPacketLengthExtension()) {
    log::warn("request not supported");
    return;
  }

  // 2 bytes each for handle, tx_data_len, TxTimer, rx_data_len
  if (evt_len < 8) {
    log::error("Event packet too short");
    return;
  }

  STREAM_TO_UINT16(handle, p);
  STREAM_TO_UINT16(tx_data_len, p);
  p += 2; /* Skip the TxTimer */
  STREAM_TO_UINT16(rx_data_len, p);

  l2cble_process_data_length_change_event(handle, tx_data_len, rx_data_len);
}

/**********************************************
 * End of BLE Events Handler
 **********************************************/
static void btu_ble_rc_param_req_evt(uint8_t* p, uint8_t len) {
  uint16_t handle;
  uint16_t int_min, int_max, latency, timeout;

  if (len < 10) {
    log::error("bogus event packet, too short");
    return;
  }

  STREAM_TO_UINT16(handle, p);
  STREAM_TO_UINT16(int_min, p);
  STREAM_TO_UINT16(int_max, p);
  STREAM_TO_UINT16(latency, p);
  STREAM_TO_UINT16(timeout, p);

  l2cble_process_rc_param_request_evt(handle, int_min, int_max, latency,
                                      timeout);
}
+0 −3
Original line number Diff line number Diff line
@@ -22,9 +22,6 @@
#include "stack/include/hci_error_code.h"

// This header contains functions for HCI-ble to invoke
void btm_ble_process_adv_pkt(uint8_t len, const uint8_t* p);
void btm_ble_process_ext_adv_pkt(uint8_t len, const uint8_t* p);
void btm_ble_process_phy_update_pkt(uint8_t len, uint8_t* p);
void btm_ble_read_remote_features_complete(uint8_t* p, uint8_t length);
void btm_ble_write_adv_enable_complete(uint8_t* p, uint16_t evt_len);
void btm_ble_ltk_request(uint16_t handle, uint8_t rand[8], uint16_t ediv);
Loading