From 5244f7909e04b23fbd5706dc6bcadafba21f7600 Mon Sep 17 00:00:00 2001 From: Javier Date: Sun, 16 Nov 2014 16:40:06 +0100 Subject: initial notification support --- sapbtlistener.cc | 19 ++++++++++++++----- 1 file changed, 14 insertions(+), 5 deletions(-) (limited to 'sapbtlistener.cc') 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(sender()); + qWarning() << "Cannot nudge:" << error << socket->errorString(); + socket->abort(); + socket->deleteLater(); +} -- cgit v1.2.3