summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--app/pebbledinterface.cpp5
-rw-r--r--app/pebbledinterface.h1
-rw-r--r--app/qml/pages/WatchPage.qml7
-rw-r--r--daemon/dbusadaptor.cpp7
-rw-r--r--daemon/dbusadaptor.h2
-rw-r--r--daemon/manager.h1
-rw-r--r--daemon/org.pebbled.xml1
-rw-r--r--daemon/watchconnector.cpp17
-rw-r--r--daemon/watchconnector.h1
9 files changed, 42 insertions, 0 deletions
diff --git a/app/pebbledinterface.cpp b/app/pebbledinterface.cpp
index 50ece6e..a46cf45 100644
--- a/app/pebbledinterface.cpp
+++ b/app/pebbledinterface.cpp
@@ -149,6 +149,11 @@ void PebbledInterface::ping()
pebbled->call("ping", 66);
}
+void PebbledInterface::time()
+{
+ pebbled->call("time");
+}
+
void PebbledInterface::disconnect()
{
pebbled->call("disconnect");
diff --git a/app/pebbledinterface.h b/app/pebbledinterface.h
index df9cd3d..cf87425 100644
--- a/app/pebbledinterface.h
+++ b/app/pebbledinterface.h
@@ -49,6 +49,7 @@ public slots:
void setEnabled(bool);
void setActive(bool);
void ping();
+ void time();
void disconnect();
void reconnect();
diff --git a/app/qml/pages/WatchPage.qml b/app/qml/pages/WatchPage.qml
index efb12a0..68502bd 100644
--- a/app/qml/pages/WatchPage.qml
+++ b/app/qml/pages/WatchPage.qml
@@ -56,6 +56,13 @@ Page {
pebbled.ping(66)
}
}
+
+ Button {
+ text: "Sync Time"
+ onClicked: {
+ pebbled.time()
+ }
+ }
}
}
}
diff --git a/daemon/dbusadaptor.cpp b/daemon/dbusadaptor.cpp
index 6125ee7..3332551 100644
--- a/daemon/dbusadaptor.cpp
+++ b/daemon/dbusadaptor.cpp
@@ -69,6 +69,13 @@ void PebbledAdaptor::ping(int val)
QMetaObject::invokeMethod(parent(), "ping", Q_ARG(int, val));
}
+void PebbledAdaptor::time()
+{
+ // handle method call org.pebbled.time
+ QMetaObject::invokeMethod(parent(), "time");
+}
+
+
void PebbledAdaptor::reconnect()
{
// handle method call org.pebbled.reconnect
diff --git a/daemon/dbusadaptor.h b/daemon/dbusadaptor.h
index 7613fba..715a41b 100644
--- a/daemon/dbusadaptor.h
+++ b/daemon/dbusadaptor.h
@@ -43,6 +43,7 @@ class PebbledAdaptor: public QDBusAbstractAdaptor
" <method name=\"ping\">\n"
" <arg direction=\"in\" type=\"i\" name=\"val\"/>\n"
" </method>\n"
+" <method name=\"time\"/>\n"
" <method name=\"disconnect\"/>\n"
" <method name=\"reconnect\"/>\n"
" </interface>\n"
@@ -67,6 +68,7 @@ public: // PROPERTIES
public Q_SLOTS: // METHODS
void disconnect();
void ping(int val);
+ void time();
void reconnect();
Q_SIGNALS: // SIGNALS
void connectedChanged();
diff --git a/daemon/manager.h b/daemon/manager.h
index 89b8e2b..26a0fd8 100644
--- a/daemon/manager.h
+++ b/daemon/manager.h
@@ -102,6 +102,7 @@ public:
public slots:
void ping(int val) { static_cast<Manager*>(parent())->watch->ping((unsigned int)val); }
+ void time() { static_cast<Manager*>(parent())->watch->time(); }
void disconnect() { static_cast<Manager*>(parent())->watch->disconnect(); }
void reconnect() { static_cast<Manager*>(parent())->watch->reconnect(); }
diff --git a/daemon/org.pebbled.xml b/daemon/org.pebbled.xml
index 0a958c8..e255782 100644
--- a/daemon/org.pebbled.xml
+++ b/daemon/org.pebbled.xml
@@ -13,6 +13,7 @@
<method name="ping">
<arg name="val" type="i" direction="in"/>
</method>
+ <method name="time"/>
<method name="disconnect"/>
<method name="reconnect"/>
</interface>
diff --git a/daemon/watchconnector.cpp b/daemon/watchconnector.cpp
index 1bdec8d..70b8e6f 100644
--- a/daemon/watchconnector.cpp
+++ b/daemon/watchconnector.cpp
@@ -242,6 +242,23 @@ void WatchConnector::ping(uint val)
sendMessage(watchPING, res);
}
+void WatchConnector::time()
+{
+ QByteArray res;
+ QDateTime UTC(QDateTime::currentDateTimeUtc());
+ QDateTime local(UTC.toLocalTime());
+ local.setTimeSpec(Qt::UTC);
+ int offset = UTC.secsTo(local);
+ uint val = (local.toMSecsSinceEpoch() + offset) / 1000;
+
+ res.append(0x02); //SET_TIME_REQ
+ res.append((char)((val >> 24) & 0xff));
+ res.append((char)((val >> 16) & 0xff));
+ res.append((char)((val >> 8) & 0xff));
+ res.append((char)(val & 0xff));
+ sendMessage(watchTIME, res);
+}
+
QString WatchConnector::timeStamp()
{
return QString::number(QDateTime::currentMSecsSinceEpoch());
diff --git a/daemon/watchconnector.h b/daemon/watchconnector.h
index 936deff..cdaf059 100644
--- a/daemon/watchconnector.h
+++ b/daemon/watchconnector.h
@@ -145,6 +145,7 @@ public slots:
void sendData(const QByteArray &data);
void sendMessage(uint endpoint, QByteArray data);
void ping(uint val);
+ void time();
void sendNotification(uint lead, QString sender, QString data, QString subject);
void sendSMSNotification(QString sender, QString data);
void sendEmailNotification(QString sender, QString data, QString subject);