deviceplug / btleplug

Rust Cross-Platform Host-Side Bluetooth LE Access Library
Other
814 stars 150 forks source link

iOS cannot disconnect the Bluetooth connection #386

Closed laxian closed 1 week ago

laxian commented 5 months ago

Describe the bug

I‘m from flutter_btleplug. After scanning, I add two buttons on scanned items, connect and disconnect. The connection works, but the disconnected connection does not work.

BUT, code in examples works. https://github.com/deviceplug/btleplug/blob/master/examples/subscribe_notify_characteristic.rs

Why?

Expected behavior

disconnect works

Actual behavior

disconnect doesn't work

Additional context

                      child: Column(
                        children: [
                          Text(s.name),
                          Text(s.id),
                          ElevatedButton(
                              onPressed: () {
                                connect(id: s.id);
                              },
                              child: Text("connect")),
                          ElevatedButton(
                              onPressed: () {
                                disconnect(id: s.id);
                              },
                              child: Text("disconnect")),
                        ],

https://github.com/trobanga/flutter_btleplug/blob/7600adaf5304ff2d1d37f35ae739bc5248761c71/lib/main.dart#L56

https://github.com/trobanga/flutter_btleplug/issues/48

Here is a log of the disconnection process

flutter: disconnect to 15085272-df52-0046-b23d-18fea9a7fc63
Adapter message!
Trying to disconnect peripheral!
Disconnecting peripheral!
delegate_centralmanager_diddisconnectperipheral_error CBPeripheral(..., ...)
Got disconnect event!
ZDIS 3 CoreBluetoothReply::Ok
ZDIS 1 adapter_manager.emit
laxian commented 5 months ago

It depends. Some LE device works, some doesn't work

laxian commented 1 week ago

callinng unsubscibe before disconnect