Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fixes #421: setTime upon connection to bangle.js #424

Merged
merged 1 commit into from
Nov 5, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
18 changes: 18 additions & 0 deletions daemon/src/devices/banglejsdevice.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -175,6 +175,24 @@ 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
uart->tx(QByteArray(1, 0x10) + QString("setTime(" + QString::number(ts) + ");\n").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
Loading