diff options
| author | Andrew Branson <andrew.branson@cern.ch> | 2016-02-11 23:55:16 +0100 |
|---|---|---|
| committer | Andrew Branson <andrew.branson@cern.ch> | 2016-02-11 23:55:16 +0100 |
| commit | 29aaea2d80a9eb1715b6cddfac2d2aacf76358bd (patch) | |
| tree | 012795b6bec16c72f38d33cff46324c9a0225868 /rockworkd/libpebble/dataloggingendpoint.cpp | |
launchpad ~mzanetti/rockwork/trunk r87
Diffstat (limited to 'rockworkd/libpebble/dataloggingendpoint.cpp')
| -rw-r--r-- | rockworkd/libpebble/dataloggingendpoint.cpp | 44 |
1 files changed, 44 insertions, 0 deletions
diff --git a/rockworkd/libpebble/dataloggingendpoint.cpp b/rockworkd/libpebble/dataloggingendpoint.cpp new file mode 100644 index 0000000..a571c25 --- /dev/null +++ b/rockworkd/libpebble/dataloggingendpoint.cpp @@ -0,0 +1,44 @@ +#include "dataloggingendpoint.h" + +#include "pebble.h" +#include "watchconnection.h" +#include "watchdatareader.h" +#include "watchdatawriter.h" + +DataLoggingEndpoint::DataLoggingEndpoint(Pebble *pebble, WatchConnection *connection): + QObject(pebble), + m_pebble(pebble), + m_connection(connection) +{ + m_connection->registerEndpointHandler(WatchConnection::EndpointDataLogging, this, "handleMessage"); +} + +void DataLoggingEndpoint::handleMessage(const QByteArray &data) +{ + qDebug() << "data logged" << data.toHex(); + WatchDataReader reader(data); + DataLoggingCommand command = (DataLoggingCommand)reader.read<quint8>(); + switch (command) { + case DataLoggingDespoolSendData: { + quint8 sessionId = reader.read<quint8>(); + quint32 itemsLeft = reader.readLE<quint32>(); + quint32 crc = reader.readLE<quint32>(); + qDebug() << "Despooling data: Session:" << sessionId << "Items left:" << itemsLeft << "CRC:" << crc; + + QByteArray reply; + WatchDataWriter writer(&reply); + writer.write<quint8>(DataLoggingACK); + writer.write<quint8>(sessionId); + m_connection->writeToPebble(WatchConnection::EndpointDataLogging, reply); + return; + } + case DataLoggingTimeout: { + quint8 sessionId = reader.read<quint8>(); + qDebug() << "DataLogging reached timeout: Session:" << sessionId; + return; + } + default: + qDebug() << "Unhandled DataLogging message"; + } +} + |
