From cd0f42804af70845c08e6b0d589b45feaef53f1c Mon Sep 17 00:00:00 2001 From: Jef Driesen Date: Thu, 7 Oct 2021 19:57:23 +0200 Subject: [PATCH] Ignore unsupported BLE handshake For some BLE enabled models, like the Oceanic Pro Plus X, Aqualung i750TC, Sherwood Sage and Sherwood Beacon, the BLE handshake command is not supported and therefore disabled. However, based on a bug report by a user with two Aqualung i770R dive computers, this detection mechanism based on the dive computer model number isn't sufficient. Allthough the two devices have the exact same firmware version (2A), the handshake command only works on the newest unit, and fails with a NAK response on the oldest unit. Remove the model based detection and always try to send the handshake command and rely on the NAK response to ignore the failure instead. An additional advantage is that we no longer have to (manually) maintain a list with the model numbers where the handshaking is known to fail. --- src/oceanic_atom2.c | 13 +++++++++---- 1 file changed, 9 insertions(+), 4 deletions(-) diff --git a/src/oceanic_atom2.c b/src/oceanic_atom2.c index c327ceb..16cf43e 100644 --- a/src/oceanic_atom2.c +++ b/src/oceanic_atom2.c @@ -819,8 +819,14 @@ oceanic_atom2_ble_handshake(oceanic_atom2_device_t *device) // Send the command to the dive computer. rc = oceanic_atom2_transfer (device, handshake, sizeof(handshake), ACK, NULL, 0, 0); - if (rc != DC_STATUS_SUCCESS) - return rc; + if (rc != DC_STATUS_SUCCESS) { + if (rc == DC_STATUS_UNSUPPORTED) { + WARNING (abstract->context, "Bluetooth handshake not supported."); + return DC_STATUS_SUCCESS; + } else { + return rc; + } + } return DC_STATUS_SUCCESS; } @@ -916,8 +922,7 @@ oceanic_atom2_device_open (dc_device_t **out, dc_context_t *context, dc_iostream goto error_free; } - if (dc_iostream_get_transport (device->iostream) == DC_TRANSPORT_BLE && - model != PROPLUSX && model != I750TC && model != SAGE && model != BEACON) { + if (dc_iostream_get_transport (device->iostream) == DC_TRANSPORT_BLE) { status = oceanic_atom2_ble_handshake(device); if (status != DC_STATUS_SUCCESS) { goto error_free;