Skip to content

Commit 4f5abbd

Browse files
committed
Add support for the Shearwater Swift GPS
With the new Swift GPS transmitter, the GPS location of the dive entry and exit points are stored in the opening and closing record number 9. At the moment only the entry location is reported because the api only supports a single location.
1 parent 75ecac9 commit 4f5abbd

File tree

1 file changed

+20
-3
lines changed

1 file changed

+20
-3
lines changed

src/shearwater_predator_parser.c

Lines changed: 20 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -46,6 +46,8 @@
4646
#define LOG_RECORD_OPENING_5 0x15
4747
#define LOG_RECORD_OPENING_6 0x16
4848
#define LOG_RECORD_OPENING_7 0x17
49+
#define LOG_RECORD_OPENING_8 0x18
50+
#define LOG_RECORD_OPENING_9 0x19
4951
#define LOG_RECORD_CLOSING_0 0x20
5052
#define LOG_RECORD_CLOSING_1 0x21
5153
#define LOG_RECORD_CLOSING_2 0x22
@@ -54,6 +56,8 @@
5456
#define LOG_RECORD_CLOSING_5 0x25
5557
#define LOG_RECORD_CLOSING_6 0x26
5658
#define LOG_RECORD_CLOSING_7 0x27
59+
#define LOG_RECORD_CLOSING_8 0x28
60+
#define LOG_RECORD_CLOSING_9 0x29
5761
#define LOG_RECORD_INFO_EVENT 0x30
5862
#define LOG_RECORD_DIVE_SAMPLE_EXT 0xE1
5963
#define LOG_RECORD_FINAL 0xFF
@@ -96,7 +100,7 @@
96100
#define NGASMIXES 20
97101
#define NFIXED 10
98102
#define NTANKS 6
99-
#define NRECORDS 8
103+
#define NRECORDS 10
100104

101105
#define PREDATOR 2
102106
#define PETREL 3
@@ -531,7 +535,7 @@ shearwater_predator_parser_cache (shearwater_predator_parser_t *parser)
531535
} else if (type == LOG_RECORD_FREEDIVE_SAMPLE) {
532536
// Freedive record
533537
divemode = M_FREEDIVE;
534-
} else if (type >= LOG_RECORD_OPENING_0 && type <= LOG_RECORD_OPENING_7) {
538+
} else if (type >= LOG_RECORD_OPENING_0 && type <= LOG_RECORD_OPENING_9) {
535539
// Opening record
536540
parser->opening[type - LOG_RECORD_OPENING_0] = offset;
537541

@@ -621,7 +625,7 @@ shearwater_predator_parser_cache (shearwater_predator_parser_t *parser)
621625
memcpy (tank[3].name, data + offset + 12, sizeof (tank[3].name));
622626
}
623627
}
624-
} else if (type >= LOG_RECORD_CLOSING_0 && type <= LOG_RECORD_CLOSING_7) {
628+
} else if (type >= LOG_RECORD_CLOSING_0 && type <= LOG_RECORD_CLOSING_9) {
625629
// Closing record
626630
parser->closing[type - LOG_RECORD_CLOSING_0] = offset;
627631
} else if (type == LOG_RECORD_FINAL) {
@@ -752,11 +756,13 @@ shearwater_predator_parser_get_field (dc_parser_t *abstract, dc_field_type_t typ
752756

753757
unsigned int decomodel_idx = parser->pnf ? parser->opening[2] + 18 : 67;
754758
unsigned int gf_idx = parser->pnf ? parser->opening[0] + 4 : 4;
759+
int latitude = 0, longitude = 0;
755760

756761
dc_gasmix_t *gasmix = (dc_gasmix_t *) value;
757762
dc_tank_t *tank = (dc_tank_t *) value;
758763
dc_salinity_t *water = (dc_salinity_t *) value;
759764
dc_decomodel_t *decomodel = (dc_decomodel_t *) value;
765+
dc_location_t *location = (dc_location_t *) value;
760766

761767
if (value) {
762768
switch (type) {
@@ -865,6 +871,17 @@ shearwater_predator_parser_get_field (dc_parser_t *abstract, dc_field_type_t typ
865871
return DC_STATUS_DATAFORMAT;
866872
}
867873
break;
874+
case DC_FIELD_LOCATION:
875+
if (parser->opening[9] == UNDEFINED || parser->logversion < 17)
876+
return DC_STATUS_UNSUPPORTED;
877+
latitude = (signed int) array_uint32_be (data + parser->opening[9] + 21);
878+
longitude = (signed int) array_uint32_be (data + parser->opening[9] + 25);
879+
if (latitude == 0 && longitude == 0)
880+
return DC_STATUS_UNSUPPORTED;
881+
location->latitude = latitude / 100000.0;
882+
location->longitude = longitude / 100000.0;
883+
location->altitude = 0.0;
884+
break;
868885
default:
869886
return DC_STATUS_UNSUPPORTED;
870887
}

0 commit comments

Comments
 (0)