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 <dirk@hohndel.org>
This commit is contained in:
Dirk Hohndel 2017-09-16 20:19:41 -07:00
parent e5b7fb74b4
commit db38a7023d
2 changed files with 17 additions and 0 deletions

View file

@ -307,4 +307,18 @@ bool BTDiscovery::checkException(const char* method, const QAndroidJniObject *ob
}
#endif // Q_OS_ANDROID
QHash<QString, QBluetoothDeviceInfo> 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

View file

@ -18,6 +18,9 @@
#include <QAndroidJniEnvironment>
#endif
void saveBtDeviceInfo(const char* devaddr, QBluetoothDeviceInfo deviceInfo);
QBluetoothDeviceInfo getBtDeviceInfo(const char* devaddr);
class ConnectionListModel : public QAbstractListModel {
Q_OBJECT
public: