summaryrefslogtreecommitdiff
path: root/daemon/watchconnector.cpp
diff options
context:
space:
mode:
authorTomasz Sterna <tomek@xiaoka.com>2014-10-29 09:28:40 +0100
committerTomasz Sterna <tomek@xiaoka.com>2014-10-29 09:28:40 +0100
commitecba425f8c029e103211446e9f250927a832315f (patch)
tree0c4b6d36be78569733dbba6ceb16f1fabca9a2c4 /daemon/watchconnector.cpp
parent31a206e93e2266f3dcc0e1c2c43ab92e5ae7bd9c (diff)
parentb5ecd0a0778ad8e1d0de49b4f49271b458acefda (diff)
Merge pull request #25 from smurfy/fix_update9
Fix for Sailfish update9 and QT5.2 Fixes #23 Closes #24
Diffstat (limited to 'daemon/watchconnector.cpp')
-rw-r--r--daemon/watchconnector.cpp15
1 files changed, 14 insertions, 1 deletions
diff --git a/daemon/watchconnector.cpp b/daemon/watchconnector.cpp
index 91c5217..a240b04 100644
--- a/daemon/watchconnector.cpp
+++ b/daemon/watchconnector.cpp
@@ -66,8 +66,11 @@ void WatchConnector::handleWatch(const QString &name, const QString &address)
if (emit_name) emit nameChanged();
logger()->debug() << "Creating socket";
+#if QT_VERSION < QT_VERSION_CHECK(5, 2, 0)
socket = new QBluetoothSocket(QBluetoothSocket::RfcommSocket);
-
+#else
+ socket = new QBluetoothSocket(QBluetoothServiceInfo::RfcommProtocol);
+#endif
connect(socket, SIGNAL(readyRead()), SLOT(onReadSocket()));
connect(socket, SIGNAL(bytesWritten(qint64)), SLOT(onBytesWritten(qint64)));
connect(socket, SIGNAL(connected()), SLOT(onConnected()));
@@ -87,6 +90,16 @@ QString WatchConnector::decodeEndpoint(uint val)
void WatchConnector::decodeMsg(QByteArray data)
{
+ //Sometimes pebble sends a "00", we ignore it without future action
+ if (data.length() == 1 && data.at(0) == 0) {
+ return;
+ }
+
+ if (data.length() < 4) {
+ logger()->error() << "Can not decode message data length invalid: " << data.toHex();
+ return;
+ }
+
unsigned int datalen = 0;
int index = 0;
datalen = (data.at(index) << 8) + data.at(index+1);