Skip to content

Commit

Permalink
Fixes #421: setTime upon connection to bangle.js
Browse files Browse the repository at this point in the history
  • Loading branch information
jmlich committed Nov 3, 2024
1 parent 2963f7c commit 0930f84
Show file tree
Hide file tree
Showing 2 changed files with 21 additions and 0 deletions.
19 changes: 19 additions & 0 deletions daemon/src/devices/banglejsdevice.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -175,6 +175,25 @@ void BangleJSDevice::initialise()
}

setConnectionState("authenticated");

setTime();
}

void BangleJSDevice::setTime() {
UARTService *uart = qobject_cast<UARTService*>(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)
Expand Down
2 changes: 2 additions & 0 deletions daemon/src/devices/banglejsdevice.h
Original file line number Diff line number Diff line change
Expand Up @@ -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);

Expand Down

0 comments on commit 0930f84

Please sign in to comment.