From db38a7023db5ebf1c58e8bc652071d8f509bd001 Mon Sep 17 00:00:00 2001 From: Dirk Hohndel Date: Sat, 16 Sep 2017 20:19:41 -0700 Subject: [PATCH] BLE: helper function to get QBtDeviceInfo from UUID Right now this will only work if you scan for your BLE dive computer every time. Ideally we should simply initiate a scan and look for that address if it's not found in the hash. Signed-off-by: Dirk Hohndel --- core/btdiscovery.cpp | 14 ++++++++++++++ core/btdiscovery.h | 3 +++ 2 files changed, 17 insertions(+) diff --git a/core/btdiscovery.cpp b/core/btdiscovery.cpp index 90eb2e844..729ee9851 100644 --- a/core/btdiscovery.cpp +++ b/core/btdiscovery.cpp @@ -307,4 +307,18 @@ bool BTDiscovery::checkException(const char* method, const QAndroidJniObject *ob } #endif // Q_OS_ANDROID +QHash btDeviceInfo; + +void saveBtDeviceInfo(const char* devaddr, QBluetoothDeviceInfo deviceInfo) +{ + btDeviceInfo[devaddr] = deviceInfo; +} + +QBluetoothDeviceInfo getBtDeviceInfo(const char* devaddr) +{ + if (btDeviceInfo.contains(devaddr)) + return btDeviceInfo[devaddr]; + qDebug() << "need to scan for" << devaddr; + return QBluetoothDeviceInfo(); +} #endif // BT_SUPPORT diff --git a/core/btdiscovery.h b/core/btdiscovery.h index 71df24f24..160890c73 100644 --- a/core/btdiscovery.h +++ b/core/btdiscovery.h @@ -18,6 +18,9 @@ #include #endif +void saveBtDeviceInfo(const char* devaddr, QBluetoothDeviceInfo deviceInfo); +QBluetoothDeviceInfo getBtDeviceInfo(const char* devaddr); + class ConnectionListModel : public QAbstractListModel { Q_OBJECT public: