Skip to content

Commit fa3abb6

Browse files
authored
Merge pull request #132 from mikeller/feat/ratio-apos5-firmware-5211-#66
DiveSystem: fix APOS5 record type detection for firmware 5.2.11+.
2 parents 3a6bd03 + 07cf8df commit fa3abb6

1 file changed

Lines changed: 18 additions & 15 deletions

File tree

src/divesystem_idive_parser.c

Lines changed: 18 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -58,9 +58,11 @@
5858
#define IX3M2_ZHL16C 2
5959
#define IX3M2_VPM 3
6060

61-
#define REC_SAMPLE 0
6261
#define REC_INFO 1
63-
#define REC_SAMPLE_APOS5_COMPAT 0x8006
62+
63+
#define TANK_VALID 0x8000
64+
#define TANK_RFCHANNEL 0x001F
65+
#define TANK_PRESSURE_MSB 0x0020
6466

6567
typedef struct divesystem_idive_parser_t divesystem_idive_parser_t;
6668

@@ -450,19 +452,12 @@ divesystem_idive_parser_samples_foreach (dc_parser_t *abstract, dc_sample_callba
450452
// Get the record type.
451453
unsigned int type = ISIX3M(parser->model) ?
452454
array_uint16_le (data + offset + 52) :
453-
REC_SAMPLE;
454-
// AI-generated (Claude)
455-
// APOS5 uses 0x8006 for ordinary profile samples. Keep this alias
456-
// narrow until the record type is confirmed by the vendor.
457-
if (firmware_major >= 5 && type == REC_SAMPLE_APOS5_COMPAT)
458-
type = REC_SAMPLE;
459-
if (type != REC_SAMPLE) {
460-
if (type == REC_INFO) {
461-
altitude = (signed int) array_uint32_le (data + offset + 40);
462-
longitude = (signed int) array_uint32_le (data + offset + 44);
463-
latitude = (signed int) array_uint32_le (data + offset + 48);
464-
have_location = 1;
465-
}
455+
0;
456+
if (type == REC_INFO) {
457+
altitude = (signed int) array_uint32_le (data + offset + 40);
458+
longitude = (signed int) array_uint32_le (data + offset + 44);
459+
latitude = (signed int) array_uint32_le (data + offset + 48);
460+
have_location = 1;
466461

467462
// Skip non-sample records.
468463
offset += samplesize;
@@ -588,6 +583,14 @@ divesystem_idive_parser_samples_foreach (dc_parser_t *abstract, dc_sample_callba
588583
unsigned int id = data[offset + 47] & 0x0F;
589584
unsigned int flags = data[offset + 47] & 0xF0;
590585
unsigned int pressure = data[offset + 49];
586+
unsigned int DC_ATTR_UNUSED rfchannel = 0;
587+
588+
if (type & TANK_VALID) {
589+
rfchannel = type & TANK_RFCHANNEL;
590+
if (type & TANK_PRESSURE_MSB) {
591+
pressure |= 0x100;
592+
}
593+
}
591594

592595
if (flags & 0x20) {
593596
// 300 bar transmitter.

0 commit comments

Comments
 (0)