Implement requestMtu in Linux (#22)
* Implement requestMtu in Linux * Minor fixes * Improve requestMtu
This commit is contained in:
@@ -227,17 +227,16 @@ class UniversalBleLinux extends UniversalBlePlatform {
|
||||
|
||||
@override
|
||||
Future<int> requestMtu(String deviceId, int expectedMtu) async {
|
||||
// var device = _findDeviceById(deviceId);
|
||||
// if (!device.connected) return 0;
|
||||
// for (BlueZGattService service in device.gattServices) {
|
||||
// for (BlueZGattCharacteristic characteristic in service.characteristics) {
|
||||
// // The value provided by Bluez includes an extra 3 bytes from the GATT header, which needs to be removed.
|
||||
// // requires `int? get mtu => _object.getUint16Property(_gattCharacteristicInterfaceName, 'MTU');` to add in bluez.dart
|
||||
// return characteristic.mtu - 3;
|
||||
// }
|
||||
// }
|
||||
// return 0;
|
||||
throw UnimplementedError();
|
||||
var device = _findDeviceById(deviceId);
|
||||
if (!device.connected) throw Exception('Device not connected');
|
||||
for (BlueZGattService service in device.gattServices) {
|
||||
for (BlueZGattCharacteristic characteristic in service.characteristics) {
|
||||
int? mtu = characteristic.mtu;
|
||||
// The value provided by Bluez includes an extra 3 bytes from the GATT header, which needs to be removed.
|
||||
if (mtu != null) return mtu - 3;
|
||||
}
|
||||
}
|
||||
throw Exception('MTU not available');
|
||||
}
|
||||
|
||||
@override
|
||||
|
||||
Reference in New Issue
Block a user