Fixes Oceanic/Aqualung/Sherwood BLE downloads (#24)
Aqualung/Oceanic/Sherwood devices (Atom2 protocol family — i300C, i330R, i550C, i770R, i200C, and rebrands) were completely unable to connect and download over BLE. This release fixes the full chain of issues, confirmed working end-to-end against a real Aqualung i300C.
Fixed
DC_IOCTL_BLE_GET_NAMEwas a stub returningDC_STATUS_UNSUPPORTED.oceanic_atom2_device_open()needs the peripheral's advertised BLE name for its handshake; without it the device NAKed every command.- Characteristic selection could bind to the wrong write/notify characteristic. Devices exposing more than one write- or notify-capable characteristic in the same service (the i300C has a data channel plus an auth-nonce channel) could end up bound to the wrong one depending on BLE enumeration order, producing "Unknown ATT error" on write.
- No retry on
dc_device_open. The i300C (and other Pelagic OEMs) ignores protocol commands for several seconds after a fresh BLE link is established. Now retries up to 5 times with a 3s delay on the same link, instead of failing immediately or forcing an expensive disconnect/reconnect cycle. connect(toDevice:)didn't wait for a prior connection to fully tear down. CoreBluetooth reusesCBPeripheralinstances; reconnecting while a previous teardown was still in flight triggered internal state-machine errors that delayed or blocked the retry. Now waits up to 5s for.disconnectedbefore issuing a new connect.- Fingerprint lookup returned a hardcoded 4-byte sentinel when nothing was stored. Oceanic/Aqualung's Atom2 family needs 8-byte fingerprints; the wrongly-sized buffer made
dc_device_set_fingerprintfail silently, so fingerprinting never took effect on these devices — every sync re-downloaded all dives instead of just new ones. Now returnsnil/0, which the bridge already knows how to skip safely. close_device_data()leaked the device descriptor on every close, for every device family, not just Aqualung — it nulled the pointer without freeing it. Two other failure paths inopen_ble_device()had the same gap.- Redundant reconnect attempts.
open_ble_device_with_identification()could retry the same protocol family twice (once via stored config, once via name-based fallback) when both would fail the same way — now skips the redundant attempt.
Also included
- Dropped a stale TODO about the Shearwater Perdix 3 descriptor table entry — resolved upstream in libdivecomputer, Perdix 3 already works.
Credits
Several of these fixes (dc_device_open retry, the connect(toDevice:) disconnect-wait, and the fingerprint sentinel fix) were found and verified working by @houle988 against a real device, and ported from his fork. Thanks to @kreitje for the original report and patient retesting through each iteration.