diff options
Diffstat (limited to 'lib')
| -rw-r--r-- | lib/watchconnector.cpp | 13 | ||||
| -rw-r--r-- | lib/watchconnector.h | 1 |
2 files changed, 10 insertions, 4 deletions
diff --git a/lib/watchconnector.cpp b/lib/watchconnector.cpp index 15fd97f..1bfce0d 100644 --- a/lib/watchconnector.cpp +++ b/lib/watchconnector.cpp @@ -40,7 +40,7 @@ void WatchConnector::reconnect() void WatchConnector::handleWatch(const QString &name, const QString &address) { - qDebug() << "handleWatch" << name << (socket != nullptr); + qDebug() << "handleWatch" << name << address; if (socket != nullptr && socket->isOpen()) { socket->close(); socket->deleteLater(); @@ -54,12 +54,13 @@ void WatchConnector::handleWatch(const QString &name, const QString &address) qDebug() << "Creating socket"; socket = new QBluetoothSocket(QBluetoothSocket::RfcommSocket); - // FIXME: Assuming port 1 (with Pebble) - socket->connectToService(QBluetoothAddress(address), 1); - connect(socket, SIGNAL(readyRead()), SLOT(onReadSocket())); connect(socket, SIGNAL(connected()), SLOT(onConnected())); connect(socket, SIGNAL(disconnected()), SLOT(onDisconnected())); + connect(socket, SIGNAL(error(QBluetoothSocket::SocketError)), this, SLOT(onError(QBluetoothSocket::SocketError))); + + // FIXME: Assuming port 1 (with Pebble) + socket->connectToService(QBluetoothAddress(address), 1); } QString WatchConnector::decodeEndpoint(unsigned int val) @@ -171,6 +172,10 @@ void WatchConnector::onDisconnected() QTimer::singleShot(__reconnect_timeout, this, SLOT(reconnect())); } +void WatchConnector::onError(QBluetoothSocket::SocketError error) { + qWarning() << "Error connecting Pebble" << error << socket->errorString(); +} + void WatchConnector::sendData(const QByteArray &data) { if (socket == nullptr) return; diff --git a/lib/watchconnector.h b/lib/watchconnector.h index bf404e6..493856b 100644 --- a/lib/watchconnector.h +++ b/lib/watchconnector.h @@ -116,6 +116,7 @@ public slots: void onReadSocket(); void onConnected(); void onDisconnected(); + void onError(QBluetoothSocket::SocketError error); void reconnect(); private: |
