Ratio BLE detection fix

For Ratio dive computers we can't tell by the Bluetooth name which model it is.
There are BT only models and BLE only models. The failure case here was a user
on iOS (BLE only) with a BLE only dive computer which we didn't recognize
because previously we returned a BT only device (which isn't supported on an
iPhone), and the lookup won't return a valid descriptor if the transport needed
isn't available.

These days BLE is far more common, so return a BLE enabled name by default, but
try a BT only name just in case.

Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
This commit is contained in:
Dirk Hohndel 2022-08-29 09:51:56 -07:00
parent 8c644547fb
commit 0a4689c2e6
2 changed files with 18 additions and 6 deletions

View file

@ -2,6 +2,8 @@ divelist: do not include planned versions of a dive if there is real data
desktop: fix key composition in tag widgets and dive site widget
mobile: allow cloud account deletion (Apple app store requirement)
mobile: fix listing of local cloud cache directories
dive computer support:
- fix Ratio dive computer detection for BLE only devices
---
* Always add new entries at the very top of this file above other existing entries and this note.

View file

@ -100,19 +100,19 @@ static dc_descriptor_t *getDeviceType(QString btName)
else if (btName.mid(4,2) == "2-") product = "OSTC 2N";
else if (btName.mid(4,2) == "+ ") product = "OSTC 2";
// all BT/BLE enabled OSTCs are HW_FAMILY_OSTC_3, so when we do not know,
// just use a default product that allows the codoe to download from the
// just use a default product that allows the code to download from the
// user's dive computer
else product = "OSTC 2";
} else if (btName.contains(QRegularExpression("^DS\\d{6}"))) {
// The Ratio bluetooth name looks like the Pelagic ones,
// but that seems to be just happenstance.
vendor = "Ratio";
product = "iX3M GPS Easy"; // we don't know which of the GPS models, so set one
product = "iX3M 2021 GPS Easy"; // we don't know which of the Bluetooth models, so set one that supports BLE
} else if (btName.contains(QRegularExpression("^IX5M\\d{6}"))) {
// The 2021 iX3M models (square buttons) report as iX5M,
// eventhough the physical model states iX3M.
vendor = "Ratio";
product = "iX3M GPS Easy"; // we don't know which of the GPS models, so set one
product = "iX3M 2021 GPS Easy"; // we don't know which of the Bluetooth models, so set one that supports BLE
} else if (btName.contains(QRegularExpression("^[A-Z]{2}\\d{6}"))) {
// try the Pelagic/Aqualung name patterns
// the source of truth for this data is in libdivecomputer/src/descriptor.c
@ -142,11 +142,21 @@ static dc_descriptor_t *getDeviceType(QString btName)
// check if we found a known dive computer
if (!vendor.isEmpty() && !product.isEmpty()) {
dc_descriptor_t *lookup = descriptorLookup.value(vendor.toLower() + product.toLower());
if (!lookup)
qWarning("known dive computer %s not found in descriptorLookup", qPrintable(QString(vendor + product)));
if (!lookup) {
// the Ratio dive computers come in BT only or BLE only and we can't tell
// which just from the name; so while this is fairly unlikely, the user
// could be on an older computer / device that only supports BT and no BLE
// and giving the BLE only name might therefore not work, so try the other
// one just in case
if (vendor == "Ratio" && product == "iX3M 2021 GPS Easy") {
product = "iX3M GPS Easy"; // this one is BT only
lookup = descriptorLookup.value(vendor.toLower() + product.toLower());
}
if (!lookup) // still nothing?
qWarning("known dive computer %s not found in descriptorLookup", qPrintable(QString(vendor + product)));
}
return lookup;
}
return nullptr;
}