diff options
author | Christian Waßmuth <c.wassmuth@oculus.de> | 2015-03-10 15:49:33 +0100 |
---|---|---|
committer | Alex Blasche <alexander.blasche@theqtcompany.com> | 2015-03-17 08:20:24 +0000 |
commit | 935975a268279671a34084e306b44901d266c419 (patch) | |
tree | b19da5de3ccd690ce694086e4cabbfd05f32c733 /src | |
parent | fbb7acbc7f59fd79cbe6e59aef21be6d7c6cf5ca (diff) |
QLowEnergyController_bluez now responds to server requests.
The bluez implementation of QLowEnergyController now responds to
requests with a "Request not supported" message, instead of ignoring it.
If such requests are ignored, the remote will close the connection after
30 seconds, according to the bluetooth ATT specification.
Task-number: QTBUG-44915
Change-Id: Id81b4a31d92a48269eda7d6c2d5995639dffe00a
Reviewed-by: Alex Blasche <alexander.blasche@theqtcompany.com>
Diffstat (limited to 'src')
-rw-r--r-- | src/bluetooth/qlowenergycontroller_bluez.cpp | 16 |
1 files changed, 14 insertions, 2 deletions
diff --git a/src/bluetooth/qlowenergycontroller_bluez.cpp b/src/bluetooth/qlowenergycontroller_bluez.cpp index f22cea71..f061dba8 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 @@ -352,9 +353,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; |