diff --git a/examples/uwatec_smart_test.c b/examples/uwatec_smart_test.c index 8b2ceb3..fc9ba4f 100644 --- a/examples/uwatec_smart_test.c +++ b/examples/uwatec_smart_test.c @@ -46,16 +46,6 @@ test_dump_memory (const char* filename) return rc; } - message ("uwatec_smart_device_version\n"); - unsigned char version[UWATEC_SMART_VERSION_SIZE] = {0}; - rc = uwatec_smart_device_version (device, version, sizeof (version)); - if (rc != DC_STATUS_SUCCESS) { - WARNING ("Cannot identify computer."); - dc_device_close (device); - dc_context_free (context); - return rc; - } - dc_buffer_t *buffer = dc_buffer_new (0); message ("dc_device_dump\n"); diff --git a/include/libdivecomputer/uwatec_smart.h b/include/libdivecomputer/uwatec_smart.h index 191f389..0cf66d6 100644 --- a/include/libdivecomputer/uwatec_smart.h +++ b/include/libdivecomputer/uwatec_smart.h @@ -30,14 +30,9 @@ extern "C" { #endif /* __cplusplus */ -#define UWATEC_SMART_VERSION_SIZE 9 - dc_status_t uwatec_smart_device_open (dc_device_t **device, dc_context_t *context); -dc_status_t -uwatec_smart_device_version (dc_device_t *device, unsigned char data[], unsigned int size); - dc_status_t uwatec_smart_device_set_timestamp (dc_device_t *device, unsigned int timestamp); diff --git a/src/libdivecomputer.symbols b/src/libdivecomputer.symbols index 8ab0339..b0c062e 100644 --- a/src/libdivecomputer.symbols +++ b/src/libdivecomputer.symbols @@ -133,7 +133,6 @@ uwatec_memomouse_device_open uwatec_memomouse_device_set_timestamp uwatec_memomouse_extract_dives uwatec_smart_device_open -uwatec_smart_device_version uwatec_smart_device_set_timestamp uwatec_smart_extract_dives hw_ostc_device_open diff --git a/src/uwatec_smart.c b/src/uwatec_smart.c index 1378647..6f17d19 100644 --- a/src/uwatec_smart.c +++ b/src/uwatec_smart.c @@ -269,44 +269,11 @@ uwatec_smart_device_set_fingerprint (dc_device_t *abstract, const unsigned char } -dc_status_t -uwatec_smart_device_version (dc_device_t *abstract, unsigned char data[], unsigned int size) -{ - uwatec_smart_device_t *device = (uwatec_smart_device_t *) abstract; - - if (size < UWATEC_SMART_VERSION_SIZE) { - ERROR (abstract->context, "Insufficient buffer space available."); - return DC_STATUS_NOMEMORY; - } - - unsigned char command[1] = {0}; - - // Model Number. - command[0] = 0x10; - dc_status_t rc = uwatec_smart_transfer (device, command, 1, data + 0, 1); - if (rc != DC_STATUS_SUCCESS) - return rc; - - // Serial Number. - command[0] = 0x14; - rc = uwatec_smart_transfer (device, command, 1, data + 1, 4); - if (rc != DC_STATUS_SUCCESS) - return rc; - - // Current Timestamp. - command[0] = 0x1A; - rc = uwatec_smart_transfer (device, command, 1, data + 5, 4); - if (rc != DC_STATUS_SUCCESS) - return rc; - - return DC_STATUS_SUCCESS; -} - - static dc_status_t uwatec_smart_device_dump (dc_device_t *abstract, dc_buffer_t *buffer) { uwatec_smart_device_t *device = (uwatec_smart_device_t*) abstract; + dc_status_t rc = DC_STATUS_SUCCESS; if (! device_is_uwatec_smart (abstract)) return DC_STATUS_INVALIDARGS; @@ -321,15 +288,41 @@ uwatec_smart_device_dump (dc_device_t *abstract, dc_buffer_t *buffer) dc_event_progress_t progress = EVENT_PROGRESS_INITIALIZER; device_event_emit (&device->base, DC_EVENT_PROGRESS, &progress); - // Read the version and clock data. - unsigned char version[UWATEC_SMART_VERSION_SIZE] = {0}; - dc_status_t rc = uwatec_smart_device_version (abstract, version, sizeof (version)); + // Command template. + unsigned char command[9] = {0x00, + (device->timestamp ) & 0xFF, + (device->timestamp >> 8 ) & 0xFF, + (device->timestamp >> 16) & 0xFF, + (device->timestamp >> 24) & 0xFF, + 0x10, + 0x27, + 0, + 0}; + + // Read the model number. + command[0] = 0x10; + unsigned char model[1] = {0}; + rc = uwatec_smart_transfer (device, command, 1, model, sizeof (model)); + if (rc != DC_STATUS_SUCCESS) + return rc; + + // Read the serial number. + command[0] = 0x14; + unsigned char serial[4] = {0}; + rc = uwatec_smart_transfer (device, command, 1, serial, sizeof (serial)); + if (rc != DC_STATUS_SUCCESS) + return rc; + + // Read the device clock. + command[0] = 0x1A; + unsigned char devtime[4] = {0}; + rc = uwatec_smart_transfer (device, command, 1, devtime, sizeof (devtime)); if (rc != DC_STATUS_SUCCESS) return rc; // Store the clock calibration values. device->systime = dc_datetime_now (); - device->devtime = array_uint32_le (version + 5); + device->devtime = array_uint32_le (devtime); // Update and emit a progress event. progress.current += 9; @@ -343,25 +336,14 @@ uwatec_smart_device_dump (dc_device_t *abstract, dc_buffer_t *buffer) // Emit a device info event. dc_event_devinfo_t devinfo; - devinfo.model = version[0]; + devinfo.model = model[0]; devinfo.firmware = 0; - devinfo.serial = array_uint32_le (version + 1); + devinfo.serial = array_uint32_le (serial); device_event_emit (&device->base, DC_EVENT_DEVINFO, &devinfo); - // Command template. - unsigned char answer[4] = {0}; - unsigned char command[9] = {0x00, - (device->timestamp ) & 0xFF, - (device->timestamp >> 8 ) & 0xFF, - (device->timestamp >> 16) & 0xFF, - (device->timestamp >> 24) & 0xFF, - 0x10, - 0x27, - 0, - 0}; - // Data Length. command[0] = 0xC6; + unsigned char answer[4] = {0}; rc = uwatec_smart_transfer (device, command, sizeof (command), answer, sizeof (answer)); if (rc != DC_STATUS_SUCCESS) return rc;