@@ -21,16 +21,13 @@ namespace {
2121constexpr size_t kAdvertisingNameCapacity = 32 ;
2222constexpr TickType_t kConnTuneDelayTicks = pdMS_TO_TICKS(1200 );
2323constexpr TickType_t kPairingTimeoutTicks = pdMS_TO_TICKS(60000 );
24- constexpr TickType_t kReconnectWindowTicks = pdMS_TO_TICKS(300000 ); // 5 min
2524constexpr TickType_t kAdvertisingWatchdogTicks = pdMS_TO_TICKS(1000 );
2625TimerHandle_t gConnTuneTimer = nullptr ;
2726TimerHandle_t gPairingTimer = nullptr ;
28- TimerHandle_t gReconnectWindowTimer = nullptr ;
2927TimerHandle_t gAdvertisingWatchdogTimer = nullptr ;
3028char gAdvertisingName [kAdvertisingNameCapacity ];
3129bool pairingModeActive = false ;
3230bool pairingModeTransitionActive = false ;
33- bool reconnectWindowActive = false ;
3431
3532// Store the active connection handle for conn param updates
3633uint16_t activeConnHandle = 0 ;
@@ -65,40 +62,6 @@ void stopPairingModeTimer() {
6562 }
6663}
6764
68- void stopReconnectWindowTimer () {
69- if (gReconnectWindowTimer != nullptr ) {
70- xTimerStop (gReconnectWindowTimer , 0 );
71- }
72- }
73-
74- void onReconnectWindowTimeout (TimerHandle_t timer) {
75- (void )timer;
76- reconnectWindowActive = false ;
77- USBSerial.println (" [BLE] Reconnect window expired; stopping advertising" );
78- restartBLEAdvertising ();
79- }
80-
81- void startReconnectWindowTimer () {
82- reconnectWindowActive = true ;
83- if (gReconnectWindowTimer == nullptr ) {
84- gReconnectWindowTimer = xTimerCreate (" bleReconn" , kReconnectWindowTicks ,
85- pdFALSE, nullptr ,
86- onReconnectWindowTimeout);
87- }
88- if (gReconnectWindowTimer != nullptr ) {
89- xTimerStop (gReconnectWindowTimer , 0 );
90- xTimerStart (gReconnectWindowTimer , 0 );
91- }
92- }
93-
94- void initReconnectWindowFromBoot () {
95- if (NimBLEDevice::getNumBonds () > 0 ) {
96- startReconnectWindowTimer ();
97- USBSerial.println (" [BLE] Reconnect window active (5 min)" );
98- } else {
99- reconnectWindowActive = false ;
100- }
101- }
10265
10366size_t syncWhiteListFromBonds () {
10467 // Reconcile the whitelist to the current bond store. Advertising must be
@@ -148,7 +111,8 @@ void applyPreferredLinkParams(TimerHandle_t timer) {
148111
149112bool shouldAdvertiseWhilePowered () {
150113 return !pairingModeTransitionActive &&
151- (pairingModeActive || reconnectWindowActive);
114+ (pairingModeActive ||
115+ NimBLEDevice::getNumBonds () > 0 );
152116}
153117
154118bool startAdvertising (NimBLEServer *server) {
@@ -172,11 +136,9 @@ bool startAdvertising(NimBLEServer *server) {
172136 return false ;
173137 }
174138
175- if (!allowOpenAdvertising && bondCount > 0 && !reconnectWindowActive) {
176- USBSerial.println (
177- " [BLE] Reconnect window inactive; whitelist advertising not started" );
178- return false ;
179- }
139+ // Bonded devices can always reconnect via whitelist advertising —
140+ // no reconnect window gating. Power draw is negligible for
141+ // whitelist-only advertising.
180142
181143#if CONFIG_BT_NIMBLE_EXT_ADV
182144 // Legacy connectable undirected advertising via the extended API.
@@ -272,9 +234,6 @@ class BleServerConnectionCallbacks : public NimBLEServerCallbacks {
272234 deviceConnected = true ;
273235 connectedHandle = connInfo.getConnHandle ();
274236
275- stopReconnectWindowTimer ();
276- reconnectWindowActive = false ;
277-
278237 if (gConnTuneTimer != nullptr ) {
279238 xTimerStop (gConnTuneTimer , 0 );
280239 xTimerStart (gConnTuneTimer , 0 );
@@ -313,12 +272,6 @@ class BleServerConnectionCallbacks : public NimBLEServerCallbacks {
313272 // Suppress the immediate advertising restart during a pairing transition —
314273 // enterBLEPairingMode() issues its own startAdvertising after clearing bonds.
315274 if (!pairingModeTransitionActive) {
316- if (NimBLEDevice::getNumBonds () > 0 ) {
317- startReconnectWindowTimer ();
318- } else {
319- reconnectWindowActive = false ;
320- stopReconnectWindowTimer ();
321- }
322275 startAdvertising (server);
323276 }
324277 }
@@ -420,8 +373,6 @@ void setupBLE() {
420373 USBSerial.println (" [BLE] BLE_PAIR_ON_BOOT: entering pairing mode automatically" );
421374 enterBLEPairingMode ();
422375#endif
423- // After optional boot pairing: start reconnect window only if bonds remain.
424- initReconnectWindowFromBoot ();
425376 if (shouldAdvertiseWhilePowered ()) {
426377 restartBLEAdvertising ();
427378 }
@@ -454,8 +405,6 @@ void restartBLEAdvertising() {
454405void enterBLEPairingMode () {
455406 // Block advertising restarts (e.g. from onDisconnect) during this transition.
456407 pairingModeTransitionActive = true ;
457- stopReconnectWindowTimer ();
458- reconnectWindowActive = false ;
459408
460409 // Single-bond model: disconnect the current peer so we can safely clear bonds.
461410 if (deviceConnected && pServer != nullptr &&
0 commit comments