summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--daemon/watchconnector.cpp7
-rw-r--r--daemon/watchconnector.h1
2 files changed, 8 insertions, 0 deletions
diff --git a/daemon/watchconnector.cpp b/daemon/watchconnector.cpp
index a4bfb64..04e9ceb 100644
--- a/daemon/watchconnector.cpp
+++ b/daemon/watchconnector.cpp
@@ -68,6 +68,9 @@ WatchConnector::WatchConnector(QObject *parent) :
{
reconnectTimer.setSingleShot(true);
connect(&reconnectTimer, SIGNAL(timeout()), SLOT(reconnect()));
+ timeSyncTimer.setSingleShot(true);
+ connect(&timeSyncTimer, SIGNAL(timeout()), SLOT(time()));
+ timeSyncTimer.setInterval(14400000);
firmwareMapping.insert(UNKNOWN, "unknown");
firmwareMapping.insert(PEBBLE_ONE_EV1, "ev1");
@@ -151,6 +154,7 @@ void WatchConnector::disconnect()
socket->close();
socket->deleteLater();
reconnectTimer.stop();
+ timeSyncTimer.stop();
qCDebug(l) << "stopped reconnect timer";
}
@@ -312,6 +316,7 @@ void WatchConnector::onConnected()
sendMessage(watchVERSION, QByteArray(1, 0));
emit connectedChanged();
if (name() != _last_name) emit nameChanged();
+ time();
}
}
@@ -476,6 +481,7 @@ void WatchConnector::ping(uint cookie)
void WatchConnector::time()
{
+ timeSyncTimer.stop();
QByteArray res;
QDateTime UTC(QDateTime::currentDateTimeUtc());
QDateTime local(UTC.toLocalTime());
@@ -489,6 +495,7 @@ void WatchConnector::time()
res.append((char)((val >> 8) & 0xff));
res.append((char)(val & 0xff));
sendMessage(watchTIME, res);
+ timeSyncTimer.start();
}
QString WatchConnector::timeStamp()
diff --git a/daemon/watchconnector.h b/daemon/watchconnector.h
index 4e6ed5d..f9576a3 100644
--- a/daemon/watchconnector.h
+++ b/daemon/watchconnector.h
@@ -261,6 +261,7 @@ private:
bool is_connected;
QByteArray writeData;
QTimer reconnectTimer;
+ QTimer timeSyncTimer;
QString _last_name;
QString _last_address;
WatchVersions _versions;