Hi Jerome,

Thanks for your advice, I seperated charateristics reading with service 
discovery and Error1:"no attribute in ..." is disappeared.


However, the QLowEnergyController is still disconnected several seconds after 
service discovery is finished, still there is error of "Connection timed out" 
or "Connection reset by peer". I wonder is this BLE feature and is it normal? 
as when I use "BLE analyser" on android phone to read BLE devices, there are 
all automatically disconnected in several seconds after connection is 
estabilished.



B.R.
Jie





At 2018-10-30 21:10:34, "Jérôme Godbout" <godbo...@amotus.ca> wrote:


Hi,

 

You should find and resolve the first error, any error could lead to 
disconnection:

qt.bluetooth.bluez: Error1: "no attribute in given range found" last command: 
10 handle: 1
m_controller discoveryFinished



Also make sure you finish the discovery before you start doing any other 
services/characteristics discovery with BlueZ.

 

Side note: In the case of the Bluez (especially the Android one), give it some 
delay between your request and avoid sending multiple request at the same time. 
After you connect put a sleep delay of a few hundred ms and always request a 
single services and characteristic at a time.

 

The stack is so buggy it’s the only way to make it work properly and reliably. 
Don’t base your “it work” with BlueZ on a single test run, the results change a 
lot with the device load and BLE usage by other application. iOS and OS X on 
the other hand seem t work just fine, they do not need the artificial delay, so 
it’s a delay festival with ifdef.

 

Jerome

 

From: Interest <interest-bounces+godboutj=amotus...@qt-project.org> On Behalf 
Of nus1998
Sent: October 30, 2018 4:42 AM
To:interest@qt-project.org
Subject: [Interest] QLowEnergyController always disconnected after service 
discovery finished

 

Hi,

When I use QLowEnergyController to scan the service, it's always disconnected 
about 15 seconds after services discovery is finished. the error is not 
certain, sometimes it's "Connection reset by peer", sometimes it's "Connection 
timeout".

 

The log is attached, can anyone have a look at it and give me some advice? 
thanks in advance.

 

qt.bluetooth.bluez: Bluez 5 detected.
qt.bluetooth.bluez: Creating QtBluezDiscoveryManager
m_discoveryAgent is active
qt.bluetooth.bluez: BluetoothManagement: Ignored event: 13
qt.bluetooth.bluez: Discovered:  "00:07:80:2E:9B:85" "BLE Module" Num UUIDs 0 
total device 0 cached RSSI -94 Class 0
"00:07:80:2E:9B:85" "00:07:80:2E:9B:85" "BLE Module" QFlags(0x1)
qt.bluetooth.bluez: void QBluetoothDeviceDiscoveryAgentPrivate::stop()
found lead MkIII
qt.bluetooth.bluez: Enabling GATT request timeout behavior 20000
qt.bluetooth.bluez: addresstypeToUse: "Public"
qt.bluetooth.bluez: No settings found for peer device.
qt.bluetooth.bluez: BluetoothManagement: Ignored event: 13
qt.bluetooth.bluez: HCI event triggered, type: f
qt.bluetooth.bluez: HCI event triggered, type: 3e
qt.bluetooth.bluez: received connection complete event, handle: 1025
qt.bluetooth.bluez: BluetoothManagement: Ignored event: b
qt.bluetooth.bluez: Current l2cp sec level: 1
qt.bluetooth.bluez: Exchanging MTU
m_controller connected
qt.bluetooth.bluez: Sending read_by_group_type request, startHandle: 1 
endHandle: ffff 2800
qt.bluetooth.bluez: Received size: 3 data: "031700"
qt.bluetooth.bluez: Server MTU: 23 resulting mtu: 23
qt.bluetooth.bluez: HCI event triggered, type: 13
qt.bluetooth.bluez: Received size: 8 data: "1106010005000018"
qt.bluetooth.bluez: Found uuid: "{00001800-0000-1000-8000-00805f9b34fb}" start 
handle: 1 end handle: 5
service discovered
qt.bluetooth.bluez: Sending read_by_group_type request, startHandle: 6 
endHandle: ffff 2800
qt.bluetooth.bluez: HCI event triggered, type: 13
qt.bluetooth.bluez: HCI event triggered, type: 13
qt.bluetooth.bluez: Received size: 22 data: 
"111406001200e34bc643730f1e930e7fe83ae1b11fab"
qt.bluetooth.bluez: Found uuid: "{ab1fb1e1-3ae8-7f0e-931e-0f7343c64be3}" start 
handle: 6 end handle: 12
service discovered
qt.bluetooth.bluez: Sending read_by_group_type request, startHandle: 13 
endHandle: ffff 2800
qt.bluetooth.bluez: Received size: 14 data: "1106130017000a1818001a000518"
qt.bluetooth.bluez: Found uuid: "{0000180a-0000-1000-8000-00805f9b34fb}" start 
handle: 13 end handle: 17
service discovered
qt.bluetooth.bluez: Found uuid: "{00001805-0000-1000-8000-00805f9b34fb}" start 
handle: 18 end handle: 1a
service discovered
qt.bluetooth.bluez: Sending read_by_group_type request, startHandle: 1b 
endHandle: ffff 2800
qt.bluetooth.bluez: HCI event triggered, type: 13
qt.bluetooth.bluez: Received size: 22 data: 
"11141b002d00e8b84b71b98489ab01fb06bec3bad7af"
qt.bluetooth.bluez: Found uuid: "{afd7bac3-be06-fb01-ab89-84b9714bb8e8}" start 
handle: 1b end handle: 2d
service discovered
qt.bluetooth.bluez: Sending read_by_group_type request, startHandle: 2e 
endHandle: ffff 2800
qt.bluetooth.bluez: HCI event triggered, type: 13
qt.bluetooth.bluez: HCI event triggered, type: 13
qt.bluetooth.bluez: Received size: 22 data: 
"11142e0044000adea862315e215dbab961a5b3dc493c"
qt.bluetooth.bluez: Found uuid: "{3c49dcb3-a561-b9ba-5d21-5e3162a8de0a}" start 
handle: 2e end handle: 44
service discovered
qt.bluetooth.bluez: Sending read_by_group_type request, startHandle: 45 
endHandle: ffff 2800
qt.bluetooth.bluez: Received size: 22 data: 
"11144500fffffac79ce402ae50e53c3c6b32ffba88f7"
qt.bluetooth.bluez: Found uuid: "{f788baff-326b-3c3c-e550-ae02e49cc7fa}" start 
handle: 45 end handle: ffff
service discovered
qt.bluetooth.bluez: Sending read_by_group_type request, startHandle: 1 
endHandle: ffff 2801
qt.bluetooth.bluez: HCI event triggered, type: 13
qt.bluetooth.bluez: Received size: 5 data: "011001000a"
qt.bluetooth.bluez: Error1: "no attribute in given range found" last command: 
10 handle: 1
m_controller discoveryFinished
qt.bluetooth.bluez: HCI event triggered, type: 13
qt.bluetooth.bluez: HCI event triggered, type: 5
qt.bluetooth.bluez: void QBluetoothSocketPrivate::_q_readNotify() 19 error: -1 
"Connection reset by peer"
m_controller disconnected
qt.bluetooth.bluez: BluetoothManagement: Ignored event: c



B.R.

Jie

 

 
_______________________________________________
Interest mailing list
Interest@qt-project.org
http://lists.qt-project.org/mailman/listinfo/interest

Reply via email to