summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--src/bluetooth/qlowenergycontroller_bluez.cpp4
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;
}