Add Support for the Shearwater Perdix 3.#118
Conversation
There was a problem hiding this comment.
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()andshearwater_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.
| 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; |
| 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; |
| { | ||
| 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; |
|
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 ( 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. |
Cherry picked from upstream.