@@ -132,6 +132,12 @@ class ScanCallbacks : public NimBLEScanCallbacks {
132132 advDevice = advertisedDevice;
133133 }
134134 }
135+
136+ void onScanEnd (const NimBLEScanResults& scanResults, int reason) override {
137+ #ifdef XBOX_SERIES_X_CONTROLLER_DEBUG_SERIAL
138+ XBOX_SERIES_X_CONTROLLER_DEBUG_SERIAL.println (" Scan Ended" );
139+ #endif
140+ }
135141};
136142
137143class Core {
@@ -236,8 +242,7 @@ class Core {
236242#ifdef XBOX_SERIES_X_CONTROLLER_DEBUG_SERIAL
237243 XBOX_SERIES_X_CONTROLLER_DEBUG_SERIAL.println (" Start scan" );
238244#endif
239- // assign scanCompleteCB to scan on other thread
240- pScan->start (scanTime, &Core::scanCompleteCB, false );
245+ pScan->start (msScanTime);
241246 }
242247
243248 XboxControllerNotificationParser xboxNotif;
@@ -255,7 +260,7 @@ class Core {
255260 private:
256261 ConnectionState connectionState = ConnectionState::Scanning;
257262 unsigned long receivedNotificationAt = 0 ;
258- uint32_t scanTime = 4 ; /* * 0 = scan forever */
263+ uint32_t msScanTime = 4000 ; /* * 0 = scan forever */
259264 uint8_t countFailedConnection = 0 ;
260265 uint8_t retryCountInOneConnection = 3 ;
261266 unsigned long retryIntervalMs = 100 ;
@@ -527,12 +532,6 @@ class Core {
527532#endif
528533 }
529534 }
530-
531- static void scanCompleteCB (NimBLEScanResults results) {
532- #ifdef XBOX_SERIES_X_CONTROLLER_DEBUG_SERIAL
533- XBOX_SERIES_X_CONTROLLER_DEBUG_SERIAL.println (" Scan Ended" );
534- #endif
535- }
536535};
537536
538537}; // namespace XboxSeriesXControllerESP32_asukiaaa
0 commit comments