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

Commit 368c0284 authored by Myles Watson's avatar Myles Watson
Browse files

Remove unused parsing for periodic advertising

These events are handled in LeScanningManager._

Bug: 301661850
Test: mma -j32
Flag: EXEMPT, dead code removal
Change-Id: I1a554f37692a18ee1be8a69178d7f2f0bf2b0648
parent f52c1c17
Loading
Loading
Loading
Loading
+0 −79
Original line number Diff line number Diff line
@@ -329,82 +329,3 @@ void BleScannerHciInterface::CleanUp() {
  delete instance;
  instance = nullptr;
}

void btm_ble_process_periodic_adv_sync_est_evt(uint8_t data_len,
                                               const uint8_t* data) {
  uint16_t sync_handle, adv_interval;
  uint8_t status, adv_sid, adv_addr_type, adv_phy, adv_clock_accuracy;
  RawAddress adv_addr;

  LOG_ASSERT(data_len == 15)
      << "Malformed LE Periodic Advertising Sync Est. Event from controller";

  STREAM_TO_UINT8(status, data);
  STREAM_TO_UINT16(sync_handle, data);
  STREAM_TO_UINT8(adv_sid, data);
  STREAM_TO_UINT8(adv_addr_type, data);
  STREAM_TO_BDADDR(adv_addr, data);
  STREAM_TO_UINT8(adv_phy, data);
  STREAM_TO_UINT16(adv_interval, data);
  STREAM_TO_UINT8(adv_clock_accuracy, data);

  if (BleScannerHciInterface::Get()) {
    static_cast<BleScannerImplBase*>(BleScannerHciInterface::Get())
        ->OnPeriodicAdvSyncEstablished(status, sync_handle, adv_sid,
                                       adv_addr_type, adv_addr, adv_phy,
                                       adv_interval, adv_clock_accuracy);
  }
}

void btm_ble_process_periodic_adv_pkt(uint8_t data_len, const uint8_t* data) {
  const uint8_t* p = data;
  uint16_t sync_handle;
  uint8_t tx_power, cte_type, pkt_data_status, pkt_data_len;
  int8_t rssi;

  LOG_ASSERT(data_len >= 7)
      << "Malformed LE Periodic Advertising Report Event from controller";

  STREAM_TO_UINT16(sync_handle, p);
  STREAM_TO_UINT8(tx_power, p);
  STREAM_TO_INT8(rssi, p);
  STREAM_TO_UINT8(cte_type, p);
  STREAM_TO_UINT8(pkt_data_status, p);
  STREAM_TO_UINT8(pkt_data_len, p);

  const uint8_t* pkt_data = p;
  p += pkt_data_len;

  if (p > data + data_len) {
    LOG(ERROR) << __func__ << " Invalid pkt_data_len: " << int{pkt_data_len};
    return;
  }

  if (rssi >= 21 && rssi <= 126) {
    LOG(ERROR) << __func__
               << " bad rssi value in advertising report: " << int{rssi};
  }

  if (BleScannerHciInterface::Get()) {
    static_cast<BleScannerImplBase*>(BleScannerHciInterface::Get())
        ->OnPeriodicScanResult(sync_handle, tx_power, rssi, cte_type,
                               pkt_data_status, pkt_data_len, pkt_data);
  }
}

void btm_ble_process_periodic_adv_sync_lost_evt(uint8_t data_len,
                                                uint8_t* data) {
  uint16_t sync_handle;

  if (data_len < 2) {
    LOG(ERROR) << "Bogus event packet, too short";
    return;
  }

  STREAM_TO_UINT16(sync_handle, data);

  if (BleScannerHciInterface::Get()) {
    static_cast<BleScannerImplBase*>(BleScannerHciInterface::Get())
        ->OnPeriodicSyncLost(sync_handle);
  }
}
+0 −3
Original line number Diff line number Diff line
@@ -32,9 +32,6 @@
#include "types/ble_address_with_type.h"
#include "types/raw_address.h"

void btm_ble_process_periodic_adv_sync_est_evt(uint8_t len, const uint8_t* p);
void btm_ble_process_periodic_adv_pkt(uint8_t len, const uint8_t* p);
void btm_ble_process_periodic_adv_sync_lost_evt(uint8_t len, uint8_t* p);
void btm_send_hci_set_scan_params(uint8_t scan_type, uint16_t scan_int,
                                  uint16_t scan_win,
                                  tBLE_ADDR_TYPE addr_type_own,
+0 −14
Original line number Diff line number Diff line
@@ -363,20 +363,6 @@ void btu_hcif_process_event(UNUSED_ATTR uint8_t controller_id,
          btm_acl_process_sca_cmpl_pkt(ble_evt_len, p);
          break;

        case HCI_BLE_PERIODIC_ADV_SYNC_EST_EVT:
          btm_ble_process_periodic_adv_sync_est_evt(
              ble_evt_len, const_cast<const uint8_t*>(p));
          break;

        case HCI_BLE_PERIODIC_ADV_REPORT_EVT:
          btm_ble_process_periodic_adv_pkt(ble_evt_len,
                                           const_cast<const uint8_t*>(p));
          break;

        case HCI_BLE_PERIODIC_ADV_SYNC_LOST_EVT:
          btm_ble_process_periodic_adv_sync_lost_evt(ble_evt_len, p);
          break;

        case HCI_BLE_CIS_EST_EVT:
        case HCI_BLE_CREATE_BIG_CPL_EVT:
        case HCI_BLE_TERM_BIG_CPL_EVT:
+0 −105
Original line number Diff line number Diff line
@@ -62,109 +62,4 @@ typedef struct {
  uint16_t periodic_advertising_properties;
} tBLE_PERIODIC_ADV_PARAMS;

class BleAdvertiserHciInterface;

class BleAdvertisingManager {
 public:
  virtual ~BleAdvertisingManager() = default;

  static const uint16_t advertising_prop_legacy_connectable = 0x0011;
  static const uint16_t advertising_prop_legacy_non_connectable = 0x0010;

  static void Initialize(BleAdvertiserHciInterface* interface);
  static void CleanUp();
  static bool IsInitialized();
  static base::WeakPtr<BleAdvertisingManager> Get();

  /* Register an advertising instance, status will be returned in |cb|
   * callback, with assigned id, if operation succeeds. Instance is freed when
   * advertising is disabled by calling |BTM_BleDisableAdvInstance|, or when any
   * of the operations fails.
   * The instance will have data set to |advertise_data|, scan response set to
   * |scan_response_data|, and will be enabled.
   */
  virtual void StartAdvertising(uint8_t advertiser_id, MultiAdvCb cb,
                                tBTM_BLE_ADV_PARAMS* params,
                                std::vector<uint8_t> advertise_data,
                                std::vector<uint8_t> scan_response_data,
                                int duration, MultiAdvCb timeout_cb) = 0;

  /* Register an advertising instance, status will be returned in |cb|
   * callback, with assigned id, if operation succeeds. Instance is freed when
   * advertising is disabled by calling |BTM_BleDisableAdvInstance|, or when any
   * of the operations fails.
   * The instance will have data set to |advertise_data|, scan response set to
   * |scan_response_data|, periodic data set to |periodic_data| and will be
   * enabled.
   */
  virtual void StartAdvertisingSet(
      base::Callback<void(uint8_t /* inst_id */, int8_t /* tx_power */,
                          uint8_t /* status */)>
          cb,
      tBTM_BLE_ADV_PARAMS* params, std::vector<uint8_t> advertise_data,
      std::vector<uint8_t> scan_response_data,
      tBLE_PERIODIC_ADV_PARAMS* periodic_params,
      std::vector<uint8_t> periodic_data, uint16_t duration,
      uint8_t maxExtAdvEvents,
      base::Callback<void(uint8_t /* inst_id */, uint8_t /* status */)>
          timeout_cb) = 0;

  /* Register an advertising instance, status will be returned in |cb|
   * callback, with assigned id, if operation succeeds. Instance is freed when
   * advertising is disabled by calling |BTM_BleDisableAdvInstance|, or when any
   * of the operations fails. */
  virtual void RegisterAdvertiser(
      base::Callback<void(uint8_t /* inst_id */, uint8_t /* status */)>) = 0;

  /* This function enables/disables an advertising instance. Operation status is
   * returned in |cb| */
  virtual void Enable(uint8_t inst_id, bool enable, MultiAdvCb cb,
                      uint16_t duration, uint8_t maxExtAdvEvents,
                      MultiAdvCb timeout_cb) = 0;

  /* This function update a Multi-ADV instance with the specififed adv
   * parameters. */
  virtual void SetParameters(uint8_t inst_id, tBTM_BLE_ADV_PARAMS* p_params,
                             ParametersCb cb) = 0;

  /* This function configure a Multi-ADV instance with the specified adv data or
   * scan response data.*/
  virtual void SetData(uint8_t inst_id, bool is_scan_rsp,
                       std::vector<uint8_t> data, MultiAdvCb cb) = 0;

  /* This function configure instance with the specified periodic parameters */
  virtual void SetPeriodicAdvertisingParameters(
      uint8_t inst_id, tBLE_PERIODIC_ADV_PARAMS* params, MultiAdvCb cb) = 0;

  /* This function configure instance with the specified periodic data */
  virtual void SetPeriodicAdvertisingData(uint8_t inst_id,
                                          std::vector<uint8_t> data,
                                          MultiAdvCb cb) = 0;

  /* This function enables/disables periodic advertising on selected instance */
  virtual void SetPeriodicAdvertisingEnable(uint8_t inst_id, bool enable,
                                            bool include_adi,
                                            MultiAdvCb cb) = 0;

  /*  This function disable a Multi-ADV instance */
  virtual void Unregister(uint8_t inst_id) = 0;

  /* When resolving list is used, we need to suspend and resume all advertising
   * instances for the time of operation. Suspend() saves current state,
   * Resume() resumes the advertising.
   */
  virtual void Suspend() = 0;
  virtual void Resume() = 0;

  /* This method is a member of BleAdvertiserHciInterface, and is exposed here
   * just for tests. It should never be called from upper layers*/
  virtual void OnAdvertisingSetTerminated(
      uint8_t status, uint8_t advertising_handle, uint16_t connection_handle,
      uint8_t num_completed_extended_adv_events) = 0;

  using GetAddressCallback =
      base::Callback<void(uint8_t /* address_type*/, RawAddress /*address*/)>;
  virtual void GetOwnAddress(uint8_t inst_id, GetAddressCallback cb) = 0;
};

#endif  // BLE_ADVERTISER_H
+0 −3
Original line number Diff line number Diff line
@@ -35,6 +35,3 @@ void btm_ble_read_resolving_list_entry_complete(const uint8_t* p,
void btm_ble_remove_resolving_list_entry_complete(uint8_t* p, uint16_t evt_len);
void btm_ble_add_resolving_list_entry_complete(uint8_t* p, uint16_t evt_len);
void btm_ble_clear_resolving_list_complete(uint8_t* p, uint16_t evt_len);
void btm_ble_process_periodic_adv_pkt(uint8_t len, const uint8_t* p);
void btm_ble_process_periodic_adv_sync_est_evt(uint8_t len, const uint8_t* p);
void btm_ble_process_periodic_adv_sync_lost_evt(uint8_t len, uint8_t* p);
Loading