It has been observed that, if a data packet bigger than the negotiated MTU size is sent using the Tx characteristic, the connection with the BLE device is lost after a small timeout.
This commit fixes this scenario as follows:
The data packet to send is sliced using the MTU size minus 3 bytes as established in the Bluetooth core specification.
If any of the slices is not written correctly, the whole write operation is considered as failed.
While on it, make the write_data method async by awaiting the inner write task. This avoids spurious micro-hangs while sending data to the BLE device.
…U size
It has been observed that, if a data packet bigger than the negotiated MTU size is sent using the Tx characteristic, the connection with the BLE device is lost after a small timeout.
This commit fixes this scenario as follows:
While on it, make the write_data method async by awaiting the inner write task. This avoids spurious micro-hangs while sending data to the BLE device.