Pass the fingerprint data to the callback function.
This commit is contained in:
parent
80352feee8
commit
4b590ba5e2
@ -118,13 +118,16 @@ event_cb (device_t *device, device_event_t event, const void *data, void *userda
|
||||
}
|
||||
|
||||
static int
|
||||
dive_cb (const unsigned char *data, unsigned int size, void *userdata)
|
||||
dive_cb (const unsigned char *data, unsigned int size, const unsigned char *fingerprint, unsigned int fsize, void *userdata)
|
||||
{
|
||||
static unsigned int count = 0;
|
||||
|
||||
count++;
|
||||
|
||||
message ("Dive: number=%u, size=%u\n", count, size);
|
||||
message ("Dive: number=%u, size=%u, fingerprint=", count, size);
|
||||
for (unsigned int i = 0; i < fsize; ++i)
|
||||
message ("%02X", fingerprint[i]);
|
||||
message ("\n");
|
||||
|
||||
return 1;
|
||||
}
|
||||
|
||||
@ -89,7 +89,7 @@ typedef struct device_clock_t {
|
||||
|
||||
typedef void (*device_event_callback_t) (device_t *device, device_event_t event, const void *data, void *userdata);
|
||||
|
||||
typedef int (*dive_callback_t) (const unsigned char *data, unsigned int size, void *userdata);
|
||||
typedef int (*dive_callback_t) (const unsigned char *data, unsigned int size, const unsigned char *fingerprint, unsigned int fsize, void *userdata);
|
||||
|
||||
device_type_t device_get_type (device_t *device);
|
||||
|
||||
|
||||
@ -172,7 +172,7 @@ mares_common_extract_dives (mares_common_device_t *device, const mares_common_la
|
||||
return DEVICE_STATUS_SUCCESS;
|
||||
}
|
||||
|
||||
if (callback && !callback (buffer + offset, nbytes, userdata)) {
|
||||
if (callback && !callback (buffer + offset, nbytes, buffer + fp_offset, sizeof (device->fingerprint), userdata)) {
|
||||
free (buffer);
|
||||
return DEVICE_STATUS_SUCCESS;
|
||||
}
|
||||
|
||||
@ -469,7 +469,8 @@ oceanic_common_device_foreach (device_t *abstract, dive_callback_t callback, voi
|
||||
offset -= PAGESIZE / 2;
|
||||
memcpy (profiles + offset + available, logbooks + current, PAGESIZE / 2);
|
||||
|
||||
if (callback && !callback (profiles + offset + available, rb_entry_size + PAGESIZE / 2, userdata)) {
|
||||
unsigned char *p = profiles + offset + available;
|
||||
if (callback && !callback (p, rb_entry_size + PAGESIZE / 2, p, PAGESIZE / 2, userdata)) {
|
||||
free (logbooks);
|
||||
free (profiles);
|
||||
return DEVICE_STATUS_SUCCESS;
|
||||
|
||||
@ -459,7 +459,7 @@ reefnet_sensus_extract_dives (device_t *abstract, const unsigned char data[], un
|
||||
if (device && timestamp <= device->timestamp)
|
||||
return DEVICE_STATUS_SUCCESS;
|
||||
|
||||
if (callback && !callback (data + current, offset - current, userdata))
|
||||
if (callback && !callback (data + current, offset - current, data + current + 2, 4, userdata))
|
||||
return DEVICE_STATUS_SUCCESS;
|
||||
|
||||
// Prepare for the next dive.
|
||||
|
||||
@ -435,7 +435,7 @@ reefnet_sensuspro_extract_dives (device_t *abstract, const unsigned char data[],
|
||||
if (device && timestamp <= device->timestamp)
|
||||
return DEVICE_STATUS_SUCCESS;
|
||||
|
||||
if (callback && !callback (data + current, offset + 2 - current, userdata))
|
||||
if (callback && !callback (data + current, offset + 2 - current, data + current + 6, 4, userdata))
|
||||
return DEVICE_STATUS_SUCCESS;
|
||||
|
||||
// Prepare for the next dive.
|
||||
|
||||
@ -672,7 +672,7 @@ reefnet_sensusultra_parse (reefnet_sensusultra_device_t *device,
|
||||
return DEVICE_STATUS_SUCCESS;
|
||||
}
|
||||
|
||||
if (callback && !callback (current, previous - current, userdata)) {
|
||||
if (callback && !callback (current, previous - current, current + 4, 4, userdata)) {
|
||||
if (aborted)
|
||||
*aborted = 1;
|
||||
return DEVICE_STATUS_SUCCESS;
|
||||
|
||||
@ -127,7 +127,7 @@ suunto_common_extract_dives (suunto_common_device_t *device, const suunto_common
|
||||
return DEVICE_STATUS_SUCCESS;
|
||||
}
|
||||
|
||||
if (callback && !callback (buffer, len, userdata)) {
|
||||
if (callback && !callback (buffer, len, buffer + layout->fp_offset, sizeof (device->fingerprint), userdata)) {
|
||||
free (buffer);
|
||||
return DEVICE_STATUS_SUCCESS;
|
||||
}
|
||||
|
||||
@ -365,8 +365,9 @@ suunto_common2_device_foreach (device_t *abstract, dive_callback_t callback, voi
|
||||
remaining -= size;
|
||||
available = nbytes - size;
|
||||
|
||||
unsigned int prev = array_uint16_le (data + offset + available + 0);
|
||||
unsigned int next = array_uint16_le (data + offset + available + 2);
|
||||
unsigned char *p = data + offset + available;
|
||||
unsigned int prev = array_uint16_le (p + 0);
|
||||
unsigned int next = array_uint16_le (p + 2);
|
||||
if (next != previous) {
|
||||
WARNING ("Profiles are not continuous.");
|
||||
return DEVICE_STATUS_ERROR;
|
||||
@ -376,10 +377,10 @@ suunto_common2_device_foreach (device_t *abstract, dive_callback_t callback, voi
|
||||
previous = current;
|
||||
current = prev;
|
||||
|
||||
if (memcmp (data + offset + available + FP_OFFSET, device->fingerprint, sizeof (device->fingerprint)) == 0)
|
||||
if (memcmp (p + FP_OFFSET, device->fingerprint, sizeof (device->fingerprint)) == 0)
|
||||
return DEVICE_STATUS_SUCCESS;
|
||||
|
||||
if (callback && !callback (data + offset + available + 4, size - 4, userdata))
|
||||
if (callback && !callback (p + 4, size - 4, p + FP_OFFSET, sizeof (device->fingerprint), userdata))
|
||||
return DEVICE_STATUS_SUCCESS;
|
||||
}
|
||||
|
||||
|
||||
@ -327,7 +327,7 @@ suunto_solution_extract_dives (device_t *abstract, const unsigned char data[], u
|
||||
if (data[peek] == 0x80) {
|
||||
unsigned int len = ringbuffer_distance (previous, current, 0, RB_PROFILE_BEGIN, RB_PROFILE_END);
|
||||
|
||||
if (callback && !callback (buffer + idx, len, userdata))
|
||||
if (callback && !callback (buffer + idx, len, NULL, 0, userdata))
|
||||
return DEVICE_STATUS_SUCCESS;
|
||||
|
||||
previous = current;
|
||||
|
||||
@ -563,7 +563,7 @@ suunto_vyper_device_foreach (device_t *abstract, dive_callback_t callback, void
|
||||
return DEVICE_STATUS_SUCCESS;
|
||||
}
|
||||
|
||||
if (callback && !callback (data, size, userdata)) {
|
||||
if (callback && !callback (data, size, data + layout->fp_offset, sizeof (device->fingerprint), userdata)) {
|
||||
dc_buffer_free (buffer);
|
||||
return DEVICE_STATUS_SUCCESS;
|
||||
}
|
||||
|
||||
@ -413,7 +413,7 @@ uwatec_aladin_extract_dives (device_t *abstract, const unsigned char* data, unsi
|
||||
if (device && timestamp <= device->timestamp)
|
||||
return DEVICE_STATUS_SUCCESS;
|
||||
|
||||
if (callback && !callback (buffer, len + 18, userdata))
|
||||
if (callback && !callback (buffer, len + 18, buffer + 11, 4, userdata))
|
||||
return DEVICE_STATUS_SUCCESS;
|
||||
}
|
||||
|
||||
|
||||
@ -575,7 +575,7 @@ uwatec_memomouse_extract_dives (device_t *abstract, const unsigned char data[],
|
||||
// Get the length of the profile data.
|
||||
unsigned int length = array_uint16_le (data + offset + 16);
|
||||
|
||||
if (callback && !callback (data + offset, length + 18, userdata))
|
||||
if (callback && !callback (data + offset, length + 18, data + offset + 11, 4, userdata))
|
||||
return DEVICE_STATUS_SUCCESS;
|
||||
}
|
||||
|
||||
|
||||
@ -475,7 +475,7 @@ uwatec_smart_extract_dives (device_t *abstract, const unsigned char data[], unsi
|
||||
if (current + len > previous)
|
||||
return DEVICE_STATUS_ERROR;
|
||||
|
||||
if (callback && !callback (data + current, len, userdata))
|
||||
if (callback && !callback (data + current, len, data + current + 8, 4, userdata))
|
||||
return DEVICE_STATUS_SUCCESS;
|
||||
|
||||
// Prepare for the next dive.
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user