diff options
author | Alex Blasche <alexander.blasche@digia.com> | 2014-10-28 13:41:10 +0100 |
---|---|---|
committer | Alex Blasche <alexander.blasche@digia.com> | 2014-10-29 15:22:34 +0100 |
commit | 6d23cf4afac858aeeba3e94c4074fc50633b2b4b (patch) | |
tree | 819844107a1178ab36849a4eb685741c1481a155 | |
parent | 0b42f1e6f6be36a23584dfe41acaf414023f747a (diff) |
If btle connect attempt fails return QLEController back to Unconnected
What is really needed is a new ConnectionError for this case. This new
error will shortly be introduced to the btle/5.5 branch.
Change-Id: I751fa0eeb5cf4d0b78863842c94770f4e8e74015
Reviewed-by: Timur Pocheptsov <Timur.Pocheptsov@digia.com>
Reviewed-by: Alex Blasche <alexander.blasche@digia.com>
-rw-r--r-- | src/bluetooth/qlowenergycontroller_bluez.cpp | 4 |
1 files changed, 3 insertions, 1 deletions
diff --git a/src/bluetooth/qlowenergycontroller_bluez.cpp b/src/bluetooth/qlowenergycontroller_bluez.cpp index f217f0a2..4f8021e2 100644 --- a/src/bluetooth/qlowenergycontroller_bluez.cpp +++ b/src/bluetooth/qlowenergycontroller_bluez.cpp @@ -229,11 +229,11 @@ void QLowEnergyControllerPrivate::connectToDevice() else if (addressType == QLowEnergyController::RandomAddress) l2cpSocket->d_ptr->lowEnergySocketType = BDADDR_LE_RANDOM; - // bind the socket to the local device int sockfd = l2cpSocket->socketDescriptor(); if (sockfd < 0) { qCWarning(QT_BT_BLUEZ) << "l2cp socket not initialised"; setError(QLowEnergyController::UnknownError); + setState(QLowEnergyController::UnconnectedState); return; } @@ -244,9 +244,11 @@ void QLowEnergyControllerPrivate::connectToDevice() addr.l2_bdaddr_type = BDADDR_LE_PUBLIC; convertAddress(localAdapter.toUInt64(), addr.l2_bdaddr.b); + // bind the socket to the local device if (::bind(sockfd, (struct sockaddr *)&addr, sizeof(addr)) < 0) { qCWarning(QT_BT_BLUEZ) << qt_error_string(errno); setError(QLowEnergyController::UnknownError); + setState(QLowEnergyController::UnconnectedState); return; } |