summaryrefslogtreecommitdiff
path: root/daemon/watchconnector.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'daemon/watchconnector.cpp')
-rw-r--r--daemon/watchconnector.cpp106
1 files changed, 104 insertions, 2 deletions
diff --git a/daemon/watchconnector.cpp b/daemon/watchconnector.cpp
index 9993a38..1701972 100644
--- a/daemon/watchconnector.cpp
+++ b/daemon/watchconnector.cpp
@@ -53,6 +53,7 @@ QVariantMap WatchConnector::WatchVersions::toMap() const
map.insert("bootloader", this->bootLoaderBuild.toTime_t());
map.insert("serial", this->serialNumber);
map.insert("address", this->address.toHex());
+ map.insert("platform", this->hardwarePlatform);
map.insertMulti("firmware", this->main.toMap());
map.insertMulti("firmware", this->safe.toMap());
}
@@ -89,10 +90,14 @@ WatchConnector::WatchConnector(QObject *parent) :
hardwareMapping.insert(BIANCA, HWMap(APLITE, "v2_0"));
hardwareMapping.insert(SNOWY_EVT2, HWMap(BASALT, "snowy_evt2"));
hardwareMapping.insert(SNOWY_DVT, HWMap(BASALT, "snowy_dvt"));
+ hardwareMapping.insert(BOBBY_SMILES, HWMap(BASALT, "snowy_s3"));
+ hardwareMapping.insert(SPALDING_EVT, HWMap(CHALK, "spalding_evt"));
+ hardwareMapping.insert(SPALDING, HWMap(CHALK, "spalding"));
hardwareMapping.insert(TINTIN_BB, HWMap(APLITE, "bigboard"));
hardwareMapping.insert(TINTIN_BB2, HWMap(APLITE, "bb2"));
hardwareMapping.insert(SNOWY_BB, HWMap(BASALT, "snowy_bb"));
hardwareMapping.insert(SNOWY_BB2, HWMap(BASALT, "snowy_bb2"));
+ hardwareMapping.insert(SPALDING_BB2, HWMap(CHALK, "spalding_bb2"));
setEndpointHandler(watchVERSION, [this](const QByteArray &data) {
Unpacker u(data);
@@ -122,6 +127,18 @@ WatchConnector::WatchConnector(QObject *parent) :
platform = hardwareMapping.value(_versions.safe.hw_revision).first;
+ switch (this->platform) {
+ case APLITE:
+ _versions.hardwarePlatform = "aplite";
+ break;
+ case BASALT:
+ _versions.hardwarePlatform = "basalt";
+ break;
+ case CHALK:
+ _versions.hardwarePlatform = "chalk";
+ break;
+ }
+
if (u.bad()) {
qCWarning(l) << "short read while reading firmware version";
} else {
@@ -596,8 +613,93 @@ void WatchConnector::sendNotification(uint lead, QString sender, QString data, Q
sendMessage(watchNOTIFICATION, res);
}
break;
- case BASALT: {
- qCWarning(l) << "Tried sending notification to unsupported watch platform" << lead << sender << data << subject;
+ case BASALT:
+ case CHALK: {
+ int source;
+ switch (lead) {
+ case leadEMAIL:
+ source = 19;
+ break;
+ case leadFACEBOOK:
+ source = 11;
+ break;
+ case leadSMS:
+ source = 45;
+ break;
+ case leadTWITTER:
+ source = 6;
+ break;
+ default:
+ source = 1;
+ }
+
+ int attributesCount = 0;
+ QByteArray attributes;
+
+ attributesCount++;
+ QByteArray senderBytes = sender.left(64).toUtf8();
+ attributes.append(0x01); // id = title
+ attributes.append(senderBytes.length() & 0xFF); attributes.append(((senderBytes.length() >> 8) & 0xFF)); // length
+ attributes.append(senderBytes); // content
+
+ attributesCount++;
+ QByteArray subjectBytes = (subject.isEmpty() ? data : subject).left(64).toUtf8();
+ attributes.append(0x02); // id = subtitle
+ attributes.append(subjectBytes.length() & 0xFF); attributes.append((subjectBytes.length() >> 8) & 0xFF); // length
+ attributes.append(subjectBytes); //content
+
+ if (!data.isEmpty()) {
+ attributesCount++;
+ QByteArray dataBytes = data.left(512).toUtf8();
+ attributes.append(0x03); // id = body
+ attributes.append(dataBytes.length() & 0xFF); attributes.append((dataBytes.length() >> 8) & 0xFF); // length
+ attributes.append(dataBytes); // content
+ }
+
+ attributesCount++;
+ attributes.append(0x04); // id = tinyicon
+ attributes.append(0x04); attributes.append('\0'); // length
+ attributes.append(source); attributes.append('\0'); attributes.append('\0'); attributes.append('\0'); // content
+
+
+ QByteArray actions;
+ actions.append('\0'); // action id
+ actions.append(0x04); // type = dismiss
+ actions.append(0x01); // attributes length = 1
+ actions.append(0x01); // attribute id = title
+ actions.append(0x07); actions.append('\0'); // attribute length
+ actions.append("Dismiss"); // attribute content
+
+
+ QByteArray itemId = QUuid::createUuid().toRfc4122();
+ int time = QDateTime::currentMSecsSinceEpoch() / 1000;
+ QByteArray item;
+ item.append(itemId); // item id
+ item.append(QUuid().toRfc4122()); // parent id
+ item.append(time & 0xFF); item.append((time >> 8) & 0xFF); item.append((time >> 16) & 0xFF); item.append((time >> 24) & 0xFF); // timestamp
+ item.append('\0'); item.append('\0'); // duration
+ item.append(0x01); // type: notification
+ item.append('\0'); item.append('\0'); // flags
+ item.append(0x01); // layout
+
+ int length = attributes.length() + actions.length();
+ item.append(length & 0xFF); item.append((length >> 8) & 0xFF); // data length
+ item.append(attributesCount); // attributes count
+ item.append(0x01); // actions count
+ item.append(attributes);
+ item.append(actions);
+
+ int token = (qrand() % ((int)pow(2, 16) - 2)) + 1;
+ QByteArray blob;
+ blob.append(0x01); // command = insert
+ blob.append(token & 0xFF); blob.append((token >> 8) & 0xFF); // token
+ blob.append(0x04); //database id = notification
+ blob.append(itemId.length() & 0xFF); // key length
+ blob.append(itemId); // key
+ blob.append(item.length() & 0xFF); blob.append((item.length() >> 8) & 0xFF); // value length
+ blob.append(item);
+
+ sendMessage(watchBLOB_DB, blob);
}
break;
default: