Skip to content

Commit

Permalink
Add Linux WriteError
Browse files Browse the repository at this point in the history
  • Loading branch information
Rohit Sangwan authored and Rohit Sangwan committed Jun 19, 2022
1 parent 28f386b commit 042fda9
Showing 1 changed file with 15 additions and 6 deletions.
21 changes: 15 additions & 6 deletions packages/quick_blue/lib/src/quick_blue_linux.dart
Original file line number Diff line number Diff line change
Expand Up @@ -105,6 +105,11 @@ class QuickBlueLinux extends QuickBluePlatform {
_findDeviceById(deviceId).connect().then((_) {
onConnectionChanged?.call(deviceId, BlueConnectionState.connected,null);
});
//TODO : Listen for PropertisChanged event , to update Connection Status on Disconnection from BleDevice ,

// _findDeviceById(deviceId).propertiesChanged.listen((event) {
// print(event);
// });
}

@override
Expand Down Expand Up @@ -173,13 +178,17 @@ class QuickBlueLinux extends QuickBluePlatform {
@override
Future<void> writeValue(String deviceId, String service, String characteristic, Uint8List value, BleOutputProperty bleOutputProperty) async {
var c = _getCharacteristic(deviceId, service, characteristic);

if (bleOutputProperty == BleOutputProperty.withResponse) {
await c.writeValue(value, type: BlueZGattCharacteristicWriteType.request);
} else {
await c.writeValue(value, type: BlueZGattCharacteristicWriteType.command);
try{
if (bleOutputProperty == BleOutputProperty.withResponse) {
await c.writeValue(value, type: BlueZGattCharacteristicWriteType.request);
} else {
await c.writeValue(value, type: BlueZGattCharacteristicWriteType.command);
}
_log('writeValue $characteristic, ${hex.encode(value)}');
onWrite?.call(deviceId,characteristic,null);
}catch(e){
onWrite?.call(deviceId,characteristic,e.toString());
}
_log('writeValue $characteristic, ${hex.encode(value)}');
}

@override
Expand Down

0 comments on commit 042fda9

Please sign in to comment.