mirror of
https://github.com/subsurface/subsurface.git
synced 2025-01-31 23:23:23 +00:00
core: helper function to recognize BT/BLE addresses
Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
This commit is contained in:
parent
4263d1c3f5
commit
0cfd76740b
2 changed files with 10 additions and 0 deletions
|
@ -6,6 +6,7 @@
|
||||||
#include <QTimer>
|
#include <QTimer>
|
||||||
#include <QDebug>
|
#include <QDebug>
|
||||||
#include <QLoggingCategory>
|
#include <QLoggingCategory>
|
||||||
|
#include <QRegularExpression>
|
||||||
|
|
||||||
extern QMap<QString, dc_descriptor_t *> descriptorLookup;
|
extern QMap<QString, dc_descriptor_t *> descriptorLookup;
|
||||||
|
|
||||||
|
@ -301,6 +302,14 @@ bool BTDiscovery::checkException(const char* method, const QAndroidJniObject *ob
|
||||||
|
|
||||||
QHash<QString, QBluetoothDeviceInfo> btDeviceInfo;
|
QHash<QString, QBluetoothDeviceInfo> 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)
|
void saveBtDeviceInfo(const QString &devaddr, QBluetoothDeviceInfo deviceInfo)
|
||||||
{
|
{
|
||||||
btDeviceInfo[devaddr] = deviceInfo;
|
btDeviceInfo[devaddr] = deviceInfo;
|
||||||
|
|
|
@ -17,6 +17,7 @@
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
void saveBtDeviceInfo(const QString &devaddr, QBluetoothDeviceInfo deviceInfo);
|
void saveBtDeviceInfo(const QString &devaddr, QBluetoothDeviceInfo deviceInfo);
|
||||||
|
bool isBluetoothAddress(const QString &address);
|
||||||
QBluetoothDeviceInfo getBtDeviceInfo(const QString &devaddr);
|
QBluetoothDeviceInfo getBtDeviceInfo(const QString &devaddr);
|
||||||
|
|
||||||
class BTDiscovery : public QObject {
|
class BTDiscovery : public QObject {
|
||||||
|
|
Loading…
Add table
Reference in a new issue