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

Commit 22da681e authored by Jakub Pawlowski's avatar Jakub Pawlowski
Browse files

btm: Support scan with duration of 0

Stops the existing timer if scan requested with duration of 0.

Bug: 150670922
Tag: #feature
Test: compilation
Change-Id: Ie0019259d5874add9929c5cf6d09b8639dd0eb57
parent a1be11ac
Loading
Loading
Loading
Loading
+4 −0
Original line number Diff line number Diff line
@@ -652,6 +652,10 @@ tBTM_STATUS bluetooth::shim::BTM_BleObserve(bool start, uint8_t duration_sec,
    std::lock_guard<std::mutex> lock(btm_cb_mutex_);

    if (btm_cb.ble_ctr_cb.is_ble_observe_active()) {
      if (duration_sec == 0) {
        Stack::GetInstance()->GetBtm()->CancelObservingTimer();
        return BTM_CMD_STARTED;
      }
      LOG_WARN("%s Observing already active", __func__);
      return BTM_WRONG_MODE;
    }
+9 −1
Original line number Diff line number Diff line
@@ -396,7 +396,9 @@ void BTM_BleOpportunisticObserve(bool enable,
 *                  events from a broadcast device.
 *
 * Parameters       start: start or stop observe.
 *                  acceptlist: use acceptlist in observer mode or not.
 *                  duration: how long the scan should last, in seconds. 0 means
 *                  scan without timeout. Starting the scan second time without
 *                  timeout will disable the timer.
 *
 * Returns          void
 *
@@ -425,6 +427,12 @@ tBTM_STATUS BTM_BleObserve(bool start, uint8_t duration,
  if (start) {
    /* shared inquiry database, do not allow observe if any inquiry is active */
    if (btm_cb.ble_ctr_cb.is_ble_observe_active()) {
      if (duration == 0) {
        if (alarm_is_scheduled(btm_cb.ble_ctr_cb.observer_timer)) {
          alarm_cancel(btm_cb.ble_ctr_cb.observer_timer);
          return BTM_CMD_STARTED;
        }
      }
      BTM_TRACE_ERROR("%s Observe Already Active", __func__);
      return status;
    }
+3 −0
Original line number Diff line number Diff line
@@ -160,6 +160,9 @@ extern void BTM_BleTrackAdvertiser(tBTM_BLE_TRACK_ADV_CBACK* p_track_cback,
 *                  events from a broadcast device.
 *
 * Parameters       start: start or stop observe.
 *                  duration: how long the scan should last, in seconds. 0 means
 *                  scan without timeout. Starting the scan second time without
 *                  timeout will disable the timer.
 *
 * Returns          void
 *