diff --git a/daemon/src/devices/banglejsdevice.cpp b/daemon/src/devices/banglejsdevice.cpp index 36dea5ed..9533fb6c 100644 --- a/daemon/src/devices/banglejsdevice.cpp +++ b/daemon/src/devices/banglejsdevice.cpp @@ -175,6 +175,25 @@ void BangleJSDevice::initialise() } setConnectionState("authenticated"); + + setTime(); +} + +void BangleJSDevice::setTime() { + UARTService *uart = qobject_cast(service(UARTService::UUID_SERVICE_UART)); + if (!uart){ + return; + } + + qint64 ts; + +#if QT_VERSION >= QT_VERSION_CHECK(5, 8, 0) + ts = QDateTime::currentSecsSinceEpoch(); +#else + ts = QDateTime::currentDateTime().toTime_t(); +#endif + QString time_str("setTime(" + QString::number(ts) + ");\n"); + uart->tx(time_str.toUtf8()); } void BangleJSDevice::onPropertiesChanged(QString interface, QVariantMap map, QStringList list) diff --git a/daemon/src/devices/banglejsdevice.h b/daemon/src/devices/banglejsdevice.h index c2c2b512..37e06ec7 100644 --- a/daemon/src/devices/banglejsdevice.h +++ b/daemon/src/devices/banglejsdevice.h @@ -37,6 +37,8 @@ class BangleJSDevice : public AbstractDevice //Weather void sendWeather(CurrentWeather *weather) override; + void setTime(); + protected: virtual void onPropertiesChanged(QString interface, QVariantMap map, QStringList list);