diff --git a/src/libdivecomputer.symbols b/src/libdivecomputer.symbols index 9026f34..9df0c46 100644 --- a/src/libdivecomputer.symbols +++ b/src/libdivecomputer.symbols @@ -31,6 +31,7 @@ oceanic_atom2_device_handshake oceanic_atom2_device_open oceanic_atom2_device_quit oceanic_veo250_device_open +oceanic_veo250_device_keepalive reefnet_sensuspro_device_open reefnet_sensuspro_device_set_timestamp reefnet_sensuspro_device_write_interval diff --git a/src/oceanic_veo250.c b/src/oceanic_veo250.c index 35c9aeb..5f85ba4 100644 --- a/src/oceanic_veo250.c +++ b/src/oceanic_veo250.c @@ -303,6 +303,40 @@ oceanic_veo250_device_close (device_t *abstract) } +device_status_t +oceanic_veo250_device_keepalive (device_t *abstract) +{ + oceanic_veo250_device_t *device = (oceanic_veo250_device_t*) abstract; + + if (! device_is_oceanic_veo250 (abstract)) + return DEVICE_STATUS_TYPE_MISMATCH; + + // Send the command to the dive computer. + unsigned char command[4] = {0x91, 0x00, 0x00, 0x00}; + device_status_t rc = oceanic_veo250_send (device, command, sizeof (command)); + if (rc != DEVICE_STATUS_SUCCESS) { + WARNING ("Failed to send the command."); + return rc; + } + + // Receive the answer of the dive computer. + unsigned char answer[3] = {0}; + int n = serial_read (device->port, answer, sizeof (answer)); + if (n != sizeof (answer)) { + WARNING ("Failed to receive the answer."); + return EXITCODE (n); + } + + // Verify the answer. + if (answer[0] != ACK || answer[1] != NAK || answer[2] != NAK) { + WARNING ("Unexpected answer byte(s)."); + return DEVICE_STATUS_PROTOCOL; + } + + return DEVICE_STATUS_SUCCESS; +} + + static device_status_t oceanic_veo250_device_version (device_t *abstract, unsigned char data[], unsigned int size) { diff --git a/src/oceanic_veo250.h b/src/oceanic_veo250.h index 6e0235f..7c1a279 100644 --- a/src/oceanic_veo250.h +++ b/src/oceanic_veo250.h @@ -34,6 +34,9 @@ extern "C" { device_status_t oceanic_veo250_device_open (device_t **device, const char* name); +device_status_t +oceanic_veo250_device_keepalive (device_t *device); + #ifdef __cplusplus } #endif /* __cplusplus */