Skip to content

Commit 264893d

Browse files
committed
fix #277 conn led doesnt stop when scanner is time out
1 parent be18b18 commit 264893d

File tree

2 files changed

+5
-12
lines changed

2 files changed

+5
-12
lines changed

libraries/Bluefruit52Lib/src/BLEScanner.cpp

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -138,8 +138,8 @@ bool BLEScanner::stop(void)
138138
{
139139
VERIFY_STATUS( sd_ble_gap_scan_stop(), false );
140140

141-
Bluefruit._stopConnLed(); // stop blinking
142141
_runnning = false;
142+
Bluefruit._stopConnLed(); // stop blinking
143143

144144
return true;
145145
}
@@ -406,6 +406,7 @@ void BLEScanner::_eventHandler(ble_evt_t* evt)
406406
if (evt->evt.gap_evt.params.timeout.src == BLE_GAP_TIMEOUT_SRC_SCAN)
407407
{
408408
_runnning = false;
409+
Bluefruit._stopConnLed();
409410
if (_stop_cb) ada_callback(NULL, 0, _stop_cb);
410411
}
411412
break;

libraries/Bluefruit52Lib/src/bluefruit.cpp

Lines changed: 3 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -826,16 +826,7 @@ void AdafruitBluefruit::_ble_handler(ble_evt_t* evt)
826826
LOG_LV2("GAP", "Disconnect Reason 0x%02X", evt->evt.gap_evt.params.disconnected.reason);
827827

828828
// Turn off Conn LED If not connected at all
829-
bool still_connected = false;
830-
for (uint8_t i=0; i<BLE_MAX_CONNECTION; i++)
831-
{
832-
if ( _connection[i] && _connection[i]->connected() )
833-
{
834-
still_connected = true;
835-
break;
836-
}
837-
}
838-
if ( !still_connected ) _setConnLed(false);
829+
if ( !this->connected() ) _setConnLed(false);
839830

840831
// Invoke disconnect callback
841832
if ( conn->getRole() == BLE_GAP_ROLE_PERIPH )
@@ -848,7 +839,6 @@ void AdafruitBluefruit::_ble_handler(ble_evt_t* evt)
848839

849840
delete _connection[conn_hdl];
850841
_connection[conn_hdl] = NULL;
851-
852842
}
853843
break;
854844

@@ -994,6 +984,8 @@ void AdafruitBluefruit::_startConnLed(void)
994984
void AdafruitBluefruit::_stopConnLed(void)
995985
{
996986
xTimerStop(_led_blink_th, 0);
987+
988+
_setConnLed( this->connected() );
997989
}
998990

999991
void AdafruitBluefruit::_setConnLed (bool on_off)

0 commit comments

Comments
 (0)