summaryrefslogtreecommitdiff
path: root/src/metawatchbletransport.h
diff options
context:
space:
mode:
Diffstat (limited to 'src/metawatchbletransport.h')
-rw-r--r--src/metawatchbletransport.h46
1 files changed, 46 insertions, 0 deletions
diff --git a/src/metawatchbletransport.h b/src/metawatchbletransport.h
new file mode 100644
index 0000000..973c4a8
--- /dev/null
+++ b/src/metawatchbletransport.h
@@ -0,0 +1,46 @@
+#ifndef METAWATCHBLETRANSPORT_H
+#define METAWATCHBLETRANSPORT_H
+
+#include <QtCore/QObject>
+
+#include <gato/gatoperipheral.h>
+#include <gato/gatouuid.h>
+#include <gato/gatoservice.h>
+#include <gato/gatocharacteristic.h>
+
+#include "metawatchtransport.h"
+
+class MetaWatchBLETransport : public MetaWatchTransport
+{
+ Q_OBJECT
+public:
+ explicit MetaWatchBLETransport(GatoPeripheral *peripheral, QObject *parent = 0);
+ ~MetaWatchBLETransport();
+
+ static const GatoUUID ServiceUuid;
+ static const GatoUUID InputCharacteristicUuid;
+ static const GatoUUID OutputCharacteristicUuid;
+
+ 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 handleDeviceConnected();
+ void handleDeviceDisconnected();
+ void handleDeviceServices();
+ void handleDeviceCharacteristics(const GatoService &service);
+ void handleDeviceUpdate(const GatoCharacteristic &characteristic, const QByteArray &value);
+
+private:
+ GatoPeripheral *_dev;
+ GatoCharacteristic _in, _out;
+};
+
+#endif // METAWATCHBLETRANSPORT_H