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

Commit 1b40653f authored by Chris Manton's avatar Chris Manton
Browse files

Streamline stack/btm/btm_ble_gap::BTM_BleSetScanParams

Towards readable code

Bug: 163134718
Tag: #refactor
Test: act.py -tc BleCocTest
Test: ble paired 2 phones
Test: classic paired Bose SoundLink
Change-Id: I24971c11203a47a4f06c12b39af2191860666e74
parent cec308e8
Loading
Loading
Loading
Loading
+9 −16
Original line number Diff line number Diff line
@@ -758,25 +758,19 @@ static uint8_t btm_set_conn_mode_adv_init_addr(
void BTM_BleSetScanParams(uint32_t scan_interval, uint32_t scan_window,
                          tBLE_SCAN_MODE scan_mode,
                          base::Callback<void(uint8_t)> cb) {
  tBTM_BLE_INQ_CB* p_cb = &btm_cb.ble_ctr_cb.inq_var;
  uint32_t max_scan_interval;
  uint32_t max_scan_window;

  BTM_TRACE_EVENT("%s", __func__);
  if (!controller_get_interface()->supports_ble()) return;
  if (!controller_get_interface()->supports_ble()) {
    LOG_INFO("Controller does not support ble");
    return;
  }

  /* If not supporting extended scan support, use the older range for checking
   */
  uint32_t max_scan_interval = BTM_BLE_EXT_SCAN_INT_MAX;
  uint32_t max_scan_window = BTM_BLE_EXT_SCAN_WIN_MAX;
  if (btm_cb.cmn_ble_vsc_cb.extended_scan_support == 0) {
    max_scan_interval = BTM_BLE_SCAN_INT_MAX;
    max_scan_window = BTM_BLE_SCAN_WIN_MAX;
  } else {
    /* If supporting extended scan support, use the new extended range for
     * checking */
    max_scan_interval = BTM_BLE_EXT_SCAN_INT_MAX;
    max_scan_window = BTM_BLE_EXT_SCAN_WIN_MAX;
  }

  tBTM_BLE_INQ_CB* p_cb = &btm_cb.ble_ctr_cb.inq_var;
  if (BTM_BLE_ISVALID_PARAM(scan_interval, BTM_BLE_SCAN_INT_MIN,
                            max_scan_interval) &&
      BTM_BLE_ISVALID_PARAM(scan_window, BTM_BLE_SCAN_WIN_MIN,
@@ -790,8 +784,7 @@ void BTM_BleSetScanParams(uint32_t scan_interval, uint32_t scan_window,
    cb.Run(BTM_SUCCESS);
  } else {
    cb.Run(BTM_ILLEGAL_VALUE);

    BTM_TRACE_ERROR("Illegal params: scan_interval = %d scan_window = %d",
    LOG_WARN("Illegal params: scan_interval = %d scan_window = %d",
             scan_interval, scan_window);
  }
}