diff options
author | Dirk Hohndel <dirk@hohndel.org> | 2017-07-07 22:19:23 -0700 |
---|---|---|
committer | Dirk Hohndel <dirk@hohndel.org> | 2017-07-08 09:57:21 -0700 |
commit | d5793ea6af5190420844ea06352f53e251352d99 (patch) | |
tree | bc184570938e45b306e2a7a27aca7f6a9c93a50b | |
parent | ed43b5dcedd150235cdc1ac5e5aedecb62f1c657 (diff) | |
download | subsurface-d5793ea6af5190420844ea06352f53e251352d99.tar.gz |
If we detect a different model than expected, use it
This is useful if the underlying code in libdivecomputer can reliably
detect specific hardware models.
Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
-rw-r--r-- | core/libdivecomputer.c | 11 |
1 files changed, 11 insertions, 0 deletions
diff --git a/core/libdivecomputer.c b/core/libdivecomputer.c index b548e3641..a44e4a1ca 100644 --- a/core/libdivecomputer.c +++ b/core/libdivecomputer.c @@ -1000,6 +1000,17 @@ static void event_cb(dc_device_t *device, dc_event_type_t event, const void *dat devinfo->firmware, devinfo->firmware, devinfo->serial, devinfo->serial); } + if (dc_descriptor_get_model(devdata->descriptor) != devinfo->model) { + fprintf(stderr, "EVENT_DEVINFO gave us the correct detected product (model %d instead of %d)\n", + devinfo->model, dc_descriptor_get_model(devdata->descriptor)); + dc_descriptor_t *better_descriptor = get_descriptor(dc_descriptor_get_type(devdata->descriptor), devinfo->model); + if (better_descriptor != NULL) { + devdata->descriptor = better_descriptor; + devdata->product = dc_descriptor_get_product(better_descriptor); + devdata->vendor = dc_descriptor_get_vendor(better_descriptor); + devdata->model = str_printf("%s %s", devdata->vendor, devdata->product); + } + } /* * libdivecomputer doesn't give serial numbers in the proper string form, * so we have to see if we can do some vendor-specific munging. |