Post

Replies

Boosts

Views

Activity

Reply to Background Mode for BLE app
Thanks for the response. It's running in the background when scanning stops. The scan stops randomly after 8 successful scans, sometimes 20 scans, etc. I define successful scan as being able to connect to the peripheral and write badge id (authenticate). We added a call to the iscanning() function, but scanning still stops. Here's portion of the Flutter code: func startBackgroundTask() { // Start BLE scanning or other background tasks if centralManager?.state == .poweredOn { print("isscanning") centralManager?.scanForPeripherals(withServices: nil, options: nil) } else if centralManager?.isScanning == false { print("isscanning off") print("Scanning failed, restarting background task") restartBackgroundTask() } else { print("Bluetooth is not powered on") } } func restartBackgroundTask() { // Restart BLE scanning or other background tasks stopBackgroundTask() startBackgroundTask() } func stopBackgroundTask() { // Stop BLE scanning or other background tasks centralManager?.stopScan() }
Jun ’24