Skip to content

Commit

Permalink
Fixed service discovery notifications getting missed.
Browse files Browse the repository at this point in the history
  • Loading branch information
pbaker5 authored Dec 12, 2018
1 parent ab3c7f1 commit 5dfa32a
Showing 1 changed file with 4 additions and 4 deletions.
8 changes: 4 additions & 4 deletions lib/src/bluetooth_device.dart
Original file line number Diff line number Diff line change
Expand Up @@ -19,17 +19,17 @@ class BluetoothDevice {

/// Discovers services offered by the remote device as well as their characteristics and descriptors
Future<List<BluetoothService>> discoverServices() async {
await FlutterBlue.instance._channel
.invokeMethod('discoverServices', id.toString());

return await FlutterBlue.instance._servicesDiscoveredChannel
var response = FlutterBlue.instance._servicesDiscoveredChannel
.receiveBroadcastStream()
.map((buffer) =>
new protos.DiscoverServicesResult.fromBuffer(buffer))
.where((p) => p.remoteId == id.toString())
.map((p) => p.services)
.map((s) => s.map((p) => new BluetoothService.fromProto(p)).toList())
.first;
await FlutterBlue.instance._channel
.invokeMethod('discoverServices', id.toString());
return await response;
}

/// Returns a list of Bluetooth GATT services offered by the remote device
Expand Down

0 comments on commit 5dfa32a

Please sign in to comment.