Skip to content

Commit

Permalink
Merge pull request #63 from mikeller/cherry_pick_mares_fix
Browse files Browse the repository at this point in the history
  • Loading branch information
mikeller authored May 24, 2024
2 parents 5d321de + d9c2308 commit 9b12e8e
Showing 1 changed file with 11 additions and 1 deletion.
12 changes: 11 additions & 1 deletion src/mares_iconhd.c
Original file line number Diff line number Diff line change
Expand Up @@ -183,6 +183,7 @@ mares_iconhd_packet (mares_iconhd_device_t *device,
{
dc_status_t status = DC_STATUS_SUCCESS;
dc_device_t *abstract = (dc_device_t *) device;
dc_transport_t transport = dc_iostream_get_transport (device->iostream);

if (device_is_cancelled (abstract))
return DC_STATUS_CANCELLED;
Expand All @@ -198,7 +199,7 @@ mares_iconhd_packet (mares_iconhd_device_t *device,
}

// Send the command payload to the dive computer.
if (size) {
if (size && transport == DC_TRANSPORT_BLE) {
status = dc_iostream_write (device->iostream, data, size, NULL);
if (status != DC_STATUS_SUCCESS) {
ERROR (abstract->context, "Failed to send the command.");
Expand All @@ -220,6 +221,15 @@ mares_iconhd_packet (mares_iconhd_device_t *device,
return DC_STATUS_PROTOCOL;
}

// Send the command payload to the dive computer.
if (size && transport != DC_TRANSPORT_BLE) {
status = dc_iostream_write (device->iostream, data, size, NULL);
if (status != DC_STATUS_SUCCESS) {
ERROR (abstract->context, "Failed to send the command data.");
return status;
}
}

// Read the packet.
status = dc_iostream_read (device->iostream, answer, asize, NULL);
if (status != DC_STATUS_SUCCESS) {
Expand Down

0 comments on commit 9b12e8e

Please sign in to comment.