summaryrefslogtreecommitdiff
path: root/src/metawatch.h
diff options
context:
space:
mode:
Diffstat (limited to 'src/metawatch.h')
-rw-r--r--src/metawatch.h101
1 files changed, 101 insertions, 0 deletions
diff --git a/src/metawatch.h b/src/metawatch.h
new file mode 100644
index 0000000..dd02bf4
--- /dev/null
+++ b/src/metawatch.h
@@ -0,0 +1,101 @@
+#ifndef METAWATCH_H
+#define METAWATCH_H
+
+#include <QObject>
+#include <QBluetoothAddress>
+
+QT_USE_NAMESPACE_BLUETOOTH
+
+#include "metawatchtransport.h"
+#include "widgetinfo.h"
+
+class MetaWatch : public QObject
+{
+ Q_OBJECT
+ Q_ENUMS(MessageTypes WatchProperty UiStyle)
+ Q_FLAGS(WatchProperties)
+
+public:
+ explicit MetaWatch(const QString &btAddr, QObject *parent = 0);
+
+ enum MessageTypes {
+ MessageGetDeviceType = 0x01,
+ MessageGetDeviceTypeResponse = 0x02,
+
+ MessageSetRealTimeClock = 0x26,
+
+ MessageWatchPropertyOperation = 0x30,
+
+ MessageModeChangeIndication = 0x33,
+
+ MessageUpdateLcdDisplay = 0x43,
+
+ MessageGetBatteryStatus = 0x56,
+ MessageReadBatteryStatusResponse = 0x57,
+
+ MessageSetWidgetList = 0xA1,
+
+ MessageSetupAccelerometer = 0xE1,
+ MessageAccelerometerDataResponse = 0xE0,
+
+ // Messages from the propietary BT stack
+ MessageConnectionChange = 0xB9,
+ MessageIntervalChanged = 0xBB
+ };
+
+ enum DeviceType {
+ DeviceMetaWatchDigitalGen1 = 2,
+ DeviceMetaWatchDigitalGen2 = 5
+ };
+
+ enum WatchProperty {
+ WatchPropertyHourFormat12h = 0,
+ WatchPropertyHourFormat24h = 1,
+ WatchPropertyDateFormatMMDD = 0 << 1,
+ WatchPropertyDateFormatDDMM = 1 << 1,
+ WatchPropertyShowSeconds = 1 << 2,
+ WatchPropertyShowSeparationLines = 1 << 3,
+ WatchPropertyAutobacklight = 1 << 4,
+
+ WatchPropertyOperationRead = 0 << 7,
+ WatchPropertyOperationWrite = 1 << 7
+ };
+ Q_DECLARE_FLAGS(WatchProperties, WatchProperty)
+
+ enum UiStyle {
+ UiGen1 = 0,
+ UiGen2 = 1
+ };
+
+ static QList<QUrl> availableClocks();
+
+ void setDateTime(const QDateTime &dt);
+ void configure(WatchProperties props);
+
+ void updateDeviceType();
+ void updateBatteryStatus();
+ void updateLcdDisplay(); // TODO: More overloads
+ void updateWidgetList(const QList<WidgetInfo*>& widgets);
+
+signals:
+ void connected();
+ void disconnected();
+
+ void deviceType(DeviceType type);
+ void batteryStatus(bool charging, int charge);
+
+public slots:
+ void connectDevice();
+ void disconnectDevice();
+
+private:
+ static int clockUrlToClockId(const QUrl &url);
+
+private slots:
+ void handleTransportMessage(quint8 type, quint8 options, const QByteArray &payload);
+
+private:
+ MetaWatchTransport *_transport;
+};
+
+#endif // METAWATCH_H