Skip to content

Commit 73218b4

Browse files
sjaeckeljefdriesen
authored andcommitted
Exit PC Link mode when operation is done
The command to exit the PC Link mode does not appear to be supported for the BLE communication.
1 parent 5a24517 commit 73218b4

File tree

1 file changed

+23
-1
lines changed

1 file changed

+23
-1
lines changed

src/cressi_goa.c

Lines changed: 23 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -36,6 +36,7 @@
3636

3737
#define CMD_VERSION 0x00
3838
#define CMD_SET_TIME 0x13
39+
#define CMD_EXIT_PCLINK 0x1D
3940
#define CMD_LOGBOOK 0x21
4041
#define CMD_DIVE 0x22
4142

@@ -66,6 +67,7 @@ typedef struct cressi_goa_device_t {
6667
static dc_status_t cressi_goa_device_set_fingerprint (dc_device_t *abstract, const unsigned char data[], unsigned int size);
6768
static dc_status_t cressi_goa_device_foreach (dc_device_t *abstract, dc_dive_callback_t callback, void *userdata);
6869
static dc_status_t cressi_goa_device_timesync (dc_device_t *abstract, const dc_datetime_t *datetime);
70+
static dc_status_t cressi_goa_device_close (dc_device_t *abstract);
6971

7072
static const dc_device_vtable_t cressi_goa_device_vtable = {
7173
sizeof(cressi_goa_device_t),
@@ -76,7 +78,7 @@ static const dc_device_vtable_t cressi_goa_device_vtable = {
7678
NULL, /* dump */
7779
cressi_goa_device_foreach, /* foreach */
7880
cressi_goa_device_timesync, /* timesync */
79-
NULL /* close */
81+
cressi_goa_device_close /* close */
8082
};
8183

8284
static dc_status_t
@@ -659,3 +661,23 @@ cressi_goa_device_timesync (dc_device_t *abstract, const dc_datetime_t *datetime
659661

660662
return status;
661663
}
664+
665+
static dc_status_t
666+
cressi_goa_device_close (dc_device_t *abstract)
667+
{
668+
dc_status_t status = DC_STATUS_SUCCESS;
669+
cressi_goa_device_t *device = (cressi_goa_device_t *) abstract;
670+
dc_transport_t transport = dc_iostream_get_transport (device->iostream);
671+
672+
if (transport == DC_TRANSPORT_BLE) {
673+
return DC_STATUS_SUCCESS;
674+
}
675+
676+
status = cressi_goa_device_transfer (device, CMD_EXIT_PCLINK, NULL, 0, NULL, 0, NULL, NULL);
677+
if (status != DC_STATUS_SUCCESS) {
678+
ERROR (abstract->context, "Failed to exit PC Link.");
679+
return status;
680+
}
681+
682+
return status;
683+
}

0 commit comments

Comments
 (0)