summaryrefslogtreecommitdiff
path: root/metawatch/metawatchscanner.cpp
blob: 3742092911f4748dda05192a05049419cab62c47 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
#include <QtConnectivity/QBluetoothDeviceInfo>
#include <QtConnectivity/QBluetoothAddress>

#include "metawatchscanner.h"

QTM_USE_NAMESPACE
using namespace sowatch;

MetaWatchScanner::MetaWatchScanner(QObject *parent) :
	BluetoothWatchScanner(parent)
{
	setUuidFilter(QBluetoothUuid::SerialPort);
}

void MetaWatchScanner::handleDiscoveredService(const QBluetoothServiceInfo &info)
{
	const QBluetoothDeviceInfo dev = info.device();
	QString deviceName = dev.name();
	if (deviceName.startsWith("MetaWatch")) {
		QVariantMap foundInfo;
		foundInfo["address"] = dev.address().toString();
		foundInfo["name"] = deviceName;
		qDebug() << "metawatch bluetooth scan found:" << deviceName;
		if (deviceName.contains("Analog")) {
			// This is Analog metawatch.
			foundInfo["driver"] = QString("metawatch-analog");
			foundInfo["next-watchlet-button"] = QString("A");
			emit watchFound(foundInfo);
		} else {
			// For now, assume Digital metawatch.
			foundInfo["driver"] = QString("metawatch-digital");
			foundInfo["next-watchlet-button"] = QString("A");
			foundInfo["idle-watchlet"] = QString("com.javispedro.sowatch.metawatch.watchface");
			foundInfo["notification-watchlet"] = QString("com.javispedro.sowatch.metawatch.notification");
			emit watchFound(foundInfo);
		}
	}
}