BLE connectivity in the background in Flutter

434 Views Asked by At

I've got a CGM peripheral which advertises every five minutes, being discoverable only for several seconds. The aim is to be able to gather glucose data every five minutes, especially in the background.

The Flutter code works well in the foreground for both Android and iOS devices. After scanning and discovering the peripheral once, I'll attempt to reconnect to it with a timeout for next readings, and disconnect immediately after gathering data.

The issue is connecting while app is the background. The timeout option for flutterBlueDevice.connect(timeout: Duration(seconds: 300) doesn't seem to wait at all, reporting no device has been found. I understand that BLE connectivity is limited in iOS environment.

Is there any way I could get around this in Flutter? If not, what approach should I use to integrate native corebluetooth partially in my code for connection part? Also, what connection strategy works best for continuous readings in this case?

0

There are 0 best solutions below