diff --git a/src/uwatec_aladin.c b/src/uwatec_aladin.c index 298a22b..116b921 100644 --- a/src/uwatec_aladin.c +++ b/src/uwatec_aladin.c @@ -52,13 +52,14 @@ struct uwatec_aladin_device_t { unsigned int timestamp; }; +static device_status_t uwatec_aladin_device_set_fingerprint (device_t *abstract, const unsigned char data[], unsigned int size); static device_status_t uwatec_aladin_device_dump (device_t *abstract, unsigned char data[], unsigned int size, unsigned int *result); static device_status_t uwatec_aladin_device_foreach (device_t *abstract, dive_callback_t callback, void *userdata); static device_status_t uwatec_aladin_device_close (device_t *abstract); static const device_backend_t uwatec_aladin_device_backend = { DEVICE_TYPE_UWATEC_ALADIN, - NULL, /* set_fingerprint */ + uwatec_aladin_device_set_fingerprint, /* set_fingerprint */ NULL, /* handshake */ NULL, /* version */ NULL, /* read */ @@ -173,6 +174,26 @@ uwatec_aladin_device_set_timestamp (device_t *abstract, unsigned int timestamp) } +static device_status_t +uwatec_aladin_device_set_fingerprint (device_t *abstract, const unsigned char data[], unsigned int size) +{ + uwatec_aladin_device_t *device = (uwatec_aladin_device_t*) abstract; + + if (! device_is_uwatec_aladin (abstract)) + return DEVICE_STATUS_TYPE_MISMATCH; + + if (size && size != 4) + return DEVICE_STATUS_ERROR; + + if (size) + device->timestamp = data[0] + (data[1] << 8) + (data[2] << 16) + (data[3] << 24); + else + device->timestamp = 0; + + return DEVICE_STATUS_SUCCESS; +} + + static device_status_t uwatec_aladin_device_dump (device_t *abstract, unsigned char data[], unsigned int size, unsigned int *result) { diff --git a/src/uwatec_memomouse.c b/src/uwatec_memomouse.c index d0b47d4..233888b 100644 --- a/src/uwatec_memomouse.c +++ b/src/uwatec_memomouse.c @@ -51,13 +51,14 @@ struct uwatec_memomouse_device_t { unsigned int timestamp; }; +static device_status_t uwatec_memomouse_device_set_fingerprint (device_t *device, const unsigned char data[], unsigned int size); static device_status_t uwatec_memomouse_device_dump (device_t *abstract, unsigned char data[], unsigned int size, unsigned int *result); static device_status_t uwatec_memomouse_device_foreach (device_t *abstract, dive_callback_t callback, void *userdata); static device_status_t uwatec_memomouse_device_close (device_t *abstract); static const device_backend_t uwatec_memomouse_device_backend = { DEVICE_TYPE_UWATEC_MEMOMOUSE, - NULL, /* set_fingerprint */ + uwatec_memomouse_device_set_fingerprint, /* set_fingerprint */ NULL, /* handshake */ NULL, /* version */ NULL, /* read */ @@ -176,6 +177,26 @@ uwatec_memomouse_device_set_timestamp (device_t *abstract, unsigned int timestam } +static device_status_t +uwatec_memomouse_device_set_fingerprint (device_t *abstract, const unsigned char data[], unsigned int size) +{ + uwatec_memomouse_device_t *device = (uwatec_memomouse_device_t*) abstract; + + if (! device_is_uwatec_memomouse (abstract)) + return DEVICE_STATUS_TYPE_MISMATCH; + + if (size && size != 4) + return DEVICE_STATUS_ERROR; + + if (size) + device->timestamp = data[0] + (data[1] << 8) + (data[2] << 16) + (data[3] << 24); + else + device->timestamp = 0; + + return DEVICE_STATUS_SUCCESS; +} + + static device_status_t uwatec_memomouse_confirm (uwatec_memomouse_device_t *device, unsigned char value) { diff --git a/src/uwatec_smart.c b/src/uwatec_smart.c index 15638f7..f476ea0 100644 --- a/src/uwatec_smart.c +++ b/src/uwatec_smart.c @@ -48,13 +48,14 @@ struct uwatec_smart_device_t { unsigned int timestamp; }; +static device_status_t uwatec_smart_device_set_fingerprint (device_t *device, const unsigned char data[], unsigned int size); static device_status_t uwatec_smart_device_dump (device_t *abstract, unsigned char data[], unsigned int size, unsigned int *result); static device_status_t uwatec_smart_device_foreach (device_t *abstract, dive_callback_t callback, void *userdata); static device_status_t uwatec_smart_device_close (device_t *abstract); static const device_backend_t uwatec_smart_device_backend = { DEVICE_TYPE_UWATEC_SMART, - NULL, /* set_fingerprint */ + uwatec_smart_device_set_fingerprint, /* set_fingerprint */ NULL, /* handshake */ NULL, /* version */ NULL, /* read */ @@ -203,6 +204,26 @@ uwatec_smart_device_set_timestamp (device_t *abstract, unsigned int timestamp) } +static device_status_t +uwatec_smart_device_set_fingerprint (device_t *abstract, const unsigned char data[], unsigned int size) +{ + uwatec_smart_device_t *device = (uwatec_smart_device_t*) abstract; + + if (! device_is_uwatec_smart (abstract)) + return DEVICE_STATUS_TYPE_MISMATCH; + + if (size && size != 4) + return DEVICE_STATUS_ERROR; + + if (size) + device->timestamp = data[0] + (data[1] << 8) + (data[2] << 16) + (data[3] << 24); + else + device->timestamp = 0; + + return DEVICE_STATUS_SUCCESS; +} + + static device_status_t uwatec_smart_transfer (uwatec_smart_device_t *device, const unsigned char command[], unsigned int csize, unsigned char answer[], unsigned int asize) {