From 22e0ab3d2b03ef462611b7a8a193ae59876c9ba4 Mon Sep 17 00:00:00 2001 From: Jef Driesen Date: Tue, 1 Aug 2017 13:28:03 +0200 Subject: [PATCH] Implement the new api for the HW devices The Heinrichs-Weikamp devices already supported clock synchronization by means of a device specific function. This is now replaced with the new api. --- include/libdivecomputer/hw_frog.h | 3 --- include/libdivecomputer/hw_ostc.h | 3 --- include/libdivecomputer/hw_ostc3.h | 3 --- src/hw_frog.c | 10 ++++------ src/hw_ostc.c | 10 ++++------ src/hw_ostc3.c | 10 ++++------ src/libdivecomputer.symbols | 3 --- 7 files changed, 12 insertions(+), 30 deletions(-) diff --git a/include/libdivecomputer/hw_frog.h b/include/libdivecomputer/hw_frog.h index 67f624f..0af10ca 100644 --- a/include/libdivecomputer/hw_frog.h +++ b/include/libdivecomputer/hw_frog.h @@ -36,9 +36,6 @@ extern "C" { dc_status_t hw_frog_device_version (dc_device_t *device, unsigned char data[], unsigned int size); -dc_status_t -hw_frog_device_clock (dc_device_t *device, const dc_datetime_t *datetime); - dc_status_t hw_frog_device_display (dc_device_t *device, const char *text); diff --git a/include/libdivecomputer/hw_ostc.h b/include/libdivecomputer/hw_ostc.h index b68e083..b7daca7 100644 --- a/include/libdivecomputer/hw_ostc.h +++ b/include/libdivecomputer/hw_ostc.h @@ -43,9 +43,6 @@ typedef enum hw_ostc_format_t { dc_status_t hw_ostc_device_md2hash (dc_device_t *device, unsigned char data[], unsigned int size); -dc_status_t -hw_ostc_device_clock (dc_device_t *device, const dc_datetime_t *datetime); - dc_status_t hw_ostc_device_eeprom_read (dc_device_t *device, unsigned int bank, unsigned char data[], unsigned int size); diff --git a/include/libdivecomputer/hw_ostc3.h b/include/libdivecomputer/hw_ostc3.h index bd0d2ed..c69dd93 100644 --- a/include/libdivecomputer/hw_ostc3.h +++ b/include/libdivecomputer/hw_ostc3.h @@ -39,9 +39,6 @@ hw_ostc3_device_version (dc_device_t *device, unsigned char data[], unsigned int dc_status_t hw_ostc3_device_hardware (dc_device_t *device, unsigned char data[], unsigned int size); -dc_status_t -hw_ostc3_device_clock (dc_device_t *device, const dc_datetime_t *datetime); - dc_status_t hw_ostc3_device_display (dc_device_t *device, const char *text); diff --git a/src/hw_frog.c b/src/hw_frog.c index 31caa83..83ee998 100644 --- a/src/hw_frog.c +++ b/src/hw_frog.c @@ -61,6 +61,7 @@ typedef struct hw_frog_device_t { static dc_status_t hw_frog_device_set_fingerprint (dc_device_t *abstract, const unsigned char data[], unsigned int size); static dc_status_t hw_frog_device_foreach (dc_device_t *abstract, dc_dive_callback_t callback, void *userdata); +static dc_status_t hw_frog_device_timesync (dc_device_t *abstract, const dc_datetime_t *datetime); static dc_status_t hw_frog_device_close (dc_device_t *abstract); static const dc_device_vtable_t hw_frog_device_vtable = { @@ -71,7 +72,7 @@ static const dc_device_vtable_t hw_frog_device_vtable = { NULL, /* write */ NULL, /* dump */ hw_frog_device_foreach, /* foreach */ - NULL, /* timesync */ + hw_frog_device_timesync, /* timesync */ hw_frog_device_close /* close */ }; @@ -483,14 +484,11 @@ hw_frog_device_foreach (dc_device_t *abstract, dc_dive_callback_t callback, void } -dc_status_t -hw_frog_device_clock (dc_device_t *abstract, const dc_datetime_t *datetime) +static dc_status_t +hw_frog_device_timesync (dc_device_t *abstract, const dc_datetime_t *datetime) { hw_frog_device_t *device = (hw_frog_device_t *) abstract; - if (!ISINSTANCE (abstract)) - return DC_STATUS_INVALIDARGS; - if (datetime == NULL) { ERROR (abstract->context, "Invalid parameter specified."); return DC_STATUS_INVALIDARGS; diff --git a/src/hw_ostc.c b/src/hw_ostc.c index b866f68..87c2b1d 100644 --- a/src/hw_ostc.c +++ b/src/hw_ostc.c @@ -70,6 +70,7 @@ typedef struct hw_ostc_firmware_t { static dc_status_t hw_ostc_device_set_fingerprint (dc_device_t *abstract, const unsigned char data[], unsigned int size); static dc_status_t hw_ostc_device_dump (dc_device_t *abstract, dc_buffer_t *buffer); static dc_status_t hw_ostc_device_foreach (dc_device_t *abstract, dc_dive_callback_t callback, void *userdata); +static dc_status_t hw_ostc_device_timesync (dc_device_t *abstract, const dc_datetime_t *datetime); static dc_status_t hw_ostc_device_close (dc_device_t *abstract); static const dc_device_vtable_t hw_ostc_device_vtable = { @@ -80,7 +81,7 @@ static const dc_device_vtable_t hw_ostc_device_vtable = { NULL, /* write */ hw_ostc_device_dump, /* dump */ hw_ostc_device_foreach, /* foreach */ - NULL, /* timesync */ + hw_ostc_device_timesync, /* timesync */ hw_ostc_device_close /* close */ }; @@ -378,15 +379,12 @@ hw_ostc_device_md2hash (dc_device_t *abstract, unsigned char data[], unsigned in } -dc_status_t -hw_ostc_device_clock (dc_device_t *abstract, const dc_datetime_t *datetime) +static dc_status_t +hw_ostc_device_timesync (dc_device_t *abstract, const dc_datetime_t *datetime) { dc_status_t status = DC_STATUS_SUCCESS; hw_ostc_device_t *device = (hw_ostc_device_t *) abstract; - if (!ISINSTANCE (abstract)) - return DC_STATUS_INVALIDARGS; - if (datetime == NULL) { ERROR (abstract->context, "Invalid parameter specified."); return DC_STATUS_INVALIDARGS; diff --git a/src/hw_ostc3.c b/src/hw_ostc3.c index 9081b1a..a1a5efd 100644 --- a/src/hw_ostc3.c +++ b/src/hw_ostc3.c @@ -129,6 +129,7 @@ static dc_status_t hw_ostc3_device_read (dc_device_t *abstract, unsigned int add static dc_status_t hw_ostc3_device_write (dc_device_t *abstract, unsigned int address, const unsigned char data[], unsigned int size); static dc_status_t hw_ostc3_device_dump (dc_device_t *abstract, dc_buffer_t *buffer); static dc_status_t hw_ostc3_device_foreach (dc_device_t *abstract, dc_dive_callback_t callback, void *userdata); +static dc_status_t hw_ostc3_device_timesync (dc_device_t *abstract, const dc_datetime_t *datetime); static dc_status_t hw_ostc3_device_close (dc_device_t *abstract); static const dc_device_vtable_t hw_ostc3_device_vtable = { @@ -139,7 +140,7 @@ static const dc_device_vtable_t hw_ostc3_device_vtable = { hw_ostc3_device_write, /* write */ hw_ostc3_device_dump, /* dump */ hw_ostc3_device_foreach, /* foreach */ - NULL, /* timesync */ + hw_ostc3_device_timesync, /* timesync */ hw_ostc3_device_close /* close */ }; @@ -802,14 +803,11 @@ hw_ostc3_device_foreach (dc_device_t *abstract, dc_dive_callback_t callback, voi } -dc_status_t -hw_ostc3_device_clock (dc_device_t *abstract, const dc_datetime_t *datetime) +static dc_status_t +hw_ostc3_device_timesync (dc_device_t *abstract, const dc_datetime_t *datetime) { hw_ostc3_device_t *device = (hw_ostc3_device_t *) abstract; - if (!ISINSTANCE (abstract)) - return DC_STATUS_INVALIDARGS; - if (datetime == NULL) { ERROR (abstract->context, "Invalid parameter specified."); return DC_STATUS_INVALIDARGS; diff --git a/src/libdivecomputer.symbols b/src/libdivecomputer.symbols index 237a9c1..3b16700 100644 --- a/src/libdivecomputer.symbols +++ b/src/libdivecomputer.symbols @@ -80,19 +80,16 @@ suunto_eon_device_write_name suunto_vyper2_device_version suunto_vyper2_device_reset_maxdepth hw_ostc_device_md2hash -hw_ostc_device_clock hw_ostc_device_eeprom_read hw_ostc_device_eeprom_write hw_ostc_device_reset hw_ostc_device_screenshot hw_ostc_device_fwupdate hw_frog_device_version -hw_frog_device_clock hw_frog_device_display hw_frog_device_customtext hw_ostc3_device_version hw_ostc3_device_hardware -hw_ostc3_device_clock hw_ostc3_device_display hw_ostc3_device_customtext hw_ostc3_device_config_read