From 45b9ee8376cee4d3156c3330fad64335f057e456 Mon Sep 17 00:00:00 2001 From: Jef Driesen Date: Fri, 30 Dec 2022 15:20:10 +0100 Subject: [PATCH 1/6] Remove a duplicated include statement --- src/parser.c | 1 - 1 file changed, 1 deletion(-) diff --git a/src/parser.c b/src/parser.c index 1ae480a..c766477 100644 --- a/src/parser.c +++ b/src/parser.c @@ -35,7 +35,6 @@ #include "uwatec_memomouse.h" #include "uwatec_smart.h" #include "oceanic_atom2.h" -#include "oceanic_atom2.h" #include "oceanic_veo250.h" #include "oceanic_vtpro.h" #include "mares_darwin.h" From f59cbf0fe5364a88d69416d27d7a224fc93b7a31 Mon Sep 17 00:00:00 2001 From: Jef Driesen Date: Fri, 30 Dec 2022 15:21:15 +0100 Subject: [PATCH 2/6] Move all model numbers to the common header --- src/oceanic_atom2.c | 8 --- src/oceanic_atom2_parser.c | 73 ---------------------------- src/oceanic_common.h | 97 +++++++++++++++++++++++++++++++++++++ src/oceanic_veo250_parser.c | 6 --- src/oceanic_vtpro.c | 2 - src/oceanic_vtpro_parser.c | 2 - 6 files changed, 97 insertions(+), 91 deletions(-) diff --git a/src/oceanic_atom2.c b/src/oceanic_atom2.c index 4de6dec..9f5cc17 100644 --- a/src/oceanic_atom2.c +++ b/src/oceanic_atom2.c @@ -35,14 +35,6 @@ #define ISINSTANCE(device) dc_device_isinstance((device), &oceanic_atom2_device_vtable.base) -#define PROPLUSX 0x4552 -#define VTX 0x4557 -#define I750TC 0x455A -#define SAGE 0x4647 -#define I770R 0x4651 -#define GEO40 0x4653 -#define BEACON 0x4742 - #define MAXPACKET 256 #define MAXRETRIES 2 #define MAXDELAY 16 diff --git a/src/oceanic_atom2_parser.c b/src/oceanic_atom2_parser.c index 56d9a00..f6b1f71 100644 --- a/src/oceanic_atom2_parser.c +++ b/src/oceanic_atom2_parser.c @@ -31,79 +31,6 @@ #define ISINSTANCE(parser) dc_parser_isinstance((parser), &oceanic_atom2_parser_vtable) -#define ATOM1 0x4250 -#define EPICA 0x4257 -#define VT3 0x4258 -#define T3A 0x4259 -#define ATOM2 0x4342 -#define GEO 0x4344 -#define MANTA 0x4345 -#define DATAMASK 0x4347 -#define COMPUMASK 0x4348 -#define OC1A 0x434E -#define F10A 0x434D -#define WISDOM2 0x4350 -#define INSIGHT2 0x4353 -#define ELEMENT2 0x4357 -#define VEO20 0x4359 -#define VEO30 0x435A -#define ZEN 0x4441 -#define ZENAIR 0x4442 -#define ATMOSAI2 0x4443 -#define PROPLUS21 0x4444 -#define GEO20 0x4446 -#define VT4 0x4447 -#define OC1B 0x4449 -#define VOYAGER2G 0x444B -#define ATOM3 0x444C -#define DG03 0x444D -#define OCS 0x4450 -#define OC1C 0x4451 -#define VT41 0x4452 -#define EPICB 0x4453 -#define T3B 0x4455 -#define ATOM31 0x4456 -#define A300AI 0x4457 -#define WISDOM3 0x4458 -#define A300 0x445A -#define TX1 0x4542 -#define MUNDIAL2 0x4543 -#define AMPHOS 0x4545 -#define AMPHOSAIR 0x4546 -#define PROPLUS3 0x4548 -#define F11A 0x4549 -#define OCI 0x454B -#define A300CS 0x454C -#define TALIS 0x454E -#define MUNDIAL3 0x4550 -#define PROPLUSX 0x4552 -#define F10B 0x4553 -#define F11B 0x4554 -#define XPAIR 0x4555 -#define VISION 0x4556 -#define VTX 0x4557 -#define I300 0x4559 -#define I750TC 0x455A -#define I450T 0x4641 -#define I550 0x4642 -#define I200 0x4646 -#define SAGE 0x4647 -#define I300C 0x4648 -#define I200C 0x4649 -#define I100 0x464E -#define I770R 0x4651 -#define I550C 0x4652 -#define GEO40 0x4653 -#define VEO40 0x4654 -#define WISDOM4 0x4655 -#define PROPLUS4 0x4656 -#define AMPHOS2 0x4657 -#define AMPHOSAIR2 0x4658 -#define BEACON 0x4742 -#define I470TC 0x4743 -#define I200CV2 0x4749 -#define GEOAIR 0x474B - #define NORMAL 0 #define GAUGE 1 #define FREEDIVE 2 diff --git a/src/oceanic_common.h b/src/oceanic_common.h index 915081e..16fd976 100644 --- a/src/oceanic_common.h +++ b/src/oceanic_common.h @@ -28,6 +28,103 @@ extern "C" { #endif /* __cplusplus */ +// vtpro +#define AERIS500AI 0x4151 +#define VERSAPRO 0x4155 +#define ATMOS2 0x4158 +#define PROPLUS2 0x4159 +#define ATMOSAI 0x4244 +#define VTPRO 0x4245 +#define WISDOM 0x4246 +#define ELITE 0x424F + +// veo250 +#define REACTPRO 0x4247 +#define VEO200 0x424B +#define VEO250 0x424C +#define XP5 0x4251 +#define VEO180 0x4252 +#define XR2 0x4255 +#define INSIGHT 0x425A +#define DG02 0x4352 + +// atom2 +#define ATOM1 0x4250 +#define EPICA 0x4257 +#define VT3 0x4258 +#define T3A 0x4259 +#define ATOM2 0x4342 +#define GEO 0x4344 +#define MANTA 0x4345 +#define XR1NX 0x4346 +#define DATAMASK 0x4347 +#define COMPUMASK 0x4348 +#define F10A 0x434D +#define OC1A 0x434E +#define WISDOM2 0x4350 +#define INSIGHT2 0x4353 +#define REACTPROWHITE 0x4354 +#define ELEMENT2 0x4357 +#define VEO10 0x4358 +#define VEO20 0x4359 +#define VEO30 0x435A +#define ZEN 0x4441 +#define ZENAIR 0x4442 +#define ATMOSAI2 0x4443 +#define PROPLUS21 0x4444 +#define GEO20 0x4446 +#define VT4 0x4447 +#define OC1B 0x4449 +#define VOYAGER2G 0x444B +#define ATOM3 0x444C +#define DG03 0x444D +#define OCS 0x4450 +#define OC1C 0x4451 +#define VT41 0x4452 +#define EPICB 0x4453 +#define T3B 0x4455 +#define ATOM31 0x4456 +#define A300AI 0x4457 +#define WISDOM3 0x4458 +#define A300 0x445A +#define TX1 0x4542 +#define MUNDIAL2 0x4543 +#define AMPHOS 0x4545 +#define AMPHOSAIR 0x4546 +#define PROPLUS3 0x4548 +#define F11A 0x4549 +#define OCI 0x454B +#define A300CS 0x454C +#define TALIS 0x454E +#define MUNDIAL3 0x4550 +#define PROPLUSX 0x4552 +#define F10B 0x4553 +#define F11B 0x4554 +#define XPAIR 0x4555 +#define VISION 0x4556 +#define VTX 0x4557 +#define I300 0x4559 +#define I750TC 0x455A +#define I450T 0x4641 +#define I550 0x4642 +#define I200 0x4646 +#define SAGE 0x4647 +#define I300C 0x4648 +#define I200C 0x4649 +#define I100 0x464E +#define I770R 0x4651 +#define I550C 0x4652 +#define GEO40 0x4653 +#define VEO40 0x4654 +#define WISDOM4 0x4655 +#define PROPLUS4 0x4656 +#define AMPHOS2 0x4657 +#define AMPHOSAIR2 0x4658 +#define BEACON 0x4742 +#define I470TC 0x4743 +#define I200CV2 0x4749 +#define GEOAIR 0x474B + #define PAGESIZE 0x10 #define FPMAXSIZE 0x20 diff --git a/src/oceanic_veo250_parser.c b/src/oceanic_veo250_parser.c index 4e59ede..90d3383 100644 --- a/src/oceanic_veo250_parser.c +++ b/src/oceanic_veo250_parser.c @@ -31,12 +31,6 @@ #define ISINSTANCE(parser) dc_parser_isinstance((parser), &oceanic_veo250_parser_vtable) -#define REACTPRO 0x4247 -#define VEO200 0x424B -#define VEO250 0x424C -#define INSIGHT 0x425A -#define REACTPROWHITE 0x4354 - typedef struct oceanic_veo250_parser_t oceanic_veo250_parser_t; struct oceanic_veo250_parser_t { diff --git a/src/oceanic_vtpro.c b/src/oceanic_vtpro.c index 74b94ec..4cb85f1 100644 --- a/src/oceanic_vtpro.c +++ b/src/oceanic_vtpro.c @@ -40,8 +40,6 @@ #define NAK 0xA5 #define END 0x51 -#define AERIS500AI 0x4151 - typedef enum oceanic_vtpro_protocol_t { MOD, INTR, diff --git a/src/oceanic_vtpro_parser.c b/src/oceanic_vtpro_parser.c index 1c60e62..9650c49 100644 --- a/src/oceanic_vtpro_parser.c +++ b/src/oceanic_vtpro_parser.c @@ -31,8 +31,6 @@ #define ISINSTANCE(parser) dc_parser_isinstance((parser), &oceanic_vtpro_parser_vtable) -#define AERIS500AI 0x4151 - typedef struct oceanic_vtpro_parser_t oceanic_vtpro_parser_t; struct oceanic_vtpro_parser_t { From d0857c49ec80c8e7074e6a44cfdf1b14f96c52b2 Mon Sep 17 00:00:00 2001 From: Jef Driesen Date: Fri, 30 Dec 2022 16:09:21 +0100 Subject: [PATCH 3/6] Add the model number to the version table With the model number in the version table, the version string can be mapped to the corresponding model number. This allows to implement some model specific behaviour already before being able to read the model number. In most cases, there is a simple one to one relationship between the version string and the model number, but there are also a few exceptions: * For the Sherwood Wisdom 2 and 3, and the Beuchat Mundial 2 and 3, each variant has a different model number, but the first part of the version string is identical. The difference is in the firmware version part. Handling this correctly requires two entries in the table. * For the Oceanic OC1 there are 3 different model numbers, and only 2 different version strings. That means there is no correct mapping possible. --- src/oceanic_atom2.c | 158 ++++++++++++++++++++++--------------------- src/oceanic_common.c | 5 +- src/oceanic_common.h | 4 +- src/oceanic_veo250.c | 24 ++++--- src/oceanic_vtpro.c | 23 ++++--- 5 files changed, 116 insertions(+), 98 deletions(-) diff --git a/src/oceanic_atom2.c b/src/oceanic_atom2.c index 9f5cc17..de52e96 100644 --- a/src/oceanic_atom2.c +++ b/src/oceanic_atom2.c @@ -402,101 +402,103 @@ static const oceanic_common_layout_t aqualung_i450t_layout = { }; static const oceanic_common_version_t versions[] = { - {"OCEVEO10 \0\0 8K", 0, &oceanic_veo1_layout}, - {"AERIS XR1 NX R\0\0", 0, &oceanic_veo1_layout}, + {"OCEVEO10 \0\0 8K", 0, VEO10, &oceanic_veo1_layout}, + {"AERIS XR1 NX R\0\0", 0, XR1NX, &oceanic_veo1_layout}, - {"ATOM rev\0\0 256K", 0, &oceanic_atom1_layout}, + {"ATOM rev\0\0 256K", 0, ATOM1, &oceanic_atom1_layout}, - {"MANTA R\0\0 512K", 0x3242, &oceanic_atom2a_layout}, - {"MANTA R\0\0 512K", 0, &oceanic_atom2c_layout}, - {"2M ATOM r\0\0 512K", 0x3349, &oceanic_atom2a_layout}, - {"2M ATOM r\0\0 512K", 0, &oceanic_atom2c_layout}, + {"MANTA R\0\0 512K", 0x3242, MANTA, &oceanic_atom2a_layout}, + {"MANTA R\0\0 512K", 0, MANTA, &oceanic_atom2c_layout}, + {"2M ATOM r\0\0 512K", 0x3349, ATOM2, &oceanic_atom2a_layout}, + {"2M ATOM r\0\0 512K", 0, ATOM2, &oceanic_atom2c_layout}, - {"INSIGHT2 \0\0 512K", 0, &oceanic_atom2a_layout}, - {"OCEVEO30 \0\0 512K", 0, &oceanic_atom2a_layout}, - {"ATMOSAI R\0\0 512K", 0, &oceanic_atom2a_layout}, - {"PROPLUS2 \0\0 512K", 0, &oceanic_atom2a_layout}, - {"OCEGEO20 \0\0 512K", 0, &oceanic_atom2a_layout}, - {"OCE GEO R\0\0 512K", 0, &oceanic_atom2a_layout}, - {"AQUAI200 \0\0 512K", 0, &oceanic_atom2a_layout}, - {"AQUA200C \0\0 512K", 0, &oceanic_atom2a_layout}, + {"INSIGHT2 \0\0 512K", 0, INSIGHT2, &oceanic_atom2a_layout}, + {"OCEVEO30 \0\0 512K", 0, VEO30, &oceanic_atom2a_layout}, + {"ATMOSAI R\0\0 512K", 0, ATMOSAI2, &oceanic_atom2a_layout}, + {"PROPLUS2 \0\0 512K", 0, PROPLUS21, &oceanic_atom2a_layout}, + {"OCEGEO20 \0\0 512K", 0, GEO20, &oceanic_atom2a_layout}, + {"OCE GEO R\0\0 512K", 0, GEO, &oceanic_atom2a_layout}, + {"AQUAI200 \0\0 512K", 0, I200, &oceanic_atom2a_layout}, + {"AQUA200C \0\0 512K", 0, I200C, &oceanic_atom2a_layout}, - {"ELEMENT2 \0\0 512K", 0, &oceanic_atom2b_layout}, - {"OCEVEO20 \0\0 512K", 0, &oceanic_atom2b_layout}, - {"TUSAZEN \0\0 512K", 0, &oceanic_atom2b_layout}, - {"AQUAI300 \0\0 512K", 0, &oceanic_atom2b_layout}, - {"HOLLDG03 \0\0 512K", 0, &oceanic_atom2b_layout}, - {"AQUAI100 \0\0 512K", 0, &oceanic_atom2b_layout}, - {"AQUA300C \0\0 512K", 0, &oceanic_atom2b_layout}, - {"OCEGEO40 \0\0 512K", 0, &oceanic_atom2b_layout}, - {"VEOSMART \0\0 512K", 0, &oceanic_atom2b_layout}, + {"ELEMENT2 \0\0 512K", 0, ELEMENT2, &oceanic_atom2b_layout}, + {"OCEVEO20 \0\0 512K", 0, VEO20, &oceanic_atom2b_layout}, + {"TUSAZEN \0\0 512K", 0, ZEN, &oceanic_atom2b_layout}, + {"AQUAI300 \0\0 512K", 0, I300, &oceanic_atom2b_layout}, + {"HOLLDG03 \0\0 512K", 0, DG03, &oceanic_atom2b_layout}, + {"AQUAI100 \0\0 512K", 0, I100, &oceanic_atom2b_layout}, + {"AQUA300C \0\0 512K", 0, I300C, &oceanic_atom2b_layout}, + {"OCEGEO40 \0\0 512K", 0, GEO40, &oceanic_atom2b_layout}, + {"VEOSMART \0\0 512K", 0, VEO40, &oceanic_atom2b_layout}, - {"2M EPIC r\0\0 512K", 0, &oceanic_atom2c_layout}, - {"EPIC1 R\0\0 512K", 0, &oceanic_atom2c_layout}, - {"AERIA300 \0\0 512K", 0, &oceanic_atom2c_layout}, + {"2M EPIC r\0\0 512K", 0, EPICA, &oceanic_atom2c_layout}, + {"EPIC1 R\0\0 512K", 0, EPICB, &oceanic_atom2c_layout}, + {"AERIA300 \0\0 512K", 0, A300, &oceanic_atom2c_layout}, - {"OCE VT3 R\0\0 512K", 0, &oceanic_default_layout}, - {"ELITET3 R\0\0 512K", 0, &oceanic_default_layout}, - {"ELITET31 \0\0 512K", 0, &oceanic_default_layout}, - {"DATAMASK \0\0 512K", 0, &oceanic_default_layout}, - {"COMPMASK \0\0 512K", 0, &oceanic_default_layout}, + {"OCE VT3 R\0\0 512K", 0, VT3, &oceanic_default_layout}, + {"ELITET3 R\0\0 512K", 0, T3A, &oceanic_default_layout}, + {"ELITET31 \0\0 512K", 0, T3B, &oceanic_default_layout}, + {"DATAMASK \0\0 512K", 0, DATAMASK, &oceanic_default_layout}, + {"COMPMASK \0\0 512K", 0, COMPUMASK, &oceanic_default_layout}, - {"WISDOM R\0\0 512K", 0, &sherwood_wisdom_layout}, + {"WISDOM R\0\0 512K", 0x3342, WISDOM3, &sherwood_wisdom_layout}, + {"WISDOM R\0\0 512K", 0, WISDOM2, &sherwood_wisdom_layout}, - {"PROPLUS3 \0\0 512K", 0, &oceanic_proplus3_layout}, - {"PROPLUS4 \0\0 512K", 0, &oceanic_proplus3_layout}, + {"PROPLUS3 \0\0 512K", 0, PROPLUS3, &oceanic_proplus3_layout}, + {"PROPLUS4 \0\0 512K", 0, PROPLUS4, &oceanic_proplus3_layout}, - {"TUZENAIR \0\0 512K", 0, &tusa_zenair_layout}, - {"AMPHOSSW \0\0 512K", 0, &tusa_zenair_layout}, - {"AMPHOAIR \0\0 512K", 0, &tusa_zenair_layout}, - {"VOYAGE2G \0\0 512K", 0, &tusa_zenair_layout}, - {"TUSTALIS \0\0 512K", 0, &tusa_zenair_layout}, - {"AMPHOS20 \0\0 512K", 0, &tusa_zenair_layout}, - {"AMPAIR20 \0\0 512K", 0, &tusa_zenair_layout}, + {"TUZENAIR \0\0 512K", 0, ZENAIR, &tusa_zenair_layout}, + {"AMPHOSSW \0\0 512K", 0, AMPHOS, &tusa_zenair_layout}, + {"AMPHOAIR \0\0 512K", 0, AMPHOSAIR, &tusa_zenair_layout}, + {"VOYAGE2G \0\0 512K", 0, VOYAGER2G, &tusa_zenair_layout}, + {"TUSTALIS \0\0 512K", 0, TALIS, &tusa_zenair_layout}, + {"AMPHOS20 \0\0 512K", 0, AMPHOS2, &tusa_zenair_layout}, + {"AMPAIR20 \0\0 512K", 0, AMPHOSAIR2, &tusa_zenair_layout}, - {"REACPRO2 \0\0 512K", 0, &oceanic_reactpro_layout}, + {"REACPRO2 \0\0 512K", 0, REACTPROWHITE, &oceanic_reactpro_layout}, - {"FREEWAER \0\0 512K", 0, &aeris_f10_layout}, - {"OCEANF10 \0\0 512K", 0, &aeris_f10_layout}, - {"MUNDIAL R\0\0 512K", 0, &aeris_f10_layout}, + {"FREEWAER \0\0 512K", 0, F10A, &aeris_f10_layout}, + {"OCEANF10 \0\0 512K", 0, F10B, &aeris_f10_layout}, + {"MUNDIAL R\0\0 512K", 0x3300, MUNDIAL3, &aeris_f10_layout}, + {"MUNDIAL R\0\0 512K", 0, MUNDIAL2, &aeris_f10_layout}, - {"AERISF11 \0\0 1024", 0, &aeris_f11_layout}, - {"OCEANF11 \0\0 1024", 0, &aeris_f11_layout}, + {"AERISF11 \0\0 1024", 0, F11A, &aeris_f11_layout}, + {"OCEANF11 \0\0 1024", 0, F11B, &aeris_f11_layout}, - {"OCWATCH R\0\0 1024", 0, &oceanic_oc1_layout}, - {"OC1WATCH \0\0 1024", 0, &oceanic_oc1_layout}, - {"OCSWATCH \0\0 1024", 0, &oceanic_oc1_layout}, - {"AQUAI550 \0\0 1024", 0, &oceanic_oc1_layout}, - {"AQUA550C \0\0 1024", 0, &oceanic_oc1_layout}, - {"WISDOM04 \0\0 1024", 0, &oceanic_oc1_layout}, - {"AQUA470C \0\0 1024", 0, &oceanic_oc1_layout}, - {"AQUA200C \0\0 1024", 0, &oceanic_oc1_layout}, - {"GEOAIR \0\0 1024", 0, &oceanic_oc1_layout}, + {"OCWATCH R\0\0 1024", 0, OC1A, &oceanic_oc1_layout}, + {"OC1WATCH \0\0 1024", 0, OC1B, &oceanic_oc1_layout}, + {"OCSWATCH \0\0 1024", 0, OCS, &oceanic_oc1_layout}, + {"AQUAI550 \0\0 1024", 0, I550, &oceanic_oc1_layout}, + {"AQUA550C \0\0 1024", 0, I550C, &oceanic_oc1_layout}, + {"WISDOM04 \0\0 1024", 0, WISDOM4, &oceanic_oc1_layout}, + {"AQUA470C \0\0 1024", 0, I470TC, &oceanic_oc1_layout}, + {"AQUA200C \0\0 1024", 0, I200CV2, &oceanic_oc1_layout}, + {"GEOAIR \0\0 1024", 0, GEOAIR, &oceanic_oc1_layout}, - {"OCEANOCI \0\0 1024", 0, &oceanic_oci_layout}, + {"OCEANOCI \0\0 1024", 0, OCI, &oceanic_oci_layout}, - {"OCEATOM3 \0\0 1024", 0, &oceanic_atom3_layout}, - {"ATOM31 \0\0 1024", 0, &oceanic_atom3_layout}, + {"OCEATOM3 \0\0 1024", 0, ATOM3, &oceanic_atom3_layout}, + {"ATOM31 \0\0 1024", 0, ATOM31, &oceanic_atom3_layout}, - {"OCEANVT4 \0\0 1024", 0, &oceanic_vt4_layout}, - {"OCEAVT41 \0\0 1024", 0, &oceanic_vt4_layout}, - {"AERISAIR \0\0 1024", 0, &oceanic_vt4_layout}, - {"SWVISION \0\0 1024", 0, &oceanic_vt4_layout}, - {"XPSUBAIR \0\0 1024", 0, &oceanic_vt4_layout}, + {"OCEANVT4 \0\0 1024", 0, VT4, &oceanic_vt4_layout}, + {"OCEAVT41 \0\0 1024", 0, VT41, &oceanic_vt4_layout}, + {"AERISAIR \0\0 1024", 0, A300AI, &oceanic_vt4_layout}, + {"SWVISION \0\0 1024", 0, VISION, &oceanic_vt4_layout}, + {"XPSUBAIR \0\0 1024", 0, XPAIR, &oceanic_vt4_layout}, - {"HOLLDG04 \0\0 2048", 0, &hollis_tx1_layout}, + {"HOLLDG04 \0\0 2048", 0, TX1, &hollis_tx1_layout}, - {"AER300CS \0\0 2048", 0, &aeris_a300cs_layout}, - {"OCEANVTX \0\0 2048", 0, &aeris_a300cs_layout}, - {"AQUAI750 \0\0 2048", 0, &aeris_a300cs_layout}, - {"SWDRAGON \0\0 2048", 0, &aeris_a300cs_layout}, - {"SWBEACON \0\0 2048", 0, &aeris_a300cs_layout}, + {"AER300CS \0\0 2048", 0, A300CS, &aeris_a300cs_layout}, + {"OCEANVTX \0\0 2048", 0, VTX, &aeris_a300cs_layout}, + {"AQUAI750 \0\0 2048", 0, I750TC, &aeris_a300cs_layout}, + {"SWDRAGON \0\0 2048", 0, SAGE, &aeris_a300cs_layout}, + {"SWBEACON \0\0 2048", 0, BEACON, &aeris_a300cs_layout}, - {"AQUAI450 \0\0 2048", 0, &aqualung_i450t_layout}, + {"AQUAI450 \0\0 2048", 0, I450T, &aqualung_i450t_layout}, - {"OCEANOCX \0\0 \0\0\0\0", 0, &oceanic_proplusx_layout}, + {"OCEANOCX \0\0 \0\0\0\0", 0, PROPLUSX, &oceanic_proplusx_layout}, - {"AQUA770R \0\0 \0\0\0\0", 0, &aqualung_i770r_layout}, + {"AQUA770R \0\0 \0\0\0\0", 0, I770R, &aqualung_i770r_layout}, }; /* @@ -925,8 +927,8 @@ oceanic_atom2_device_open (dc_device_t **out, dc_context_t *context, dc_iostream } // Detect the memory layout. - device->base.layout = OCEANIC_COMMON_MATCH(device->base.version, versions, &device->base.firmware); - if (device->base.layout == NULL) { + const oceanic_common_version_t *version = OCEANIC_COMMON_MATCH(device->base.version, versions, &device->base.firmware); + if (version == NULL) { WARNING (context, "Unsupported device detected!"); if (memcmp(device->base.version + 12, "256K", 4) == 0) { device->base.layout = &oceanic_atom1_layout; @@ -939,6 +941,10 @@ oceanic_atom2_device_open (dc_device_t **out, dc_context_t *context, dc_iostream } else { device->base.layout = &oceanic_default_layout; } + device->base.model = 0; + } else { + device->base.layout = version->layout; + device->base.model = version->model; } // Set the big page support. diff --git a/src/oceanic_common.c b/src/oceanic_common.c index f876d28..62f5f74 100644 --- a/src/oceanic_common.c +++ b/src/oceanic_common.c @@ -132,7 +132,7 @@ oceanic_common_match_pattern (const unsigned char *string, const unsigned char * return 1; } -const oceanic_common_layout_t * +const oceanic_common_version_t * oceanic_common_match (const unsigned char *version, const oceanic_common_version_t patterns[], size_t n, unsigned int *firmware) { for (size_t i = 0; i < n; ++i) { @@ -143,7 +143,7 @@ oceanic_common_match (const unsigned char *version, const oceanic_common_version if (firmware) { *firmware = fw; } - return patterns[i].layout; + return patterns + i; } } @@ -160,6 +160,7 @@ oceanic_common_device_init (oceanic_common_device_t *device) device->firmware = 0; memset (device->version, 0, sizeof (device->version)); memset (device->fingerprint, 0, sizeof (device->fingerprint)); + device->model = 0; device->layout = NULL; device->multipage = 1; } diff --git a/src/oceanic_common.h b/src/oceanic_common.h index 16fd976..045dca4 100644 --- a/src/oceanic_common.h +++ b/src/oceanic_common.h @@ -161,6 +161,7 @@ typedef struct oceanic_common_device_t { unsigned int firmware; unsigned char version[PAGESIZE]; unsigned char fingerprint[FPMAXSIZE]; + unsigned int model; const oceanic_common_layout_t *layout; unsigned int multipage; } oceanic_common_device_t; @@ -174,10 +175,11 @@ typedef struct oceanic_common_device_vtable_t { typedef struct oceanic_common_version_t { unsigned char pattern[PAGESIZE + 1]; unsigned int firmware; + unsigned int model; const oceanic_common_layout_t *layout; } oceanic_common_version_t; -const oceanic_common_layout_t * +const oceanic_common_version_t * oceanic_common_match (const unsigned char *version, const oceanic_common_version_t patterns[], size_t n, unsigned int *firmware); void diff --git a/src/oceanic_veo250.c b/src/oceanic_veo250.c index db323db..58a9ceb 100644 --- a/src/oceanic_veo250.c +++ b/src/oceanic_veo250.c @@ -78,14 +78,14 @@ static const oceanic_common_layout_t oceanic_veo250_layout = { }; static const oceanic_common_version_t versions[] = { - {"GENREACT \0\0 256K", 0, &oceanic_veo250_layout}, - {"VEO 200 R\0\0 256K", 0, &oceanic_veo250_layout}, - {"VEO 250 R\0\0 256K", 0, &oceanic_veo250_layout}, - {"SEEMANN R\0\0 256K", 0, &oceanic_veo250_layout}, - {"VEO 180 R\0\0 256K", 0, &oceanic_veo250_layout}, - {"AERISXR2 \0\0 256K", 0, &oceanic_veo250_layout}, - {"INSIGHT R\0\0 256K", 0, &oceanic_veo250_layout}, - {"HO DGO2 R\0\0 256K", 0, &oceanic_veo250_layout}, + {"GENREACT \0\0 256K", 0, REACTPRO, &oceanic_veo250_layout}, + {"VEO 200 R\0\0 256K", 0, VEO200, &oceanic_veo250_layout}, + {"VEO 250 R\0\0 256K", 0, VEO250, &oceanic_veo250_layout}, + {"SEEMANN R\0\0 256K", 0, XP5, &oceanic_veo250_layout}, + {"VEO 180 R\0\0 256K", 0, VEO180, &oceanic_veo250_layout}, + {"AERISXR2 \0\0 256K", 0, XR2, &oceanic_veo250_layout}, + {"INSIGHT R\0\0 256K", 0, INSIGHT, &oceanic_veo250_layout}, + {"HO DGO2 R\0\0 256K", 0, DG02, &oceanic_veo250_layout}, }; static dc_status_t @@ -316,10 +316,14 @@ oceanic_veo250_device_open (dc_device_t **out, dc_context_t *context, dc_iostrea } // Detect the memory layout. - device->base.layout = OCEANIC_COMMON_MATCH(device->base.version, versions, &device->base.firmware); - if (device->base.layout == NULL) { + const oceanic_common_version_t *version = OCEANIC_COMMON_MATCH(device->base.version, versions, &device->base.firmware); + if (version == NULL) { WARNING (context, "Unsupported device detected!"); device->base.layout = &oceanic_veo250_layout; + device->base.model = 0; + } else { + device->base.layout = version->layout; + device->base.model = version->model; } *out = (dc_device_t*) device; diff --git a/src/oceanic_vtpro.c b/src/oceanic_vtpro.c index 4cb85f1..5e11115 100644 --- a/src/oceanic_vtpro.c +++ b/src/oceanic_vtpro.c @@ -118,14 +118,14 @@ static const oceanic_common_layout_t aeris_500ai_layout = { }; static const oceanic_common_version_t versions[] = { - {"VERSAPRO \0\0 256K", 0, &oceanic_vtpro_layout}, - {"ATMOSTWO \0\0 256K", 0, &oceanic_vtpro_layout}, - {"PROPLUS2 \0\0 256K", 0, &oceanic_vtpro_layout}, - {"ATMOSAIR \0\0 256K", 0, &oceanic_vtpro_layout}, - {"VTPRO r\0\0 256K", 0, &oceanic_vtpro_layout}, - {"ELITE r\0\0 256K", 0, &oceanic_vtpro_layout}, + {"VERSAPRO \0\0 256K", 0, VERSAPRO, &oceanic_vtpro_layout}, + {"ATMOSTWO \0\0 256K", 0, ATMOS2, &oceanic_vtpro_layout}, + {"PROPLUS2 \0\0 256K", 0, PROPLUS2, &oceanic_vtpro_layout}, + {"ATMOSAIR \0\0 256K", 0, ATMOSAI, &oceanic_vtpro_layout}, + {"VTPRO r\0\0 256K", 0, VTPRO, &oceanic_vtpro_layout}, + {"ELITE r\0\0 256K", 0, ELITE, &oceanic_vtpro_layout}, - {"WISDOM r\0\0 256K", 0, &oceanic_wisdom_layout}, + {"WISDOM r\0\0 256K", 0, WISDOM, &oceanic_wisdom_layout}, }; static dc_status_t @@ -490,11 +490,16 @@ oceanic_vtpro_device_open (dc_device_t **out, dc_context_t *context, dc_iostream // Detect the memory layout. if (model == AERIS500AI) { device->base.layout = &aeris_500ai_layout; + device->base.model = AERIS500AI; } else { - device->base.layout = OCEANIC_COMMON_MATCH(device->base.version, versions, &device->base.firmware); - if (device->base.layout == NULL) { + const oceanic_common_version_t * version = OCEANIC_COMMON_MATCH(device->base.version, versions, &device->base.firmware); + if (version == NULL) { WARNING (context, "Unsupported device detected!"); device->base.layout = &oceanic_vtpro_layout; + device->base.model = 0; + } else { + device->base.layout = version->layout; + device->base.model = version->model; } } From 3414f72f605efd64061626e60c8540a92135858a Mon Sep 17 00:00:00 2001 From: Jef Driesen Date: Fri, 30 Dec 2022 22:26:39 +0100 Subject: [PATCH 4/6] Remove the model number from the vtpro struct The model number is now also available in the common struct. There is no need to store it twice. The auto-detected model number from the version table is also more reliable than the one passed by the caller. --- src/oceanic_vtpro.c | 4 +--- 1 file changed, 1 insertion(+), 3 deletions(-) diff --git a/src/oceanic_vtpro.c b/src/oceanic_vtpro.c index 5e11115..ef3d6d1 100644 --- a/src/oceanic_vtpro.c +++ b/src/oceanic_vtpro.c @@ -48,7 +48,6 @@ typedef enum oceanic_vtpro_protocol_t { typedef struct oceanic_vtpro_device_t { oceanic_common_device_t base; dc_iostream_t *iostream; - unsigned int model; oceanic_vtpro_protocol_t protocol; } oceanic_vtpro_device_t; @@ -379,7 +378,7 @@ oceanic_vtpro_device_logbook (dc_device_t *abstract, dc_event_progress_t *progre { oceanic_vtpro_device_t *device = (oceanic_vtpro_device_t *) abstract; - if (device->model == AERIS500AI) { + if (device->base.model == AERIS500AI) { return oceanic_aeris500ai_device_logbook (abstract, progress, logbook); } else { return oceanic_common_device_logbook (abstract, progress, logbook); @@ -410,7 +409,6 @@ oceanic_vtpro_device_open (dc_device_t **out, dc_context_t *context, dc_iostream // Set the default values. device->iostream = iostream; - device->model = model; if (model == AERIS500AI) { device->protocol = INTR; } else { From ceae89e149c5685a39fa9ca56700e8a856698512 Mon Sep 17 00:00:00 2001 From: Jef Driesen Date: Thu, 29 Dec 2022 16:34:53 +0100 Subject: [PATCH 5/6] Enable big page support The Oceanic Pro Plus 4 appears to support the big page B4 and B8 read commands, but with some strange twists: * When sending the B8 read command, a 256 byte packet is received. The checksums of the packet are valid, but the upper half of the payload data is always filled with zero bytes. That means we can't use this command. * The B4 read command appears to use a 2 byte checksum instead of the normal 1 byte checksum. That means we can use this command with a small model specific tweak. --- src/oceanic_atom2.c | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/src/oceanic_atom2.c b/src/oceanic_atom2.c index de52e96..ee60215 100644 --- a/src/oceanic_atom2.c +++ b/src/oceanic_atom2.c @@ -948,7 +948,8 @@ oceanic_atom2_device_open (dc_device_t **out, dc_context_t *context, dc_iostream } // Set the big page support. - if (device->base.layout == &aeris_f11_layout) { + if (device->base.layout == &aeris_f11_layout || + device->base.layout == &oceanic_proplus3_layout) { device->bigpage = 8; } else if (device->base.layout == &oceanic_proplusx_layout || device->base.layout == &aqualung_i770r_layout || @@ -1042,7 +1043,7 @@ oceanic_atom2_device_read (dc_device_t *abstract, unsigned int address, unsigned break; case 8: read_cmd = CMD_READ8; - crc_size = 1; + crc_size = device->base.model == PROPLUS4 ? 2 : 1; break; case 16: read_cmd = CMD_READ16; From e0e3bc89946c5f4633f4bfef79b534723cd446e2 Mon Sep 17 00:00:00 2001 From: Jef Driesen Date: Thu, 29 Dec 2022 17:31:01 +0100 Subject: [PATCH 6/6] Repeat the handshake every few packets The Oceanic Pro Plus 4 appears to "disconnect" somehow after about 30 seconds. The BLE connection remains up, but the dive computer simply stops responding to commands. The download fails with a timeout error, and the end-user can only download a few dives at most. The Android DiverLog+ application appears to keep the connection alive by re-sending the version and handshake commands once in a while. Copy this behaviour by repeating those two commands every 50 read requests. During testing, that's approximately every 25 seconds. Note that both commands are required, sending only one of them does not fix the problem. --- src/oceanic_atom2.c | 15 +++++++++++++++ 1 file changed, 15 insertions(+) diff --git a/src/oceanic_atom2.c b/src/oceanic_atom2.c index ee60215..cc1e3c3 100644 --- a/src/oceanic_atom2.c +++ b/src/oceanic_atom2.c @@ -54,9 +54,13 @@ #define ACK 0x5A #define NAK 0xA5 +#define REPEAT 50 + typedef struct oceanic_atom2_device_t { oceanic_common_device_t base; dc_iostream_t *iostream; + unsigned int handshake_repeat; + unsigned int handshake_counter; unsigned int sequence; unsigned int delay; unsigned int extra; @@ -957,6 +961,11 @@ oceanic_atom2_device_open (dc_device_t **out, dc_context_t *context, dc_iostream device->bigpage = 16; } + // Repeat the handshaking every few packets. + device->handshake_repeat = dc_iostream_get_transport (device->iostream) == DC_TRANSPORT_BLE && + device->base.model == PROPLUS4; + device->handshake_counter = 0; + *out = (dc_device_t*) device; return DC_STATUS_SUCCESS; @@ -1074,6 +1083,12 @@ oceanic_atom2_device_read (dc_device_t *abstract, unsigned int address, unsigned unsigned int page = (address - highmem) / pagesize; if (page != device->cached_page || highmem != device->cached_highmem) { + if (device->handshake_repeat && ++device->handshake_counter % REPEAT == 0) { + unsigned char version[PAGESIZE] = {0}; + oceanic_atom2_device_version (abstract, version, sizeof (version)); + oceanic_atom2_ble_handshake (device); + } + // Read the package. unsigned int number = highmem ? page : page * device->bigpage; // This is always PAGESIZE, even in big page mode. unsigned char command[] = {read_cmd,