btleplug
btleplug copied to clipboard
Requesting MTU
This PR will include a method to retrieve the negotiated MTU size on each platform.
Info grabbed from: https://github.com/deviceplug/btleplug/issues/246
Windows - GattSession.MaxPduSize Negotiation happens on user's behalf, and a GattSession.MaxPduSizeChanged event is emitted when MTU is updated.
macOS / iOS - CBPeripheral.maximumWriteValueLength Negotiation happens on user's behalf, have used peripheral.maximumWriteValueLength(for: .withoutResponse) reliably in the past. .withResponse has some issues. See here.
Linux Instead of a dedicated MTU property, BlueZ has decided to adopt the newer Bluetooth 5.2 standard. Example here: Link
Android - BluetoothGatt.requestMtu The way I understand it and have used it in the past, you call requestMtu with the largest you can support (e.g. 512), and it will negotiate the min(host.maxMtu, periph.maxMtu) and call onMtuChanged with the new mtu size.
TODO:
- [x] Windows
- [x] Linux
- [ ] Android
- [ ] macOS/iOS
@robbym Hi, have you finish it on bluez?
@laxian I just pushed a working bluez implementation. I tested it on one of my BLE devices and it works, but let me know if there is any issues.
@qwandor I added the constant and now moved it to the api namespace so that each implementation can use it. Not really happy with where it currently lives. Maybe move it to common?
Windows parts of this are looking good so far. Would like to get all platforms in before we land it (otherwise I will have people on unsupported platforms yelling) but I'm fine to also do a point release whenever we get all the parts in.
Converted this to a draft until we get all the platforms in. Just makes my life easier for the little amount of time I actually get to do triage on this project.
One more quick update here: I brought us up to bluez-async 0.8.0 in v0.11.7, so mtu() is available now and we can drop that change here (it'll probably just skip the commit on rebase).