diff options
author | Linus Torvalds <torvalds@linux-foundation.org> | 2018-09-23 12:07:01 -0700 |
---|---|---|
committer | Dirk Hohndel <dirk@hohndel.org> | 2018-09-23 17:29:05 -0700 |
commit | 30fb7bf35c9e8df2faf9d13a23872a8432cb9990 (patch) | |
tree | 60cfc31db7458843beb8292af95a417e7ce7a445 /core/qt-ble.h | |
parent | 594f13eeafe52eb070c10daad8322ce2074dd4e5 (diff) | |
download | subsurface-30fb7bf35c9e8df2faf9d13a23872a8432cb9990.tar.gz |
qt-ble: set up infrastructure for better preferred service choice
We used to just pick the first non-standard service we found (with a
special case for the Heinrichs Weikamp dive computers that have an
actual registered standard service).
We then waited for that service to finish discovery, and started using
it.
This changes the logic to wait for _all_ services to finish discovery,
and then after that we pick the one we like best. Right now the rule
for picking a preferred service is the same one we had before, but the
difference is that we now have the full discovery data, so we *could* do
something better.
Plus this makes our debug messages a lot more legible, when we don't
have the mix of overlapping service discovery with the actual IO we do
to the preferred service.
NOTE! This doesn't much matter for most of the dive computers that we
currently support BLE for. They don't tend to have a lot of odd
services.
But at least both the Mares BlueLink and the Garmin Descent both have
multiple services and it's not obvious which one to use, and this will
make it not only easier to debug those, it will make it easier to pick
the right preferred service descriptor to use.
Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>
Diffstat (limited to 'core/qt-ble.h')
-rw-r--r-- | core/qt-ble.h | 6 |
1 files changed, 3 insertions, 3 deletions
diff --git a/core/qt-ble.h b/core/qt-ble.h index 5b3991bef..ddf628e60 100644 --- a/core/qt-ble.h +++ b/core/qt-ble.h @@ -23,9 +23,8 @@ public: dc_status_t write(const void* data, size_t size, size_t *actual); dc_status_t read(void* data, size_t size, size_t *actual); - //TODO: need better mode of selecting the desired service than below - inline QLowEnergyService *preferredService() - { return services.isEmpty() ? nullptr : services[0]; } + inline QLowEnergyService *preferredService() { return preferred; } + dc_status_t select_preferred_service(void); public slots: void addService(const QBluetoothUuid &newService); @@ -39,6 +38,7 @@ private: QVector<QLowEnergyService *> services; QLowEnergyController *controller = nullptr; + QLowEnergyService *preferred = nullptr; QList<QByteArray> receivedPackets; bool isCharacteristicWritten; dc_user_device_t *device; |