v69 – Logbook export
Logbook export
A new Logbook tab downloads every dive stored on the Cosmiq and exports it as Subsurface XML (File → Open in Subsurface), CSV or raw JSON.
-
It only uses read commands. Nothing is written to the dive computer while the logbook downloads, and settings are locked until it finishes.
-
Each profile is read twice and only accepted when both copies match. Split or garbled Bluetooth packets are detected and re-read.
-
It works around a firmware bug behind the "645 m / 6553 °C" profiles in Subsurface (subsurface#3548). The Cosmiq writes each profile to flash sector
start_sector % 256but reads it back from the fullstart_sector. So once a logbook passes sector 256:- newer dives read back as empty memory;
- the oldest profiles get overwritten.
The Logbook tab reads each newer dive through the slot of the old dive it overwrote. Dives whose profile can't be reached are still exported with date, duration, max depth and temperature. The table shows the status of every dive.
Fixes to settings writes
- Freedive max time reset depth alarm 3 to 25 m. Command
0x26also carries depth alarm 3, which was hard-coded to0x14. Alarm 3 is now read from the device and sent back unchanged. - Freedive depth alarms could overwrite their partner. Alarms are written in pairs, and an unread partner alarm was sent as 5 m. The partner is now read from the device first, and nothing is written if that read fails.
- Input validation. Empty or out-of-range fields used to send malformed packets (
NaN, negative hex). Values are now checked against the Deepblu app's ranges:- scuba depth alarm 5–50 m;
- scuba time alarm 10–120 min;
- freedive depth alarms 5–80 m;
- freedive time 30–600 s.
- Reply handling. Bluetooth notifications are reassembled into full replies and checksum-verified before use. "COMMAND REJECTED" only appears for a real rejection.
- All writes go through one queue. This fixes "GATT operation already in progress" errors when clicking quickly.
- Other:
- characteristics are selected by UUID;
- device data is logged as text, not HTML;
- the tab bar wraps on phones.
Notes
- The protocol and export code are in
logbook.js, which must be published next toindex.html. node test/logbook.test.js <dump dir>tests it against a simulated device.- Tested against a simulated device and captured data from a COSMIQ 5 (firmware 2.2). Please verify settings on the device screen as always.