Skip to content

feat(dive detail): implement parse of raw data on Windows#345

Open
essengee wants to merge 3 commits into
submersion-app:mainfrom
essengee:feature/implement-reparse-windows
Open

feat(dive detail): implement parse of raw data on Windows#345
essengee wants to merge 3 commits into
submersion-app:mainfrom
essengee:feature/implement-reparse-windows

Conversation

@essengee

Copy link
Copy Markdown
Contributor

Summary

Parsing raw dive data stored in the SQLite db was not implemented for Windows. This PR resolves that.

Changes

  • adds tests (using one of my dives as test data) for error handling and the "happy path"
  • implements the parse

Test Plan

  • flutter test passes
  • flutter analyze passes
  • Manual testing on: Windows. Tested by importing dives from computer, using the "smooth" function to modify the data points of some of them, then using the "Parse raw data" on the dive detail screen to re-import them

@codecov

codecov Bot commented Jun 17, 2026

Copy link
Copy Markdown

Codecov Report

✅ All modified and coverable lines are covered by tests.

📢 Thoughts on this report? Let us know!

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 implements Windows support for parsing raw dive computer binary blobs (stored in SQLite) into structured ParsedDive data, and adds a native C test to validate the wrapper’s error handling and “happy path” parsing.

Changes:

  • Implement ParseRawDiveData on Windows by calling libdc_parse_raw_dive and converting the resulting libdc_parsed_dive_t into a Pigeon ParsedDive.
  • Add a native C test (test_parse_raw_dive) that exercises invalid-argument handling, unknown-descriptor errors, and a real fixture parse.
  • Extend the native test CMake setup to build/link the new test with wrapper + libdivecomputer sources.

Reviewed changes

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

File Description
packages/libdivecomputer_plugin/windows/dive_computer_host_api_impl.cc Implements raw dive parsing on Windows via libdc_parse_raw_dive and returns ParsedDive/FlutterError.
packages/libdivecomputer_plugin/test/native/test_parse_raw_dive.c Adds native parsing tests (invalid args, unknown descriptor, real fixture).
packages/libdivecomputer_plugin/test/native/CMakeLists.txt Adds a new native test target and wires it into CTest, including platform config selection.

Comment on lines +166 to +170
int rc = libdc_parse_raw_dive(
vendor.c_str(), product.c_str(),
static_cast<unsigned int>(model),
data.data(), static_cast<unsigned int>(data.size()),
&dive, error_buf, sizeof(error_buf));
Comment on lines +9 to +20
static unsigned int load_fixture(const char *path, unsigned char **out) {
FILE *f = fopen(path, "rb");
if (!f) return 0;
fseek(f, 0, SEEK_END);
long len = ftell(f);
fseek(f, 0, SEEK_SET);
if (len <= 0) { fclose(f); return 0; }
*out = (unsigned char *)malloc((size_t)len);
size_t read = fread(*out, 1, (size_t)len, f);
fclose(f);
return (unsigned int)read;
}

# Collect libdivecomputer sources needed for parsing (exclude platform I/O
# files that don't compile cross-platform).
file(GLOB LIBDC_ALL_SOURCES "${LIBDC_DIR}/src/*.c")
ericgriffin and others added 2 commits June 24, 2026 15:50
Resolve the conflict in the native test CMakeLists.txt registry by
taking the union of both sides' added test targets: main's
test_descriptor_match_integration and test_hw_ostc3_read alongside this
PR's test_parse_raw_dive (with all three add_test registrations). No
content from either side is dropped.
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.

3 participants