Compare commits

...

1 Commits

Author SHA1 Message Date
Roberto Viola
6e3bd576c5 logging current status to file 2020-10-02 10:30:17 +02:00
3 changed files with 27 additions and 1 deletions

View File

@@ -1,5 +1,5 @@
QT -= gui
QT += bluetooth
QT += bluetooth xml
CONFIG += c++11 console
CONFIG -= app_bundle

View File

@@ -193,6 +193,30 @@ void virtualtreadmill::treadmillProvider()
= serviceHR->characteristic(QBluetoothUuid::HeartRateMeasurement);
Q_ASSERT(characteristicHR.isValid());
serviceHR->writeCharacteristic(characteristicHR, valueHR); // Potentially causes notification.
QFile* log;
QDomDocument docStatus;
QDomElement docRoot;
QDomElement docTreadmill;
QDomElement docHeart;
log = new QFile("status.xml");
if(!log->open(QIODevice::WriteOnly | QIODevice::Text))
{
qDebug() << "Open status.xml for writing failed";
}
docRoot = docStatus.createElement("Gym");
docStatus.appendChild(docRoot);
docTreadmill = docStatus.createElement("Treadmill");
docTreadmill.setAttribute("Speed", QString::number(currentSpeed));
docTreadmill.setAttribute("Incline", QString::number(currentIncline));
docRoot.appendChild(docTreadmill);
docHeart = docStatus.createElement("Heart");
docHeart.setAttribute("Rate", QString::number(currentHeart));
docRoot.appendChild(docHeart);
docRoot.setAttribute("Updated", QDateTime::currentDateTime().toString());
QTextStream stream(log);
stream << docStatus.toString();
log->close();
}
uint16_t virtualtreadmill::watts()

View File

@@ -22,6 +22,8 @@
#include <QtCore/qscopedpointer.h>
#include <QtCore/qtimer.h>
#include <QtXml>
class virtualtreadmill: QObject
{
Q_OBJECT