Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Update libdivecomputer from Upstream. #71

Merged

Conversation

mikeller
Copy link
Member

Add the latest updates in libdivecomputer as of 2024/12/31:

  • Add support for a new variant of the Aqualung i100
  • Add a new Perdix 2 hardware ID
  • Add support for the i330R Console
  • Return the correct error code
  • Don't skip the last entry in the logbook buffer
  • Add ioctl's for reading and writing BLE characteristics
  • Add helper functions to convert UUID to/from strings
  • Add support for the Cressi BLE protocol variant
  • Remove the unused model parameter
  • Add the device id and logbook entry
  • Add an extra surface sample
  • Add timesync support
  • Exit PC Link mode when operation is done
  • Add support for the Cressi Nepto
  • Add support for the Cressi Leonardo 2.0
  • Add CCR support for the Excursion
  • Add support for the Uwatec Aladin One

jefdriesen and others added 20 commits July 29, 2024 07:50
The i330R Console is a new variant of the i330R Wrist computer. The only
difference is the new model number.

Reported-by: Greg McLaughlin <support@moremobilesoftware.com>
Return the error code DC_STATUS_NOMEMORY when running out of memory
instead of DC_STATUS_SUCCESS.
Due to an off by one error, the last entry in the logbook buffer wasn't
processed at all. In theory that means the oldest dive is skipped and
can't be downloaded. However the logbook buffer usually contains some
empty entries at the front. Those are already detected by inspecting the
dive number for a zero value and thus the download is already aborted
before reaching that last entry. Therefore this bug didn't cause any
problems yet in practice.
Most BLE enabled dive computer use a simple BLE service with a TX and RX
characteristic, which emulates a basic UART connection over two lines.
This allows to use the I/O stream interface for the BLE communication.

Unfortunately some dive computers (e.g Cressi) also have some additional
characteristics that libdivecomputer must be able to read to retrieve
some important data. Therefore, add some new ioctl's for reading and
writing those BLE characteristics.
Add some helper functions to convert the binary UUID data structure to
and from their human readable string representation.
The BLE variant of the Cressi protocol uses a completely different set
of commands compared to the existing usb-serial protocol. Most of the
packet framing bytes have been removed as well. But the most surprising
change is the fact that there is no variant of the CMD_VERSION
available. The corresponding information must be obtained by reading
some secondary characteristics instead.

Co-authored-by: Greg McLaughlin <support@moremobilesoftware.com>
Co-authored-by: Sven Knoch <info@divinglog.de>
Previously, in commit 57cd11f, the part
of the logbook entry containing the dive mode was already inserted back
into the dive data, because the dive mode is needed to be able to parse
the dive.

Unfortunately, the newer models like the Cressi Nepto store even more
important information in the logbook entry and the dive computer id
data. Therefore, the data format is changed once more to preserve both
pieces of data. The parser is updated to handle this new format.

This change is not strictly backwards compatible, but if needed existing
data can be converted into the new format.
The extra surface sample results in a nicer and more correct graph when
plotting the depth profile.
The command to set the date/time does not appear to be supported for the
BLE communication.
The command to exit the PC Link mode does not appear to be supported for
the BLE communication.
The Cressi 'goa' protocol and data format has different versions. The
current implementation only supports version 2 and 3 (both variants are
mostly compatible with only some minor differences), but the Nepto uses
version 4, which requires some refactoring:

 - The reply to the CMD_VERSION command has no longer a fixed size, and
   thus the receive function is changed to accept a dynamically sized
   buffer.
 - The size of the entries in the logbook can be 23 bytes (for versions
   0-3) or 15 bytes (for version 4).
 - The Nepto is a freediving computer which supports sample rates less
   than one second. Therefore the sample time is internally changed from
   seconds to milliseconds.
 - Each version needs it own layout descriptor.

The version number is either available directly in the device id data,
or obtained indirectly from the firmware version.
The Cressi Leonardo 2.0 switched from the older 'leonardo' protocol to
the newer 'goa' protocol. At the same time, the device firmware also
uses a new V5 variant of the data format.

Some of the other models, like the Donatello, also received a firmware
update which uses this new V5 data format.
There is a minor update to the dataformat to support CCR dives.

For the current firmware, the setpoint change event was originally
defined as a 4 byte event, but the new implementation changed this to
only 2 bytes. Since the current firmware doesn't support CCR dives yet,
the 4 bytes variant is not supposed to appear in the sample data and
should be ignored.
The Uwatec Aladin One shares the same model number with the Tec and
Prime and is therefore already supported.

Reported-by: Sven Knoch <info@divinglog.de>
@mikeller mikeller requested review from dirkhh and torvalds and removed request for dirkhh December 30, 2024 11:24
@dirkhh
Copy link
Collaborator

dirkhh commented Dec 30, 2024

I assume that a number of these (at least the BLE one) are no-ops for us. Not saying they shouldn't be merged, just maybe that should be noted in the commit message?
We need to remember to run the scripts to update the list of supported dive computers when this is merged in Subsurface. And IIRC, we may need to manually remove the ones that aren't supported using Qt BLE without special handling for their broken-by-design protocols.

Copy link
Collaborator

@torvalds torvalds left a comment

Choose a reason for hiding this comment

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

Looks all reasonable to me

@mikeller
Copy link
Member Author

I assume that a number of these (at least the BLE one) are no-ops for us. Not saying they shouldn't be merged, just maybe that should be noted in the commit message?

All of the commits in this pull request (except for the merge commit) are the result of a git merge of libdivecomputer's master branch - so I am not sure if it makes sense to go and edit these commit messages and make them different from the ones in the 'upstream' repository?

We need to remember to run the scripts to update the list of supported dive computers when this is merged in Subsurface.

Yes, I'll do that. We can probably improve the process by adding a GitHub workflow that checks for every pull request if it will require the scripts to be run, and fails otherwise.

And while we are at it, I think there is generated documentation that is kept in the repository. Maybe this should have a similar guard?

And IIRC, we may need to manually remove the ones that aren't supported using Qt BLE without special handling for their broken-by-design protocols.

This already came out in the wash when resolving merge conflicts:

https://github.com/subsurface/libdc/pull/71/files#diff-470ccbf1ede979acb859b72fe3f44f1ff0d70a5599224b3c0097dc9e2a107487L279-L283

mikeller added a commit to mikeller/subsurface that referenced this pull request Dec 31, 2024
Add a check that will fail whenever there is a change in the list of
supported dive computers in libdivecomputer that is not reflected in the
`SupportedDivecomputers.*` lists.
Also add a script for a simplified update of these lists.
From a discussion with @dirkh in subsurface/libdc#71 (comment).

Signed-off-by: Michael Keller <github@ike.ch>
mikeller added a commit to mikeller/subsurface that referenced this pull request Dec 31, 2024
Add a check that will fail whenever there is a change in the list of
supported dive computers in libdivecomputer that is not reflected in the
`SupportedDivecomputers.*` lists.
Also add a script for a simplified update of these lists.
From a discussion with @dirkhh in subsurface/libdc#71 (comment).

Signed-off-by: Michael Keller <github@ike.ch>
mikeller added a commit to mikeller/subsurface that referenced this pull request Dec 31, 2024
Add a check that will fail whenever there is a change in the list of
supported dive computers in libdivecomputer that is not reflected in the
`SupportedDivecomputers.*` lists.
Also add a script for a simplified update of these lists.
From a discussion with @dirkhh in subsurface/libdc#71 (comment).

Signed-off-by: Michael Keller <github@ike.ch>
@mikeller
Copy link
Member Author

Tested with:

  • Shearwater Petrel 2
  • Heinrichs Weikamp OSTC4
  • Garmin Descent Mk1

mikeller added a commit to subsurface/subsurface that referenced this pull request Jan 1, 2025
Add a check that will fail whenever there is a change in the list of
supported dive computers in libdivecomputer that is not reflected in the
`SupportedDivecomputers.*` lists.
Also add a script for a simplified update of these lists.
From a discussion with @dirkhh in subsurface/libdc#71 (comment).

Signed-off-by: Michael Keller <github@ike.ch>
@mikeller mikeller merged commit 34556d4 into subsurface:Subsurface-DS9 Jan 1, 2025
7 of 8 checks passed
@mikeller mikeller deleted the update_libdivecomputer_202412 branch January 1, 2025 04:56
mikeller added a commit to mikeller/subsurface that referenced this pull request Jan 1, 2025
libdivecomputer.

Details in subsurface/libdc#71.

Signed-off-by: Michael Keller <github@ike.ch>
mikeller added a commit to subsurface/subsurface that referenced this pull request Jan 2, 2025
libdivecomputer.

Details in subsurface/libdc#71.

Signed-off-by: Michael Keller <github@ike.ch>
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.

5 participants