summaryrefslogtreecommitdiff
path: root/daemon/datalogmanager.cpp
blob: c3562efcf748f4e04f804799e2ca0224af653bfd (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
#include "datalogmanager.h"
#include "unpacker.h"

DataLogManager::DataLogManager(WatchConnector *watch, QObject *parent) :
    QObject(parent), l(metaObject()->className()), watch(watch)
{
    watch->setEndpointHandler(WatchConnector::watchDATA_LOGGING, [this](const QByteArray& data) {
        if (data.size() < 2) {
            qCWarning(l) << "small data_logging packet";
            return false;
        }

        const char command = data[0];
        const int session = data[1];

        switch (command) {
        case WatchConnector::datalogOPEN:
            qCDebug(l) << "open datalog session" << session;
            return true;
        case WatchConnector::datalogCLOSE:
            qCDebug(l) << "close datalog session" << session;
            return true;
        case WatchConnector::datalogTIMEOUT:
            qCDebug(l) << "timeout datalog session" << session;
            return true;
        case WatchConnector::datalogDATA:
            handleDataCommand(session, data.mid(2));
            return true;
        default:
            return false;
        }
    });
}

void DataLogManager::handleDataCommand(int session, const QByteArray &data)
{
    Unpacker u(data);

    // TODO Seemingly related to analytics, so not important.

    qCDebug(l) << "got datalog data" << session << data.size();
}