diff options
author | Javier S. Pedro <maemo@javispedro.com> | 2012-04-26 01:36:20 +0200 |
---|---|---|
committer | Javier S. Pedro <maemo@javispedro.com> | 2012-04-26 01:36:20 +0200 |
commit | 93f3acd128d6b349efe14e97b12c2703ca4f81f3 (patch) | |
tree | 937f3de2307444f0c28d6d21f26f1580e789b074 /metawatch/metawatchscanner.cpp | |
parent | 1375a26b135547fdd8e07db62acf8116a8482560 (diff) | |
download | sowatch-93f3acd128d6b349efe14e97b12c2703ca4f81f3.tar.gz sowatch-93f3acd128d6b349efe14e97b12c2703ca4f81f3.zip |
Moved the core framework to GConf & D-Bus
Diffstat (limited to 'metawatch/metawatchscanner.cpp')
-rw-r--r-- | metawatch/metawatchscanner.cpp | 48 |
1 files changed, 48 insertions, 0 deletions
diff --git a/metawatch/metawatchscanner.cpp b/metawatch/metawatchscanner.cpp new file mode 100644 index 0000000..418500c --- /dev/null +++ b/metawatch/metawatchscanner.cpp @@ -0,0 +1,48 @@ +#include <QtConnectivity/QBluetoothDeviceInfo> +#include <QtConnectivity/QBluetoothAddress> + +#include "metawatchscanner.h" + +QTM_USE_NAMESPACE +using namespace sowatch; + +MetaWatchScanner::MetaWatchScanner(QObject *parent) : + WatchScanner(parent), + _agent(new QBluetoothServiceDiscoveryAgent(this)) +{ + _agent->setUuidFilter(QBluetoothUuid::SerialPort); + connect(_agent, SIGNAL(finished()), this, SIGNAL(finished())); + connect(_agent, SIGNAL(serviceDiscovered(QBluetoothServiceInfo)), + this, SLOT(handleDiscoveredService(QBluetoothServiceInfo))); +} + +void MetaWatchScanner::start() +{ + if (_agent->isActive()) { + _agent->stop(); + } + _agent->start(); + qDebug() << "started metawatch bluetooth scan"; + emit started(); +} + +void MetaWatchScanner::handleDiscoveredService(const QBluetoothServiceInfo &info) +{ + const QBluetoothDeviceInfo dev = info.device(); + QString deviceName = dev.name(); + if (deviceName.contains("MetaWatch", Qt::CaseInsensitive)) { + QVariantMap foundInfo; + foundInfo["address"] = dev.address().toString(); + foundInfo["name"] = deviceName; + qDebug() << "metawatch bluetooth scan found" << deviceName; + if (deviceName.contains("Digital", Qt::CaseInsensitive)) { + foundInfo["driver"] = QString("metawatch-digital"); + emit watchFound(foundInfo); + } else if (deviceName.contains("Analog", Qt::CaseInsensitive)) { + foundInfo["driver"] = QString("metawatch-analog"); + emit watchFound(foundInfo); + } else { + qWarning() << "Unknown MetaWatch device found:" << deviceName; + } + } +} |