summaryrefslogtreecommitdiff
path: root/sapbtlistener.cc
diff options
context:
space:
mode:
authorJavier <dev.git@javispedro.com>2014-11-16 16:40:06 +0100
committerJavier <dev.git@javispedro.com>2014-11-16 16:40:06 +0100
commit5244f7909e04b23fbd5706dc6bcadafba21f7600 (patch)
tree88d8730dc70b68586d2d31845dc51eead9e526cb /sapbtlistener.cc
parentd8d8fc7a0d139e7b864eee3b573bd208f823ad4f (diff)
downloadsapd-5244f7909e04b23fbd5706dc6bcadafba21f7600.tar.gz
sapd-5244f7909e04b23fbd5706dc6bcadafba21f7600.zip
initial notification support
Diffstat (limited to 'sapbtlistener.cc')
-rw-r--r--sapbtlistener.cc19
1 files changed, 14 insertions, 5 deletions
diff --git a/sapbtlistener.cc b/sapbtlistener.cc
index d5cd071..1b4550a 100644
--- a/sapbtlistener.cc
+++ b/sapbtlistener.cc
@@ -169,17 +169,18 @@ void SAPBTListener::nudge(const QBluetoothAddress &address)
{
QBluetoothSocket *socket = new QBluetoothSocket(QBluetoothSocket::RfcommSocket, this);
+ connect(socket, SIGNAL(connected()), socket, SLOT(deleteLater()));
+ connect(socket, SIGNAL(error(QBluetoothSocket::SocketError)),
+ this, SLOT(handleNudgeError(QBluetoothSocket::SocketError)));
+
qDebug() << "Nudging" << address.toString();
socket->connectToService(address, 2); //SAPProtocol::nudgeServiceUuid);
#if 1
- HfpAg *ag = new HfpAg(address, this);
- connect(socket, SIGNAL(disconnected()), ag, SLOT(deleteLater()));
+ // At the same time set up and HFP connection to the watch.
+ new HfpAg(address, this);
#endif
-
- connect(socket, SIGNAL(connected()), socket, SLOT(deleteLater()));
- connect(socket, SIGNAL(error(QBluetoothSocket::SocketError)), socket, SLOT(deleteLater()));
}
void SAPBTListener::acceptConnection()
@@ -196,3 +197,11 @@ void SAPBTListener::acceptConnection()
// TODO Why am I hardcoding the role here
new SAPBTPeer(SAProtocol::ClientRole, socket, this);
}
+
+void SAPBTListener::handleNudgeError(QBluetoothSocket::SocketError error)
+{
+ QBluetoothSocket *socket = static_cast<QBluetoothSocket*>(sender());
+ qWarning() << "Cannot nudge:" << error << socket->errorString();
+ socket->abort();
+ socket->deleteLater();
+}