summaryrefslogtreecommitdiffstats
path: root/src/bluetooth/qlowenergycontroller_bluez.cpp
diff options
context:
space:
mode:
authorAlex Blasche <alexander.blasche@theqtcompany.com>2015-04-01 08:33:21 +0200
committerAlex Blasche <alexander.blasche@theqtcompany.com>2015-04-01 08:36:34 +0200
commit4ed0678f93d7fc6a9d0d43dfdfe6608e827eb176 (patch)
tree3faa743c8a7a84e9f97408acd625c4ed797e6f81 /src/bluetooth/qlowenergycontroller_bluez.cpp
parentec82c463d3f83454130dccfa71988af13768c5eb (diff)
parentb4bf23453e65995bdd8827b6e146edd5cafeddc3 (diff)
Merge branch '5.4' into 5.5
Diffstat (limited to 'src/bluetooth/qlowenergycontroller_bluez.cpp')
-rw-r--r--src/bluetooth/qlowenergycontroller_bluez.cpp20
1 files changed, 17 insertions, 3 deletions
diff --git a/src/bluetooth/qlowenergycontroller_bluez.cpp b/src/bluetooth/qlowenergycontroller_bluez.cpp
index 2d4fa7be..d355b070 100644
--- a/src/bluetooth/qlowenergycontroller_bluez.cpp
+++ b/src/bluetooth/qlowenergycontroller_bluez.cpp
@@ -79,6 +79,7 @@
#define ATT_OP_WRITE_COMMAND 0x52 //write characteristic without response
//GATT command sizes in bytes
+#define ERROR_RESPONSE_HEADER_SIZE 5
#define FIND_INFO_REQUEST_HEADER_SIZE 5
#define GRP_TYPE_REQ_HEADER_SIZE 7
#define READ_BY_TYPE_REQ_HEADER_SIZE 7
@@ -358,9 +359,20 @@ void QLowEnergyControllerPrivate::l2cpReadyRead()
case ATT_OP_READ_REQUEST:
case ATT_OP_FIND_INFORMATION_REQUEST:
case ATT_OP_WRITE_REQUEST:
- qCWarning(QT_BT_BLUEZ) << "Unexpected message type" << hex << command
- << "will be ignored" ;
+ {
+ qCDebug(QT_BT_BLUEZ) << "Server request" << hex << command;
+
+ //send not supported
+ QByteArray packet(ERROR_RESPONSE_HEADER_SIZE, Qt::Uninitialized);
+ packet[0] = ATT_OP_ERROR_RESPONSE;
+ packet[1] = command;
+ bt_put_unaligned(htobs(0), (quint16 *)(packet.data() + 2));
+ packet[4] = ATT_ERROR_REQUEST_NOT_SUPPORTED;
+
+ sendCommand(packet);
+
return;
+ }
default:
//only solicited replies finish pending requests
requestPending = false;
@@ -386,10 +398,12 @@ void QLowEnergyControllerPrivate::l2cpReadyRead()
void QLowEnergyControllerPrivate::encryptionChangedEvent(
const QBluetoothAddress &address, bool wasSuccess)
{
+ if (!encryptionChangePending) // somebody else caused change event
+ return;
+
if (remoteDevice != address)
return;
- Q_ASSERT(encryptionChangePending);
securityLevelValue = securityLevel();
// On success continue to process ATT command queue