From 0cfd76740b1af1424c39151e1628e1af6480a2d6 Mon Sep 17 00:00:00 2001 From: Dirk Hohndel Date: Mon, 24 Sep 2018 17:39:33 -0700 Subject: core: helper function to recognize BT/BLE addresses Signed-off-by: Dirk Hohndel --- core/btdiscovery.cpp | 9 +++++++++ 1 file changed, 9 insertions(+) (limited to 'core/btdiscovery.cpp') diff --git a/core/btdiscovery.cpp b/core/btdiscovery.cpp index a37f36a92..1527be624 100644 --- a/core/btdiscovery.cpp +++ b/core/btdiscovery.cpp @@ -6,6 +6,7 @@ #include #include #include +#include extern QMap descriptorLookup; @@ -301,6 +302,14 @@ bool BTDiscovery::checkException(const char* method, const QAndroidJniObject *ob QHash btDeviceInfo; +bool isBluetoothAddress(const QString &address) +{ + QRegularExpression re("(LE:)*([0-9A-F]{2}:[0-9A-F]{2}:[0-9A-F]{2}:[0-9A-F]{2}:[0-9A-F]{2}:[0-9A-F]{2}|{[0-9A-F]{8}-[0-9A-F]{4}-[0-9A-F]{4}-[0-9A-F]{4}-[0-9A-F]{12}})", + QRegularExpression::CaseInsensitiveOption); + QRegularExpressionMatch m = re.match(address); + return m.hasMatch(); +} + void saveBtDeviceInfo(const QString &devaddr, QBluetoothDeviceInfo deviceInfo) { btDeviceInfo[devaddr] = deviceInfo; -- cgit v1.2.3-70-g09d2