I'm trying to connect a mobile phone with a raspi Stretch over Bluetooth with BlueZ library (HashtagChris on github) with c#. The thing is, I can pair smoothly, no problem, but when I try to connect, it is marked as connected but phone seems to immediately ask disconnection (this is what I understood from btmon logs). Scanning works perfectly.
root@raspberrypi:/app# btmon
Bluetooth monitor ver 5.50
= Note: Linux version 4.19.66-v7+ (armv7l) 0.807788
= Note: Bluetooth subsystem version 2.22 0.807801
= New Index: B8:27:EB:0D:C1:8F (Primary,UART,hci0) [hci0] 0.807806
= Open Index: B8:27:EB:0D:C1:8F [hci0] 0.807809
= Index Info: B8:27:EB:0D:C1:8F (Broadcom Corporation) [hci0] 0.807812
@ MGMT Open: bluetoothd (privileged) version 1.14 {0x0001} 0.807816
@ MGMT Open: btmon (privileged) version 1.14 {0x0002} 0.808401
> HCI Event: Connect Request (0x04) plen 10 #1 [hci0] 8.307280
Address: EC:8C:9A:89:9A:08 (OUI EC-8C-9A)
Class: 0x5a020c
Major class: Phone (cellular, cordless, payphone, modem)
Minor class: Smart phone
Networking (LAN, Ad hoc)
Capturing (Scanner, Microphone)
Object Transfer (v-Inbox, v-Folder)
Telephony (Cordless telephony, Modem, Headset)
Link type: ACL (0x01)
< HCI Command: Accept Connection Request (0x01|0x0009) plen 7 #2 [hci0] 8.307389
Address: EC:8C:9A:89:9A:08 (OUI EC-8C-9A)
Role: Master (0x00)
> HCI Event: Command Status (0x0f) plen 4 #3 [hci0] 8.307914
Accept Connection Request (0x01|0x0009) ncmd 1
Status: Success (0x00)
> HCI Event: Role Change (0x12) plen 8 #4 [hci0] 8.466426
Status: Success (0x00)
Address: EC:8C:9A:89:9A:08 (OUI EC-8C-9A)
Role: Master (0x00)
> HCI Event: Connect Complete (0x03) plen 11 #5 [hci0] 8.502669
Status: Success (0x00)
Handle: 11
Address: EC:8C:9A:89:9A:08 (OUI EC-8C-9A)
Link type: ACL (0x01)
Encryption: Disabled (0x00)
< HCI Command: Read Remote Supported Features (0x01|0x001b) plen 2 #6 [hci0] 8.503022
Handle: 11
> HCI Event: Command Status (0x0f) plen 4 #7 [hci0] 8.503572
Read Remote Supported Features (0x01|0x001b) ncmd 1
Status: Success (0x00)
> HCI Event: Read Remote Supported Features (0x0b) plen 11 #8 [hci0] 8.503724
Status: Success (0x00)
Handle: 11
Features: 0xbf 0x3e 0x8d 0xfe 0xdb 0xff 0x5b 0x87
3 slot packets
5 slot packets
Encryption
Slot offset
Timing accuracy
Role switch
Sniff mode
Power control requests
Channel quality driven data rate (CQDDR)
SCO link
HV2 packets
HV3 packets
CVSD synchronous data
Power control
Transparent synchronous data
Broadcast Encryption
Enhanced Data Rate ACL 2 Mbps mode
Enhanced Data Rate ACL 3 Mbps mode
Enhanced inquiry scan
Interlaced inquiry scan
Interlaced page scan
RSSI with inquiry results
Extended SCO link (EV3 packets)
EV4 packets
EV5 packets
AFH capable slave
AFH classification slave
LE Supported (Controller)
3-slot Enhanced Data Rate ACL packets
5-slot Enhanced Data Rate ACL packets
Sniff subrating
Pause encryption
AFH capable master
AFH classification master
Enhanced Data Rate eSCO 2 Mbps mode
Enhanced Data Rate eSCO 3 Mbps mode
3-slot Enhanced Data Rate eSCO packets
Extended Inquiry Response
Simultaneous LE and BR/EDR (Controller)
Secure Simple Pairing
Encapsulated PDU
Non-flushable Packet Boundary Flag
Link Supervision Timeout Changed Event
Inquiry TX Power Level
Enhanced Power Control
Extended features
< HCI Command: Read Remote Extended Features (0x01|0x001c) plen 3 #9 [hci0] 8.503829
Handle: 11
Page: 1
> HCI Event: Command Status (0x0f) plen 4 #10 [hci0] 8.504283
Read Remote Extended Features (0x01|0x001c) ncmd 1
Status: Success (0x00)
> HCI Event: Read Remote Extended Features (0x23) plen 13 #11 [hci0] 8.504523
Status: Success (0x00)
Handle: 11
Page: 1/1
Features: 0x07 0x00 0x00 0x00 0x00 0x00 0x00 0x00
Secure Simple Pairing (Host Support)
LE Supported (Host)
Simultaneous LE and BR/EDR (Host)
< HCI Command: Remote Name Request (0x01|0x0019) plen 10 #12 [hci0] 8.504631
Address: EC:8C:9A:89:9A:08 (OUI EC-8C-9A)
Page scan repetition mode: R2 (0x02)
Page scan mode: Mandatory (0x00)
Clock offset: 0x0000
< ACL Data TX: Handle 11 flags 0x00 dlen 10 #13 [hci0] 8.504658
L2CAP: Information Request (0x0a) ident 1 len 2
Type: Extended features supported (0x0002)
> HCI Event: Command Status (0x0f) plen 4 #14 [hci0] 8.505248
Remote Name Request (0x01|0x0019) ncmd 1
Status: Success (0x00)
> HCI Event: Max Slots Change (0x1b) plen 3 #15 [hci0] 8.509028
Handle: 11
Max slots: 5
> ACL Data RX: Handle 11 flags 0x02 dlen 10 #16 [hci0] 8.532649
L2CAP: Information Request (0x0a) ident 2 len 2
Type: Extended features supported (0x0002)
< ACL Data TX: Handle 11 flags 0x00 dlen 16 #17 [hci0] 8.532730
L2CAP: Information Response (0x0b) ident 2 len 8
Type: Extended features supported (0x0002)
Result: Success (0x0000)
Features: 0x000002b8
Enhanced Retransmission Mode
Streaming Mode
FCS Option
Fixed Channels
Unicast Connectionless Data Reception
> HCI Event: Remote Name Req Complete (0x07) plen 255 #18 [hci0] 8.535110
Status: Success (0x00)
Address: EC:8C:9A:89:9A:08 (OUI EC-8C-9A)
Name: HUAWEI Y5 2018
@ MGMT Event: Device Connected (0x000b) plen 34 {0x0002} [hci0] 8.535184
BR/EDR Address: EC:8C:9A:89:9A:08 (OUI EC-8C-9A)
Flags: 0x00000000
Data length: 21
Name (complete): HUAWEI Y5 2018
Class: 0x5a020c
Major class: Phone (cellular, cordless, payphone, modem)
Minor class: Smart phone
Networking (LAN, Ad hoc)
Capturing (Scanner, Microphone)
Object Transfer (v-Inbox, v-Folder)
Telephony (Cordless telephony, Modem, Headset)
@ MGMT Event: Device Connected (0x000b) plen 34 {0x0001} [hci0] 8.535184
BR/EDR Address: EC:8C:9A:89:9A:08 (OUI EC-8C-9A)
Flags: 0x00000000
Data length: 21
Name (complete): HUAWEI Y5 2018
Class: 0x5a020c
Major class: Phone (cellular, cordless, payphone, modem)
Minor class: Smart phone
Networking (LAN, Ad hoc)
Capturing (Scanner, Microphone)
Object Transfer (v-Inbox, v-Folder)
Telephony (Cordless telephony, Modem, Headset)
> ACL Data RX: Handle 11 flags 0x02 dlen 16 #19 [hci0] 8.535253
L2CAP: Information Response (0x0b) ident 1 len 8
Type: Extended features supported (0x0002)
Result: Success (0x0000)
Features: 0x000000b8
Enhanced Retransmission Mode
Streaming Mode
FCS Option
Fixed Channels
< ACL Data TX: Handle 11 flags 0x00 dlen 10 #20 [hci0] 8.535319
L2CAP: Information Request (0x0a) ident 2 len 2
Type: Fixed channels supported (0x0003)
> HCI Event: Number of Completed Packets (0x13) plen 5 #21 [hci0] 8.535348
Num handles: 1
Handle: 11
Count: 2
> HCI Event: Link Key Request (0x17) plen 6 #22 [hci0] 8.555279
Address: EC:8C:9A:89:9A:08 (OUI EC-8C-9A)
< HCI Command: Link Key Request Reply (0x01|0x000b) plen 22 #23 [hci0] 8.555362
Address: EC:8C:9A:89:9A:08 (OUI EC-8C-9A)
Link key: bfc51cdfca37d8a7db87f1600b48151b
> ACL Data RX: Handle 11 flags 0x02 dlen 10 #24 [hci0] 8.557694
L2CAP: Information Request (0x0a) ident 3 len 2
Type: Fixed channels supported (0x0003)
> HCI Event: Command Complete (0x0e) plen 10 #25 [hci0] 8.557720
Link Key Request Reply (0x01|0x000b) ncmd 1
Status: Success (0x00)
Address: EC:8C:9A:89:9A:08 (OUI EC-8C-9A)
< ACL Data TX: Handle 11 flags 0x00 dlen 20 #26 [hci0] 8.557859
L2CAP: Information Response (0x0b) ident 3 len 12
Type: Fixed channels supported (0x0003)
Result: Success (0x0000)
Channels: 0x0000000000000086
L2CAP Signaling (BR/EDR)
Connectionless reception
Security Manager (BR/EDR)
> ACL Data RX: Handle 11 flags 0x02 dlen 20 #27 [hci0] 8.558999
L2CAP: Information Response (0x0b) ident 2 len 12
Type: Fixed channels supported (0x0003)
Result: Success (0x0000)
Channels: 0x0000000000000082
L2CAP Signaling (BR/EDR)
Security Manager (BR/EDR)
> HCI Event: Number of Completed Packets (0x13) plen 5 #28 [hci0] 8.561531
Num handles: 1
Handle: 11
Count: 2
> HCI Event: Encryption Change (0x08) plen 4 #29 [hci0] 8.592289
Status: Success (0x00)
Handle: 11
Encryption: Enabled with E0 (0x01)
< HCI Command: Read Encryption Key Size (0x05|0x0008) plen 2 #30 [hci0] 8.592374
Handle: 11
> HCI Event: Command Complete (0x0e) plen 7 #31 [hci0] 8.592882
Read Encryption Key Size (0x05|0x0008) ncmd 1
Status: Success (0x00)
Handle: 11
Key size: 16
> ACL Data RX: Handle 11 flags 0x02 dlen 12 #32 [hci0] 8.610146
L2CAP: Connection Request (0x02) ident 4 len 4
PSM: 3 (0x0003)
Source CID: 67
< ACL Data TX: Handle 11 flags 0x00 dlen 16 #33 [hci0] 8.610288
L2CAP: Connection Response (0x03) ident 4 len 8
Destination CID: 64
Source CID: 67
Result: Connection successful (0x0000)
Status: No further information available (0x0000)
< ACL Data TX: Handle 11 flags 0x00 dlen 27 #34 [hci0] 8.610311
L2CAP: Configure Request (0x04) ident 3 len 19
Destination CID: 67
Flags: 0x0000
Option: Maximum Transmission Unit (0x01) [mandatory]
MTU: 1013
Option: Retransmission and Flow Control (0x04) [mandatory]
Mode: Basic (0x00)
TX window size: 0
Max transmit: 0
Retransmission timeout: 0
Monitor timeout: 0
Maximum PDU size: 0
> ACL Data RX: Handle 11 flags 0x02 dlen 16 #35 [hci0] 8.614047
L2CAP: Configure Request (0x04) ident 5 len 8
Destination CID: 64
Flags: 0x0000
Option: Maximum Transmission Unit (0x01) [mandatory]
MTU: 1691
< ACL Data TX: Handle 11 flags 0x00 dlen 18 #36 [hci0] 8.614151
L2CAP: Configure Response (0x05) ident 5 len 10
Source CID: 67
Flags: 0x0000
Result: Success (0x0000)
Option: Maximum Transmission Unit (0x01) [mandatory]
MTU: 1691
> HCI Event: Number of Completed Packets (0x13) plen 5 #37 [hci0] 8.614192
Num handles: 1
Handle: 11
Count: 2
> ACL Data RX: Handle 11 flags 0x02 dlen 14 #38 [hci0] 8.615164
L2CAP: Configure Response (0x05) ident 3 len 6
Source CID: 64
Flags: 0x0000
Result: Success (0x0000)
> ACL Data RX: Handle 11 flags 0x02 dlen 8 #39 [hci0] 8.663890
Channel: 64 len 4 [PSM 3 mode 0] {chan 0}
RFCOMM: Set Async Balance Mode (SABM) (0x2f)
Address: 0x03 cr 1 dlci 0x00
Control: 0x3f poll/final 1
Length: 0
FCS: 0x1c
< ACL Data TX: Handle 11 flags 0x00 dlen 8 #40 [hci0] 8.664053
Channel: 67 len 4 [PSM 3 mode 0] {chan 0}
RFCOMM: Unnumbered Ack (UA) (0x63)
Address: 0x03 cr 1 dlci 0x00
Control: 0x73 poll/final 1
Length: 0
FCS: 0xd7
> HCI Event: Number of Completed Packets (0x13) plen 5 #41 [hci0] 8.666513
Num handles: 1
Handle: 11
Count: 2
> ACL Data RX: Handle 11 flags 0x02 dlen 18 #42 [hci0] 8.667692
Channel: 64 len 14 [PSM 3 mode 0] {chan 0}
RFCOMM: Unnumbered Info with Header Check (UIH) (0xef)
Address: 0x03 cr 1 dlci 0x00
Control: 0xef poll/final 0
Length: 10
FCS: 0x70
MCC Message type: DLC Parameter Negotiation CMD (0x20)
Length: 8
dlci 2 frame_type 0 credit_flow 15 pri 0
ack_timer 0 frame_size 990 max_retrans 0 credits 7
< ACL Data TX: Handle 11 flags 0x00 dlen 8 #43 [hci0] 8.667826
Channel: 67 len 4 [PSM 3 mode 0] {chan 0}
RFCOMM: Disconnect Mode (DM) (0x0f)
Address: 0x0b cr 1 dlci 0x02
Control: 0x1f poll/final 1
Length: 0
FCS: 0x73
> HCI Event: Number of Completed Packets (0x13) plen 5 #44 [hci0] 8.802513
Num handles: 1
Handle: 11
Count: 1
> ACL Data RX: Handle 11 flags 0x02 dlen 8 #45 [hci0] 10.682652
Channel: 64 len 4 [PSM 3 mode 0] {chan 0}
RFCOMM: Disconnect (DISC) (0x43)
Address: 0x03 cr 1 dlci 0x00
Control: 0x53 poll/final 1
Length: 0
FCS: 0xfd
< ACL Data TX: Handle 11 flags 0x00 dlen 8 #46 [hci0] 10.682828
Channel: 67 len 4 [PSM 3 mode 0] {chan 0}
RFCOMM: Unnumbered Ack (UA) (0x63)
Address: 0x03 cr 1 dlci 0x00
Control: 0x73 poll/final 1
Length: 0
FCS: 0xd7
< ACL Data TX: Handle 11 flags 0x00 dlen 12 #47 [hci0] 10.682855
L2CAP: Disconnection Request (0x06) ident 4 len 4
Destination CID: 67
Source CID: 64
> HCI Event: Number of Completed Packets (0x13) plen 5 #48 [hci0] 10.687781
Num handles: 1
Handle: 11
Count: 2
> ACL Data RX: Handle 11 flags 0x02 dlen 12 #49 [hci0] 10.688941
L2CAP: Disconnection Request (0x06) ident 6 len 4
Destination CID: 64
Source CID: 67
< ACL Data TX: Handle 11 flags 0x00 dlen 12 #50 [hci0] 10.689055
L2CAP: Disconnection Response (0x07) ident 6 len 4
Destination CID: 64
Source CID: 67
> ACL Data RX: Handle 11 flags 0x02 dlen 12 #51 [hci0] 10.706419
L2CAP: Disconnection Response (0x07) ident 4 len 4
Destination CID: 67
Source CID: 64
> HCI Event: Number of Completed Packets (0x13) plen 5 #52 [hci0] 10.927518
Num handles: 1
Handle: 11
Count: 1
< HCI Command: Disconnect (0x01|0x0006) plen 3 #53 [hci0] 14.697967
Handle: 11
Reason: Remote User Terminated Connection (0x13)
> HCI Event: Command Status (0x0f) plen 4 #54 [hci0] 14.698624
Disconnect (0x01|0x0006) ncmd 1
Status: Success (0x00)
> HCI Event: Disconnect Complete (0x05) plen 4 #55 [hci0] 14.778933
Status: Success (0x00)
Handle: 11
Reason: Connection Terminated By Local Host (0x16)
@ MGMT Event: Device Disconnected (0x000c) plen 8 {0x0002} [hci0] 14.779002
BR/EDR Address: EC:8C:9A:89:9A:08 (OUI EC-8C-9A)
Reason: Connection terminated by local host (0x02)
@ MGMT Event: Device Disconnected (0x000c) plen 8 {0x0001} [hci0] 14.779002
BR/EDR Address: EC:8C:9A:89:9A:08 (OUI EC-8C-9A)
Reason: Connection terminated by local host (0x02)
And this if content of /etc/systemd/system/dbus-org.bluez.service
[Unit]
Description=Bluetooth service
Documentation=man:bluetoothd(8)
ConditionPathIsDirectory=/sys/class/bluetooth
[Service]
Type=dbus
BusName=org.bluez
ExecStart=/usr/lib/bluetooth/bluetoothd -C -d
ExecStartPost=/usr/bin/sdptool add SP
ExecStartPost=/bin/hciconfig hci0 up
ExecStartPost=/bin/hciconfig hci0 piscan
ExecStartPost=/bin/hciconfig hci0 sspmode 1
NotifyAccess=main
#WatchdogSec=10
#Restart=on-failure
CapabilityBoundingSet=CAP_NET_ADMIN CAP_NET_BIND_SERVICE
LimitNPROC=1
ProtectHome=true
ProtectSystem=full
[Install]
WantedBy=bluetooth.target
Alias=dbus-org.bluez.service
By the way, second thing, I'm having a Exception: Tmds.DBus.DBusException: org.bluez.Error.Failed: Protocol not available error when connecting in my C# program, if anyone knows why.
User contributions licensed under CC BY-SA 3.0