Skip to content

Commit 074b669

Browse files
jefdriesenmikeller
authored andcommitted
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. Cherry-picked-by: Michael Keller <[email protected]> Signed-off-by: Michael Keller <[email protected]>
1 parent 71a80b6 commit 074b669

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
@@ -48,6 +48,8 @@
4848
#define LOG_RECORD_OPENING_5 0x15
4949
#define LOG_RECORD_OPENING_6 0x16
5050
#define LOG_RECORD_OPENING_7 0x17
51+
#define LOG_RECORD_OPENING_8 0x18
52+
#define LOG_RECORD_OPENING_9 0x19
5153
#define LOG_RECORD_CLOSING_0 0x20
5254
#define LOG_RECORD_CLOSING_1 0x21
5355
#define LOG_RECORD_CLOSING_2 0x22
@@ -56,6 +58,8 @@
5658
#define LOG_RECORD_CLOSING_5 0x25
5759
#define LOG_RECORD_CLOSING_6 0x26
5860
#define LOG_RECORD_CLOSING_7 0x27
61+
#define LOG_RECORD_CLOSING_8 0x28
62+
#define LOG_RECORD_CLOSING_9 0x29
5963
#define LOG_RECORD_INFO_EVENT 0x30
6064
#define LOG_RECORD_DIVE_SAMPLE_EXT 0xE1
6165
#define LOG_RECORD_FINAL 0xFF
@@ -103,7 +107,7 @@
103107
#define NGASMIXES 20
104108
#define NFIXED 10
105109
#define NTANKS 6
106-
#define NRECORDS 8
110+
#define NRECORDS 10
107111
#define MAXSTRINGS 32
108112

109113
#define PREDATOR 2
@@ -657,7 +661,7 @@ shearwater_predator_parser_cache (shearwater_predator_parser_t *parser)
657661
} else if (type == LOG_RECORD_FREEDIVE_SAMPLE) {
658662
// Freedive record
659663
divemode = M_FREEDIVE;
660-
} else if (type >= LOG_RECORD_OPENING_0 && type <= LOG_RECORD_OPENING_7) {
664+
} else if (type >= LOG_RECORD_OPENING_0 && type <= LOG_RECORD_OPENING_9) {
661665
// Opening record
662666
parser->opening[type - LOG_RECORD_OPENING_0] = offset;
663667

@@ -760,7 +764,7 @@ shearwater_predator_parser_cache (shearwater_predator_parser_t *parser)
760764
memcpy (tank[3].name, data + offset + 12, sizeof (tank[3].name));
761765
}
762766
}
763-
} else if (type >= LOG_RECORD_CLOSING_0 && type <= LOG_RECORD_CLOSING_7) {
767+
} else if (type >= LOG_RECORD_CLOSING_0 && type <= LOG_RECORD_CLOSING_9) {
764768
if (type == LOG_RECORD_CLOSING_6) {
765769
if (logversion >= 11) {
766770
if (stack_time_total_s > 0) {
@@ -991,11 +995,13 @@ shearwater_predator_parser_get_field (dc_parser_t *abstract, dc_field_type_t typ
991995

992996
unsigned int decomodel_idx = parser->pnf ? parser->opening[2] + 18 : 67;
993997
unsigned int gf_idx = parser->pnf ? parser->opening[0] + 4 : 4;
998+
int latitude = 0, longitude = 0;
994999

9951000
dc_gasmix_t *gasmix = (dc_gasmix_t *) value;
9961001
dc_tank_t *tank = (dc_tank_t *) value;
9971002
dc_salinity_t *water = (dc_salinity_t *) value;
9981003
dc_decomodel_t *decomodel = (dc_decomodel_t *) value;
1004+
dc_location_t *location = (dc_location_t *) value;
9991005
dc_field_string_t *string = (dc_field_string_t *) value;
10001006

10011007
if (value) {
@@ -1091,6 +1097,17 @@ shearwater_predator_parser_get_field (dc_parser_t *abstract, dc_field_type_t typ
10911097
return DC_STATUS_DATAFORMAT;
10921098
}
10931099
break;
1100+
case DC_FIELD_LOCATION:
1101+
if (parser->opening[9] == UNDEFINED || parser->logversion < 17)
1102+
return DC_STATUS_UNSUPPORTED;
1103+
latitude = (signed int) array_uint32_be (data + parser->opening[9] + 21);
1104+
longitude = (signed int) array_uint32_be (data + parser->opening[9] + 25);
1105+
if (latitude == 0 && longitude == 0)
1106+
return DC_STATUS_UNSUPPORTED;
1107+
location->latitude = latitude / 100000.0;
1108+
location->longitude = longitude / 100000.0;
1109+
location->altitude = 0.0;
1110+
break;
10941111
case DC_FIELD_STRING:
10951112
return dc_field_get_string(&parser->cache, flags, string);
10961113
default:

0 commit comments

Comments
 (0)