diff options
author | Linus Torvalds <torvalds@linux-foundation.org> | 2020-09-16 11:01:09 -0700 |
---|---|---|
committer | Dirk Hohndel <dirk@hohndel.org> | 2020-09-17 07:54:35 -0700 |
commit | aa95a9a744f28612bbb7706e4e45ba5b2aa5279d (patch) | |
tree | ccc538406f1c6a4eb6afeb760cb0ec568a25348f /core/qt-ble.cpp | |
parent | 981c1cb1d30ff68baf4c01179866c4b827747960 (diff) | |
download | subsurface-aa95a9a744f28612bbb7706e4e45ba5b2aa5279d.tar.gz |
Extend BLE uuid matching to the characteristics, add ignore-list
This extends the uuid matching to the low-level characteristics too, so
that we can ignore the McLean Extreme characteristics that aren't
interesting.
It also renames the uuid matching to be about a "uuid_list" rather than
being about the service we're matching, since we're now using it for
other uuid's than just services.
Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>
Diffstat (limited to 'core/qt-ble.cpp')
-rw-r--r-- | core/qt-ble.cpp | 33 |
1 files changed, 29 insertions, 4 deletions
diff --git a/core/qt-ble.cpp b/core/qt-ble.cpp index 2df22b73e..c271de4be 100644 --- a/core/qt-ble.cpp +++ b/core/qt-ble.cpp @@ -105,12 +105,12 @@ struct uuid_match { const char *uuid, *details; }; -static const char *match_service(const QBluetoothUuid &service, const struct uuid_match *array) +static const char *match_uuid_list(const QBluetoothUuid &match, const struct uuid_match *array) { const char *uuid; while ((uuid = array->uuid) != NULL) { - if (service == QUuid(uuid)) + if (match == QUuid(uuid)) return array->details; array++; } @@ -159,12 +159,12 @@ static const struct uuid_match upgrade_service_uuids[] = { static const char *is_known_serial_service(const QBluetoothUuid &service) { - return match_service(service, serial_service_uuids); + return match_uuid_list(service, serial_service_uuids); } static const char *is_known_bad_service(const QBluetoothUuid &service) { - return match_service(service, upgrade_service_uuids); + return match_uuid_list(service, upgrade_service_uuids); } void BLEObject::addService(const QBluetoothUuid &newService) @@ -247,9 +247,32 @@ BLEObject::~BLEObject() delete controller; } +/* + * The McLean Extreme has just one vendor service, but then inside that + * service it has several characteristics, and it's not obvious which + * ones are the read/write ones. + * + * So just make sure to skip the ones we don't want. + * + * The proper ones are: + * + * Microchip service UUID: 49535343-fe7d-4ae5-8fa9-9fafd205e455 + * TX characteristic: 49535343-1e4d-4bd9-ba61-23c647249616 + * RX characteristic: 49535343-8841-43f4-a8d4-ecbe34729bb3 + */ +static const struct uuid_match skip_characteristics[] = { + { "49535343-6daa-4d02-abf6-19569aca69fe", "McLean Extreme Avoid" }, + { "49535343-aca3-481c-91ec-d85e28a60318", "McLean Extreme Avoid" }, + { "49535343-026e-3a9b-954c-97daef17e26e", "McLean Extreme Avoid" }, + { "49535343-4c8a-39b3-2f49-511cff073b7e", "McLean Extreme Avoid" }, + { NULL, } +}; + // a write characteristic needs Write or WriteNoResponse static bool is_write_characteristic(const QLowEnergyCharacteristic &c) { + if (match_uuid_list(c.uuid(), skip_characteristics)) + return false; return c.properties() & (QLowEnergyCharacteristic::Write | QLowEnergyCharacteristic::WriteNoResponse); @@ -259,6 +282,8 @@ static bool is_write_characteristic(const QLowEnergyCharacteristic &c) // a descriptor to enable it static bool is_read_characteristic(const QLowEnergyCharacteristic &c) { + if (match_uuid_list(c.uuid(), skip_characteristics)) + return false; return !c.descriptors().empty() && (c.properties() & (QLowEnergyCharacteristic::Notify | |