summaryrefslogtreecommitdiff
path: root/src/metawatchbttransport.h
diff options
context:
space:
mode:
authorJavier S. Pedro <dev.git@javispedro.com>2014-09-20 19:18:00 +0200
committerJavier S. Pedro <dev.git@javispedro.com>2014-09-20 19:18:00 +0200
commitcc1af30276d3650dd71589cd1d7c005da3a64873 (patch)
tree6e6ab2a2e1d4c8f8567d7785e34dfe5b043b2ebd /src/metawatchbttransport.h
parentbca10d6ab21bf0e49253fc01e313a4618b7fcae7 (diff)
downloadsalmeta-cc1af30276d3650dd71589cd1d7c005da3a64873.tar.gz
salmeta-cc1af30276d3650dd71589cd1d7c005da3a64873.zip
add normal/rfcomm bluetooth transport for older MWs
Diffstat (limited to 'src/metawatchbttransport.h')
-rw-r--r--src/metawatchbttransport.h38
1 files changed, 38 insertions, 0 deletions
diff --git a/src/metawatchbttransport.h b/src/metawatchbttransport.h
new file mode 100644
index 0000000..a27328a
--- /dev/null
+++ b/src/metawatchbttransport.h
@@ -0,0 +1,38 @@
+#ifndef METAWATCHBTTRANSPORT_H
+#define METAWATCHBTTRANSPORT_H
+
+#include <QtBluetooth/QBluetoothSocket>
+
+QT_USE_NAMESPACE_BLUETOOTH
+
+#include "metawatchtransport.h"
+
+class MetaWatchBTTransport : public MetaWatchTransport
+{
+ Q_OBJECT
+public:
+ explicit MetaWatchBTTransport(const QBluetoothAddress &address, QObject *parent = 0);
+ ~MetaWatchBTTransport();
+
+ bool isDeviceConnected() const;
+ void sendMessage(quint8 type, quint8 options, const QByteArray &payload);
+
+public slots:
+ void connectDevice();
+ void disconnectDevice();
+
+private:
+ static QByteArray encode(quint8 type, quint8 options, const QByteArray &payload);
+ static bool decode(const QByteArray &msg, quint8 *type, quint8 *options, QByteArray *payload);
+
+private slots:
+ void handleSocketConnected();
+ void handleSocketDisconnected();
+ void handleSocketData();
+
+private:
+ QBluetoothAddress _addr;
+ QBluetoothSocket *_socket;
+};
+
+#endif // METAWATCHBTTRANSPORT_H