diff --git a/src/suunto_common2.c b/src/suunto_common2.c index 2bfbd11..0c1916a 100644 --- a/src/suunto_common2.c +++ b/src/suunto_common2.c @@ -35,8 +35,6 @@ #define SZ_PACKET 0x78 #define SZ_MINIMUM 8 -#define FP_OFFSET 0x15 - #define RB_PROFILE_DISTANCE(l,a,b,m) ringbuffer_distance (a, b, m, l->rb_profile_begin, l->rb_profile_end) #define BACKEND(abstract) ((suunto_common2_device_backend_t *) abstract->backend) @@ -413,10 +411,7 @@ suunto_common2_device_foreach (dc_device_t *abstract, dc_dive_callback_t callbac } if (next != current) { - unsigned int fp_offset = FP_OFFSET; - if (devinfo.model == 0x15) - fp_offset += 6; // HelO2 - + unsigned int fp_offset = layout->fingerprint + 4; if (memcmp (p + fp_offset, device->fingerprint, sizeof (device->fingerprint)) == 0) { free (data); return DC_STATUS_SUCCESS; diff --git a/src/suunto_common2.h b/src/suunto_common2.h index 693398e..6073e25 100644 --- a/src/suunto_common2.h +++ b/src/suunto_common2.h @@ -31,6 +31,8 @@ extern "C" { typedef struct suunto_common2_layout_t { // Memory size. unsigned int memsize; + // Fingerprint + unsigned int fingerprint; // Serial number. unsigned int serial; // Profile ringbuffer diff --git a/src/suunto_d9.c b/src/suunto_d9.c index 9f43448..259cbe9 100644 --- a/src/suunto_d9.c +++ b/src/suunto_d9.c @@ -65,6 +65,7 @@ static const suunto_common2_device_backend_t suunto_d9_device_backend = { static const suunto_common2_layout_t suunto_d9_layout = { 0x8000, /* memsize */ + 0x0011, /* fingerprint */ 0x0023, /* serial */ 0x019A, /* rb_profile_begin */ 0x7FFE /* rb_profile_end */ @@ -72,6 +73,7 @@ static const suunto_common2_layout_t suunto_d9_layout = { static const suunto_common2_layout_t suunto_d9tx_layout = { 0x10000, /* memsize */ + 0x0013, /* fingerprint */ 0x0024, /* serial */ 0x019A, /* rb_profile_begin */ 0xEBF0 /* rb_profile_end */ diff --git a/src/suunto_vyper2.c b/src/suunto_vyper2.c index 01ff2c2..ab68ab4 100644 --- a/src/suunto_vyper2.c +++ b/src/suunto_vyper2.c @@ -35,6 +35,8 @@ rc == -1 ? DC_STATUS_IO : DC_STATUS_TIMEOUT \ ) +#define HELO2 0x15 + typedef struct suunto_vyper2_device_t { suunto_common2_device_t base; serial_t *port; @@ -58,6 +60,15 @@ static const suunto_common2_device_backend_t suunto_vyper2_device_backend = { static const suunto_common2_layout_t suunto_vyper2_layout = { 0x8000, /* memsize */ + 0x0011, /* fingerprint */ + 0x0023, /* serial */ + 0x019A, /* rb_profile_begin */ + 0x7FFE /* rb_profile_end */ +}; + +static const suunto_common2_layout_t suunto_helo2_layout = { + 0x8000, /* memsize */ + 0x0017, /* fingerprint */ 0x0023, /* serial */ 0x019A, /* rb_profile_begin */ 0x7FFE /* rb_profile_end */ @@ -144,7 +155,11 @@ suunto_vyper2_device_open (dc_device_t **out, dc_context_t *context, const char } // Override the base class values. - device->base.layout = &suunto_vyper2_layout; + unsigned int model = device->base.version[0]; + if (model == HELO2) + device->base.layout = &suunto_helo2_layout; + else + device->base.layout = &suunto_vyper2_layout; *out = (dc_device_t*) device;