Skip to content

feat(import layer): improve parsing of Cressi Leonardo download#342

Open
essengee wants to merge 1 commit into
submersion-app:mainfrom
essengee:feature/improve-leonardo-download
Open

feat(import layer): improve parsing of Cressi Leonardo download#342
essengee wants to merge 1 commit into
submersion-app:mainfrom
essengee:feature/improve-leonardo-download

Conversation

@essengee

Copy link
Copy Markdown
Contributor

Summary

Improves dive data parsing for the original Cressi Leonardo dive computer. Previously, all ascent rate indicators from
the Leonardo were misclassified as "Deco Violation" alerts due to two bugs: an off-by-one error in the event type
mapper (all platforms), and the parser emitting events for non-alarm ascent levels. Additionally, the Leonardo's deco
obligation flag (stored as bit 11 in the sample data) was never extracted, meaning neither deco status nor deco
start/end events were reported. Water temperature from the dive header was also not being saved to the dive record.

Changes

libdivecomputer parser (cressi_leonardo_parser.c)

  • Extract bit 11 from 16-bit sample word as deco obligation flag
  • Emit DC_SAMPLE_DECO with DC_DECO_DECOSTOP or DC_DECO_NDL on every sample based on bit 11
  • Emit SAMPLE_EVENT_DECOSTOP with BEGIN/END flags on deco state transitions (0→1 and 1→0)
  • Only emit SAMPLE_EVENT_ASCENT when ascent rate level = 3 (the only level that triggers an audible alarm on the
    Leonardo hardware)

Event type mapper fix (all platforms)

  • Fixed off-by-one in MapEventType / mapEventType — was missing SAMPLE_EVENT_RBT (value 2), causing all event types ≥2
    to map to the wrong string
  • Affected: Windows (dive_converter.cc), Linux (dive_converter.c), Android (DiveComputerHostApiImpl.kt), iOS/macOS
    (DiveComputerHostApiImpl.swift)

Dart import layer

  • _mapEventTypeString now accepts optional flags parameter to distinguish deco start (flags=1) from deco end (flags=2)
  • importProfile accepts minTemperature/maxTemperature parameters and writes waterTemp to the dive record (fixes
    Leonardo temperature not appearing)
  • Same changes applied to reparse service for consistency

Tests

  • Added 5 unit tests covering: temperature import from header, ascent event classification, deco start/end flag
    handling, and ceiling violation mapping
  • Regenerated mocks for new importProfile signature

Test Plan

  • flutter test passes
  • flutter analyze passes
  • Manual testing on: Windows

Screenshots

Note: NDL and ceiling in the Submersion screenshots below are calculated at 50/75 Buhlmann gradient - as close as I could get to the RGBM calculation of the computer for this dive. The computer itself does not include this level of detail in its 16 bits of sample data at 20 second intervals. Working with old tech here...

Result of original import:
CressiLeonardoOriginalImport

Result of import after changes:
CressiLeonardoImprovedImport

Screenshot of (ancient) Cressi PC Interface display of same dive:
CressiPCInterfaceDisplay

@essengee

Copy link
Copy Markdown
Contributor Author

Hi @ericgriffin !

I've been wanting to work on this for some time and finally decided to day to give it a go. It (unfortunately) involves a change to libdivecomputer code and I'm not sure how (or even if!) you want to handle that; I don't have a fork of the submersion_patches but I can certainly figure that out if necessary. Just wasn't sure if it was better to do it ham-fisted or let you handle it since I think you by far know what you are doing more than I do in this area.

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

Labels

None yet

Projects

Status: Backlog

Development

Successfully merging this pull request may close these issues.

1 participant