Forum: PC-Programmierung Nordic UART (NUS) client


von Hans W. (Firma: Wilhelm.Consulting) (hans-)


Lesenswert?

Hi!

Ich versuche per Bluetooth über den Nordic UART Service zu 
kommunizieren.
Mit dem Android-Tool am Handy geht das problemlos (also an der Hardware 
liegt's nicht).

Ich habe am PC in Qt etwas gebastelt das auch connected.
Nach ein paar Sekunden scheint aber BlueZ den Service einfach zu 
killen...

Ich habe mich (nachdem es ja so gut wie überhaupt keine Doku, Libs oder 
sonst irgendwas dazu zu geben scheint) an den code gehalten: 
https://github.com/subsurface/subsurface/blob/master/core/qt-ble.cpp

Wie gesagt, aus meiner Sicht sind meine Debugausgaben und die von der 
Nrf-Toolbox vergleichbar... nur bleibt die verbunden und meine 
Implementierung tut irgendwie nicht...

Hat da irgendjemand eine Idee?

Ach ja, Bluetooth an sich läuft am PC zuverlässig

73
1
qt.bluetooth.bluez: Updating RSSI for "32:E6:9E:5E:ED:2E" QVariant(short, -88)
2
qt.bluetooth.bluez: Updating RSSI for "E3:40:CC:F6:1B:4C" QVariant(short, -61)
3
qt.bluetooth.bluez: Updating RSSI for "32:E6:9E:5E:ED:2E" QVariant(short, -85)
4
Device Discovery finished... now trying to connect...
5
qt.bluetooth.bluez: Detecting bluetoothd version
6
qt.bluetooth.bluez: Using /proc/<pid>/exe
7
qt.bluetooth.bluez: Using /proc/<pid>/cmdline
8
qt.bluetooth.bluez: Detected bluetoothd version 5.56
9
qt.bluetooth.bluez: Bluetoothd: "5.56"
10
qt.bluetooth: Using BlueZ LE DBus API
11
qt.bluetooth.bluez: QLowEnergyControllerPrivateBluezDBus::connectToDevice()
12
qt.bluetooth.bluez: ###### "org.bluez.Device1" QMap(("Connected", QVariant(bool, true)))
13
qt.bluetooth.bluez: ###### "org.bluez.Device1" QMap(("ServicesResolved", QVariant(bool, true))("UUIDs", QVariant(QStringList, ("00001800-0000-1000-8000-00805f9b34fb", "00001801-0000-1000-8000-00805f9b34fb", "6e400001-b5a3-f393-e0a9-e50e24dcca9e"))))
14
deviceConnected
15
deviceServiceDiscoveryFinished
16
Services: ("{00001801-0000-1000-8000-00805f9b34fb}", "{6e400001-b5a3-f393-e0a9-e50e24dcca9e}")
17
Service State: QLowEnergyService::DiscoveringServices
18
qt.bluetooth.bluez: Read Desc: "\x00\x00"
19
Service State: QLowEnergyService::ServiceDiscovered
20
Characteristic: "{6e400002-b5a3-f393-e0a9-e50e24dcca9e}"
21
Characteristic: "{6e400003-b5a3-f393-e0a9-e50e24dcca9e}"
22
writing 0100 to descriptor: "{00002902-0000-1000-8000-00805f9b34fb}"
23
qt.bluetooth.bluez: Init CCC change to "0100" "{6e400003-b5a3-f393-e0a9-e50e24dcca9e}" "{6e400001-b5a3-f393-e0a9-e50e24dcca9e}"
24
qt.bluetooth.bluez: Write Desc: "{00002902-0000-1000-8000-00805f9b34fb}" "0100"
25
serviceDescriptorWritten  "{00002902-0000-1000-8000-00805f9b34fb}"
26
"0100"
27
qt.bluetooth.bluez: ###### "org.bluez.Device1" QMap(("Connected", QVariant(bool, false))("ServicesResolved", QVariant(bool, false)))
28
Service State: QLowEnergyService::InvalidService
29
deviceDisconnected
30
qt.bluetooth: Using BlueZ LE DBus API
31
qt.bluetooth.bluez: QLowEnergyControllerPrivateBluezDBus::connectToDevice()
32
qt.bluetooth.bluez: ###### "org.bluez.Device1" QMap(("Connected", QVariant(bool, true)))
33
qt.bluetooth.bluez: ###### "org.bluez.Device1" QMap(("ServicesResolved", QVariant(bool, true)))
34
deviceConnected
35
deviceServiceDiscoveryFinished
36
Services: ("{00001801-0000-1000-8000-00805f9b34fb}", "{6e400001-b5a3-f393-e0a9-e50e24dcca9e}")
37
Service State: QLowEnergyService::DiscoveringServices
38
qt.bluetooth.bluez: Read Desc: "\x01\x00"
39
Service State: QLowEnergyService::ServiceDiscovered
40
Characteristic: "{6e400002-b5a3-f393-e0a9-e50e24dcca9e}"
41
Characteristic: "{6e400003-b5a3-f393-e0a9-e50e24dcca9e}"
42
writing 0100 to descriptor: "{00002902-0000-1000-8000-00805f9b34fb}"
43
qt.bluetooth.bluez: Init CCC change to "0100" "{6e400003-b5a3-f393-e0a9-e50e24dcca9e}" "{6e400001-b5a3-f393-e0a9-e50e24dcca9e}"
44
qt.bluetooth.bluez: Write Desc: "{00002902-0000-1000-8000-00805f9b34fb}" "0100"
45
serviceDescriptorWritten  "{00002902-0000-1000-8000-00805f9b34fb}"
46
"0100"
47
qt.bluetooth.bluez: ###### "org.bluez.Device1" QMap(("Connected", QVariant(bool, false))("ServicesResolved", QVariant(bool, false)))
48
Service State: QLowEnergyService::InvalidService
49
deviceDisconnected

von Hans W. (Firma: Wilhelm.Consulting) (hans-)


Lesenswert?

Ok, da scheinen die kursierenden Kommentare zur Stabilität der Bluetooth 
Stacks zu stimmen.

Wenn man nach dem Discovery der Devices und Services ausreichend Zeit 
vergehen lässt, und dann connected, dann läuft's!

Echt cool.
Da hat man schöne callbacks für alle notwendigen State-Wechsel und muss 
dennoch dann irgendwie Verzögerungen einbauen da in Wahrheit nicht alles 
fertig ist, obwohl das entsprechende Event gefeuert wurde...

Die Zeiten scheinen übrigens vom Remote und vom Local Stack 
abzuhängen...
BlueZ am Android ist etwas anders als BlueZ unter Linux; Verbindungen zu 
iOS sind anscheinend auch nicht immer stabil wenn man nicht an ein paar 
Rädchen schraubt...

Faszinierend, dass da trotz der Bluetooth SIG und deren 
Qualitätsprogramm noch immer solche Verrücktheiten existieren...
73

Bitte melde dich an um einen Beitrag zu schreiben. Anmeldung ist kostenlos und dauert nur eine Minute.
Bestehender Account
Schon ein Account bei Google/GoogleMail? Keine Anmeldung erforderlich!
Mit Google-Account einloggen
Noch kein Account? Hier anmelden.