summaryrefslogtreecommitdiff
path: root/src/metawatch.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'src/metawatch.cpp')
-rw-r--r--src/metawatch.cpp22
1 files changed, 19 insertions, 3 deletions
diff --git a/src/metawatch.cpp b/src/metawatch.cpp
index ff05aca..41b32aa 100644
--- a/src/metawatch.cpp
+++ b/src/metawatch.cpp
@@ -5,19 +5,35 @@
#include <QtGui/QImage>
#include "metawatch.h"
+#include "metawatchbttransport.h"
#include "metawatchbletransport.h"
-MetaWatch::MetaWatch(const QString &btAddr, QObject *parent) :
+MetaWatch::MetaWatch(const QString &btAddr, TransportType transport, QObject *parent) :
QObject(parent)
{
- GatoPeripheral *peripheral = new GatoPeripheral(GatoAddress(btAddr), this);
- _transport = new MetaWatchBLETransport(peripheral, this);
+ switch (transport) {
+ case TransportBluetooth:
+ _transport = new MetaWatchBTTransport(QBluetoothAddress(btAddr), this);
+ break;
+ case TransportBluetoothLowEnergy:
+ _transport = new MetaWatchBLETransport(GatoAddress(btAddr), this);
+ break;
+ }
connect(_transport, &MetaWatchTransport::connected, this, &MetaWatch::connected);
connect(_transport, &MetaWatchTransport::disconnected, this, &MetaWatch::disconnected);
connect(_transport, &MetaWatchTransport::messageReceived, this, &MetaWatch::handleTransportMessage);
}
+MetaWatch::~MetaWatch()
+{
+}
+
+bool MetaWatch::isDeviceConnected() const
+{
+ return _transport && _transport->isDeviceConnected();
+}
+
void MetaWatch::setVibrateMode(bool enable, int on_duration, int off_duration, int cycles)
{
QByteArray data;