mirror of
https://github.com/subsurface/subsurface.git
synced 2025-02-19 22:16:15 +00:00
BLE: big writes to connected DC (OSTC firmware)
Most writes to a connected DC are small, typically some command bytes to get DC in download mode, or to set some parameter. All this just worked over BLE, however, sending a full firmware update (on an OSTC device) failed, as the underlying BLE interface can only handle small 20 byte BLE packets at once. So, send max ble->packet_size chuncks at once. Tested for the following cases (linux desktop with OSTC3 over BLE): 1) normal download of dive data. 2) read and write settings from configure UI 3) update firmware (from 2.15 to 2.15) And to my surprise, no flow control credit administration is required here. Signed-off-by: Jan Mulder <jlmulder@xs4all.nl>
This commit is contained in:
parent
bb1df1218d
commit
f442031fdd
1 changed files with 14 additions and 3 deletions
|
@ -169,15 +169,26 @@ static dc_status_t ble_serial_write(dc_custom_io_t *io, const void* data, size_t
|
|||
size_t transferred = 0;
|
||||
|
||||
ble_serial_flush_read();
|
||||
while (size) {
|
||||
size_t len = sizeof(buffer.out) - buffer.out_bytes;
|
||||
|
||||
/*
|
||||
* Most writes to a connected DC are small, typically some command bytes to get
|
||||
* DC in download mode, or to set some parameter. All this just worked over BLE,
|
||||
* however, sending a full firmware update (on an OSTC device) failed, as the
|
||||
* underlying BLE interface can only handle small 20 byte BLE packets at once.
|
||||
*
|
||||
* So, send max ble->packet_size chuncks at once.
|
||||
*/
|
||||
while (size) {
|
||||
size_t len = sizeof(buffer.out) - transferred;
|
||||
|
||||
if (len > io->packet_size)
|
||||
len = io->packet_size;
|
||||
if (len > size)
|
||||
len = size;
|
||||
memcpy(buffer.out + buffer.out_bytes, data, len);
|
||||
buffer.out_bytes += len;
|
||||
|
||||
if (buffer.out_bytes == sizeof(buffer.out)) {
|
||||
if (buffer.out_bytes <= io->packet_size || buffer.out_bytes == size) {
|
||||
rc = ble_serial_flush_write();
|
||||
if (rc != DC_STATUS_SUCCESS)
|
||||
break;
|
||||
|
|
Loading…
Add table
Reference in a new issue