Skip to content

Add Support for the Shearwater Perdix 3.#118

Open
mikeller wants to merge 1 commit into
subsurface:Subsurface-DS9from
mikeller:add_perdix_3
Open

Add Support for the Shearwater Perdix 3.#118
mikeller wants to merge 1 commit into
subsurface:Subsurface-DS9from
mikeller:add_perdix_3

Conversation

@mikeller

Copy link
Copy Markdown
Member

Cherry picked from upstream.

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

This PR adds support for the Shearwater Perdix 3 within libdivecomputer’s existing Shearwater “Petrel family” integration, including a protocol variant needed for the new model and wiring the model ID through device open/setup.

Changes:

  • Add the Perdix 3 model identifier and register it in the descriptor/filter lists.
  • Thread the Shearwater model ID into shearwater_petrel_device_open() and shearwater_common_setup() so protocol behavior can vary by model.
  • Implement a V2 protocol path in shearwater_common_* to support larger packet sizes and updated packet framing/validation.

Reviewed changes

Copilot reviewed 7 out of 7 changed files in this pull request and generated 3 comments.

Show a summary per file
File Description
src/shearwater_predator.c Updates common setup call signature for Predator.
src/shearwater_petrel.h Extends internal Petrel open API to accept a model ID.
src/shearwater_petrel.c Passes model through to common setup to enable model-specific protocol selection.
src/shearwater_common.h Adds PERDIX3 model constant and a protocol field; updates setup signature.
src/shearwater_common.c Adds protocol V2 support (larger packets, header/length handling, upload opcodes).
src/device.c Passes descriptor model into Petrel-family device open.
src/descriptor.c Registers “Perdix 3” descriptor and adds it to Shearwater BLE name filtering.

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

Comment thread src/shearwater_common.c
Comment on lines 163 to 167
dc_status_t status = DC_STATUS_SUCCESS;
dc_transport_t transport = dc_iostream_get_transport(device->iostream);
unsigned char buffer[32];
const unsigned int header = transport == DC_TRANSPORT_BLE && device->protocol != V2;
unsigned char buffer[BLE_MTU_MIN];
unsigned int nbytes = 0;
Comment thread src/shearwater_common.c
Comment on lines +361 to 364
const unsigned int maxpacket = (device->protocol == V2) ? SZ_PACKET_V2 : SZ_PACKET_V1;
const unsigned int headerlen = (device->protocol == V2) ? 5 : 4;
unsigned char packet[SZ_PACKET_MAX + 5];
unsigned int n = 0;
Comment thread src/shearwater_common.c
Comment on lines 442 to 447
{
dc_device_t *abstract = (dc_device_t *) device;
dc_status_t rc = DC_STATUS_SUCCESS;
const unsigned int maxpacket = (device->protocol == V2) ? SZ_PACKET_V2 : SZ_PACKET_V1;
unsigned char response[SZ_PACKET_MAX];
unsigned int n = 0;
@splichy

splichy commented Jul 14, 2026

Copy link
Copy Markdown

Tested this cherry-pick end-to-end against a physical Shearwater Perdix 3.

Built both the Linux desktop and Android (arm64) apps with the libdivecomputer submodule checked out at this PR's head (ab18ece6), combined with the Subsurface transport-layer change tracked in subsurface/subsurface#4864 (the new GATT service UUID 1aa44039-... in qt-ble.cpp plus the scan-name entry in btdiscovery.cpp, which are still required since the upstream implementation selects the V2 protocol by model number and carries no knowledge of the service UUID).

On both platforms the Perdix 3 connects over BLE, downloads its dive log, and imports correctly, including dive-computer time sync. No conflicts, no code changes needed on top of this PR.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants