Closed mika324 closed 6 months ago
wait until connection before discoverServices
await device.connectionState.where((val) => val == BluetoothConnectionState.connected).first;
however, I advise you do not use autoConnect until you understand it better.
// - when using autoConnect, connect() always returns immediately, so we must
// explicity listen to `device.connectionState` to know when connection occurs
Requirements
Have you checked this problem on the example app?
No
FlutterBluePlus Version
1.31.16
Flutter Version
3.19.5
What OS?
iOS
OS Version
15.5
Bluetooth Module
OPPO Enco Free2, AirBuds U
What is your problem?
discoverServices() does not work because the scan result service is null. After scanning, the service may or may not be acquired normally. How can I obtain service stably? Because service is null, the following error is output.
Unhandled Exception: FlutterBluePlusException | discoverServices | fbp-code: 6 | device is not connected
The implemented code is as follows.
I would like someone who knows how to solve this problem to tell me. Thank you for reviewing the question.
I'm Japanese, so I apologize if there are any mistakes in the English translation.🙏
Logs