summaryrefslogtreecommitdiffstats
path: root/core
diff options
context:
space:
mode:
authorGravatar Linus Torvalds <torvalds@linux-foundation.org>2018-09-06 17:32:24 -0700
committerGravatar Dirk Hohndel <dirk@hohndel.org>2018-09-06 18:35:18 -0700
commit56a77f0fa3ed952f945b34f13b065124909654ea (patch)
treed4f53744da832746a4e5b00dae37381770a4b25a /core
parentc03c2b5fd74b3dd8b434f5472cba59328748800d (diff)
downloadsubsurface-56a77f0fa3ed952f945b34f13b065124909654ea.tar.gz
Garmin devices - like Shearwater - want random BLE addressing
We had a special-case for the Shearwater case, let's just make it slightly more generic and add Garmin to the list of vendors that want a random BLE address rather than a static one. The Bluez model of having to state this explicitly - but not giving the information to the user - is completely broken and this is all very annoying, credit goes to Wojciech Więckowski for pointing this out. Of course, right now we don't actually know how to parse the BLE stream from the Garmin Descent, but with this (and some libdivecomputer hackery) I actually get connected and start receiving data. That we then can't parse, but that's hopefully just a libdivecomputer update away. Pointed-out-by: Wojciech Więckowski <xplwowi@gmail.com> Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org> Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
Diffstat (limited to 'core')
-rw-r--r--core/qt-ble.cpp11
1 files changed, 10 insertions, 1 deletions
diff --git a/core/qt-ble.cpp b/core/qt-ble.cpp
index 2d1de1408..b4678aa5c 100644
--- a/core/qt-ble.cpp
+++ b/core/qt-ble.cpp
@@ -25,6 +25,7 @@ static int debugCounter;
#define IS_HW(_d) same_string((_d)->vendor, "Heinrichs Weikamp")
#define IS_SHEARWATER(_d) same_string((_d)->vendor, "Shearwater")
+#define IS_GARMIN(_d) same_string((_d)->vendor, "Garmin")
#define MAXIMAL_HW_CREDIT 255
#define MINIMAL_HW_CREDIT 32
@@ -271,6 +272,14 @@ dc_status_t BLEObject::setupHwTerminalIo(QList<QLowEnergyCharacteristic> allC)
return setHwCredit(MAXIMAL_HW_CREDIT);
}
+// Bluez is broken, and doesn't have a sane way to query
+// whether to use a random address or not. So we have to
+// fake it.
+static int use_random_address(dc_user_device_t *user_device)
+{
+ return IS_SHEARWATER(user_device) || IS_GARMIN(user_device);
+}
+
dc_status_t qt_ble_open(void **io, dc_context_t *, const char *devaddr, dc_user_device_t *user_device)
{
debugCounter = 0;
@@ -302,7 +311,7 @@ dc_status_t qt_ble_open(void **io, dc_context_t *, const char *devaddr, dc_user_
#endif
qDebug() << "qt_ble_open(" << devaddr << ")";
- if (IS_SHEARWATER(user_device))
+ if (use_random_address(user_device))
controller->setRemoteAddressType(QLowEnergyController::RandomAddress);
// Try to connect to the device