Android Bluetooth device stuck in connect/disconnect loop with Linux Bluez Peripheral - android

For a BLE project I have been working on, I have created a smartphone application which serves as central, and a program in Linux, that serves as peripheral. After manually disconnecting via the phone, the program works as intended. But after disconnecting via the peripheral, the connection gets stuck in connect/disconnect loop.
I'm using "JustWorks" in bluetooth, which doesn't require any bonding/pairing.
The smartphone application is made in Flutter, and uses the flutter_reactive_ble library from Hue. The Linux program is written in Python, and uses the Bluezero package, but for disconnecting, I'm using:
subprocess.run("bluetoothctl -- disconnect", shell=True)
The terminal that is running the peripheral looks like this:
Attempting to disconnect from 58:93:C0:B5:9B:D7
Successful disconnected
[CHG] Device 58:93:C0:B5:9B:D7 Connected: no
Attempting to disconnect from 58:93:C0:B5:9B:D7
Successful disconnected
Attempting to disconnect from 58:93:C0:B5:9B:D7
Successful disconnected
The bluetoothctl terminal looks like this:
[CHG] Device 6E:4C:38:CB:4D:A9 Connected: no
[CHG] Device 6E:4C:38:CB:4D:A9 Connected: yes
[CHG] Device 6E:4C:38:CB:4D:A9 Connected: no
[CHG] Device 6E:4C:38:CB:4D:A9 Connected: yes
[CHG] Device 6E:4C:38:CB:4D:A9 Connected: no
[CHG] Device 6E:4C:38:CB:4D:A9 Connected: yes
This is the btmon output: From start to end: Received data -> disconnected from peripheral -> stuck in connect/disconnect loop.
> HCI Event: LE Meta Event (0x3e) plen 10 #72 [hci0] 4.765604
LE Connection Update Complete (0x03)
Status: Success (0x00)
Handle: 24
Connection interval: 45.00 msec (0x0024)
Connection latency: 0 (0x0000)
Supervision timeout: 5000 msec (0x01f4)
> ACL Data RX: Handle 24 flags 0x02 dlen 27 #73 [hci0] 4.855361
> ACL Data RX: Handle 24 flags 0x01 dlen 27 #74 [hci0] 4.856590
> ACL Data RX: Handle 24 flags 0x01 dlen 81 #75 [hci0] 4.857340
ATT: Write Command (0x52) len 130
Handle: 0x0026
Data: 6c69664638704647574134704656625275514a6d727053547062486a754d4c527758674f545733496d4e566630506d385542776c7a446155482b774f506f6a6330335345796c69695438494477554e477664617431424a3373496b352f58476d507a5937676a42707462436e4574392f5858702b79426b4e77796e43694c7242
> HCI Event: LE Meta Event (0x3e) plen 11 #76 [hci0] 4.857646
LE Data Length Change (0x07)
Handle: 24
Max TX octets: 251
Max TX time: 2120
Max RX octets: 250
Max RX time: 2120
# MGMT Command: Disconnect (0x0014) plen 7 {0x0001} [hci0] 6.819215
LE Address: 48:AD:99:8B:C5:3D (Resolvable)
< HCI Command: Disconnect (0x01|0x0006) plen 3 #77 [hci0] 6.819411
Handle: 24
Reason: Remote User Terminated Connection (0x13)
> HCI Event: Command Status (0x0f) plen 4 #78 [hci0] 6.823217
Disconnect (0x01|0x0006) ncmd 2
Status: Success (0x00)
> HCI Event: Disconnect Complete (0x05) plen 4 #79 [hci0] 6.881799
Status: Success (0x00)
Handle: 24
Reason: Connection Terminated By Local Host (0x16)
# MGMT Event: Command Complete (0x0001) plen 10 {0x0001} [hci0] 6.882315
Disconnect (0x0014) plen 7
Status: Success (0x00)
LE Address: 48:AD:99:8B:C5:3D (Resolvable)
< HCI Command: LE Set Extended Adve.. (0x08|0x0039) plen 6 #80 [hci0] 6.907442
Extended advertising: Disabled (0x00)
Number of sets: 1 (0x01)
Entry 0
Handle: 0x01
Duration: 0 ms (0x00)
Max ext adv events: 0
> HCI Event: Command Complete (0x0e) plen 4 #81 [hci0] 6.911608
LE Set Extended Advertising Enable (0x08|0x0039) ncmd 2
Status: Success (0x00)
< HCI Command: LE Set Extended Adv.. (0x08|0x0036) plen 25 #82 [hci0] 6.911986
Handle: 0x01
Properties: 0x0013
Connectable
Scannable
Use legacy advertising PDUs: ADV_IND
Min advertising interval: 37.500 msec (0x003c)
Max advertising interval: 37.500 msec (0x003c)
Channel map: 37, 38, 39 (0x07)
Own address type: Public (0x00)
Peer address type: Public (0x00)
Peer address: 00:00:00:00:00:00 (OUI 00-00-00)
Filter policy: Allow Scan Request from Any, Allow Connect Request from Any (0x00)
TX power: 0 dbm (0x00)
Primary PHY: LE 1M (0x01)
Secondary max skip: 0x00
Secondary PHY: LE 1M (0x01)
SID: 0x00
Scan request notifications: Disabled (0x00)
> HCI Event: Command Complete (0x0e) plen 5 #83 [hci0] 6.913620
LE Set Extended Advertising Parameters (0x08|0x0036) ncmd 2
Status: Success (0x00)
TX power (selected): 0 dbm (0x00)
< HCI Command: LE Set Extended Adve.. (0x08|0x0039) plen 6 #84 [hci0] 6.913983
Extended advertising: Enabled (0x01)
Number of sets: 1 (0x01)
Entry 0
Handle: 0x01
Duration: 0 ms (0x00)
Max ext adv events: 0
> HCI Event: Command Complete (0x0e) plen 4 #85 [hci0] 6.918517
LE Set Extended Advertising Enable (0x08|0x0039) ncmd 2
Status: Success (0x00)
> HCI Event: LE Meta Event (0x3e) plen 19 #86 [hci0] 7.793289
LE Connection Complete (0x01)
Status: Success (0x00)
Handle: 24
Role: Peripheral (0x01)
Peer address type: Random (0x01)
Peer address: 48:AD:99:8B:C5:3D (Resolvable)
Connection interval: 45.00 msec (0x0024)
Connection latency: 0 (0x0000)
Supervision timeout: 5000 msec (0x01f4)
Central clock accuracy: 0x01
# MGMT Event: Device Connected (0x000b) plen 13 {0x0001} [hci0] 7.793976
LE Address: 48:AD:99:8B:C5:3D (Resolvable)
Flags: 0x00000000
Data length: 0
< HCI Command: LE Read Remote Used... (0x08|0x0016) plen 2 #87 [hci0] 7.794074
Handle: 24
> HCI Event: LE Meta Event (0x3e) plen 6 #88 [hci0] 7.795376
LE Advertising Set Terminated (0x12)
Status: Success (0x00)
Handle: 1
Connection handle: 24
Number of completed extended advertising events: 20
> HCI Event: Command Status (0x0f) plen 4 #89 [hci0] 7.797118
LE Read Remote Used Features (0x08|0x0016) ncmd 2
Status: Success (0x00)
> HCI Event: LE Meta Event (0x3e) plen 4 #90 [hci0] 7.827428
LE Channel Selection Algorithm (0x14)
Handle: 24
Algorithm: #2 (0x01)
> HCI Event: LE Meta Event (0x3e) plen 12 #91 [hci0] 7.873271
LE Read Remote Used Features (0x04)
Status: Success (0x00)
Handle: 24
Features: 0xbd 0x7f 0x00 0x37 0x01 0x00 0x00 0x00
LE Encryption
Extended Reject Indication
Peripheral-initiated Features Exchange
LE Ping
LE Data Packet Length Extension
Extended Scanner Filter Policies
LE 2M PHY
Stable Modulation Index - Transmitter
Stable Modulation Index - Receiver
LE Coded PHY
LE Extended Advertising
LE Periodic Advertising
Channel Selection Algorithm #2
Periodic Advertising Sync Transfer - Sender
Periodic Advertising Sync Transfer - Recipient
Sleep Clock Accuracy Updates
Connected Isochronous Stream - Central
Connected Isochronous Stream - Peripheral
Isochronous Channels (Host Support)
> ACL Data RX: Handle 24 flags 0x02 dlen 26 #92 [hci0] 8.006833
LE L2CAP: Enhanced Credit Connection Request (0x17) ident 3 len 18
PSM: 39 (0x0027)
MTU: 256
MPS: 251
Credits: 65535
Source CID: 67
Source CID: 80
Source CID: 72
Source CID: 73
Source CID: 74
< ACL Data TX: Handle 24 flags 0x00 dlen 10 #93 [hci0] 8.011070
LE L2CAP: Command Reject (0x01) ident 3 len 2
Reason: Command not understood (0x0000)
> ACL Data RX: Handle 24 flags 0x02 dlen 26 #94 [hci0] 8.011537
LE L2CAP: Enhanced Credit Connection Request (0x17) ident 4 len 18
PSM: 39 (0x0027)
MTU: 256
MPS: 251
Credits: 65535
Source CID: 67
Source CID: 80
Source CID: 72
Source CID: 73
Source CID: 74
< ACL Data TX: Handle 24 flags 0x00 dlen 10 #95 [hci0] 8.011863
LE L2CAP: Command Reject (0x01) ident 4 len 2
Reason: Command not understood (0x0000)
> ACL Data RX: Handle 24 flags 0x02 dlen 26 #96 [hci0] 8.013806
LE L2CAP: Enhanced Credit Connection Request (0x17) ident 5 len 18
PSM: 39 (0x0027)
MTU: 256
MPS: 251
Credits: 65535
Source CID: 67
Source CID: 80
Source CID: 72
Source CID: 73
Source CID: 74
< ACL Data TX: Handle 24 flags 0x00 dlen 10 #97 [hci0] 8.014120
LE L2CAP: Command Reject (0x01) ident 5 len 2
Reason: Command not understood (0x0000)
> ACL Data RX: Handle 24 flags 0x02 dlen 26 #98 [hci0] 8.015700
LE L2CAP: Enhanced Credit Connection Request (0x17) ident 6 len 18
PSM: 39 (0x0027)
MTU: 256
MPS: 251
Credits: 65535
Source CID: 67
Source CID: 80
Source CID: 72
Source CID: 73
Source CID: 74
< ACL Data TX: Handle 24 flags 0x00 dlen 10 #99 [hci0] 8.016011
LE L2CAP: Command Reject (0x01) ident 6 len 2
Reason: Command not understood (0x0000)
> ACL Data RX: Handle 24 flags 0x02 dlen 26 #100 [hci0] 8.017572
LE L2CAP: Enhanced Credit Connection Request (0x17) ident 7 len 18
PSM: 39 (0x0027)
MTU: 256
MPS: 251
Credits: 65535
Source CID: 67
Source CID: 80
Source CID: 72
Source CID: 73
Source CID: 74
< ACL Data TX: Handle 24 flags 0x00 dlen 10 #101 [hci0] 8.017884
LE L2CAP: Command Reject (0x01) ident 7 len 2
Reason: Command not understood (0x0000)
> ACL Data RX: Handle 24 flags 0x02 dlen 26 #102 [hci0] 8.019854
LE L2CAP: Enhanced Credit Connection Request (0x17) ident 8 len 18
PSM: 39 (0x0027)
MTU: 256
MPS: 251
Credits: 65535
Source CID: 67
Source CID: 80
Source CID: 72
Source CID: 73
Source CID: 74
< ACL Data TX: Handle 24 flags 0x00 dlen 10 #103 [hci0] 8.020183
LE L2CAP: Command Reject (0x01) ident 8 len 2
Reason: Command not understood (0x0000)
> HCI Event: Number of Completed Packets (0x13) plen 5 #104 [hci0] 8.055702
Num handles: 1
Handle: 24
Count: 1
> HCI Event: LE Meta Event (0x3e) plen 11 #105 [hci0] 8.059275
LE Data Length Change (0x07)
Handle: 24
Max TX octets: 251
Max TX time: 2120
Max RX octets: 27
Max RX time: 328
> HCI Event: Number of Completed Packets (0x13) plen 5 #106 [hci0] 8.063411
Num handles: 1
Handle: 24
Count: 1
> HCI Event: Number of Completed Packets (0x13) plen 5 #107 [hci0] 8.067380
Num handles: 1
Handle: 24
Count: 1
> HCI Event: Number of Completed Packets (0x13) plen 5 #108 [hci0] 8.070316
Num handles: 1
Handle: 24
Count: 1
> HCI Event: Number of Completed Packets (0x13) plen 5 #109 [hci0] 8.072300
Num handles: 1
Handle: 24
Count: 1
> HCI Event: Number of Completed Packets (0x13) plen 5 #110 [hci0] 8.099836
Num handles: 1
Handle: 24
Count: 1
# MGMT Command: Disconnect (0x0014) plen 7 {0x0001} [hci0] 10.834677
LE Address: 48:AD:99:8B:C5:3D (Resolvable)
< HCI Command: Disconnect (0x01|0x0006) plen 3 #111 [hci0] 10.836267
Handle: 24
Reason: Remote User Terminated Connection (0x13)
> HCI Event: Command Status (0x0f) plen 4 #112 [hci0] 10.840869
Disconnect (0x01|0x0006) ncmd 2
Status: Success (0x00)
> HCI Event: Disconnect Complete (0x05) plen 4 #113 [hci0] 10.889096
Status: Success (0x00)
Handle: 24
Reason: Connection Terminated By Local Host (0x16)
# MGMT Event: Command Complete (0x0001) plen 10 {0x0001} [hci0] 10.889891
Disconnect (0x0014) plen 7
Status: Success (0x00)
LE Address: 48:AD:99:8B:C5:3D (Resolvable)
< HCI Command: LE Set Extended Ad.. (0x08|0x0039) plen 6 #114 [hci0] 10.919524
Extended advertising: Disabled (0x00)
Number of sets: 1 (0x01)
Entry 0
Handle: 0x01
Duration: 0 ms (0x00)
Max ext adv events: 0
> HCI Event: Command Complete (0x0e) plen 4 #115 [hci0] 10.923760
LE Set Extended Advertising Enable (0x08|0x0039) ncmd 2
Status: Success (0x00)
< HCI Command: LE Set Extended A.. (0x08|0x0036) plen 25 #116 [hci0] 10.924022
Handle: 0x01
Properties: 0x0013
Connectable
Scannable
Use legacy advertising PDUs: ADV_IND
Min advertising interval: 37.500 msec (0x003c)
Max advertising interval: 37.500 msec (0x003c)
Channel map: 37, 38, 39 (0x07)
Own address type: Public (0x00)
Peer address type: Public (0x00)
Peer address: 00:00:00:00:00:00 (OUI 00-00-00)
Filter policy: Allow Scan Request from Any, Allow Connect Request from Any (0x00)
TX power: 0 dbm (0x00)
Primary PHY: LE 1M (0x01)
Secondary max skip: 0x00
Secondary PHY: LE 1M (0x01)
SID: 0x00
Scan request notifications: Disabled (0x00)
> HCI Event: Command Complete (0x0e) plen 5 #117 [hci0] 10.927608
LE Set Extended Advertising Parameters (0x08|0x0036) ncmd 2
Status: Success (0x00)
TX power (selected): 0 dbm (0x00)
< HCI Command: LE Set Extended Ad.. (0x08|0x0039) plen 6 #118 [hci0] 10.928040
Extended advertising: Enabled (0x01)
Number of sets: 1 (0x01)
Entry 0
Handle: 0x01
Duration: 0 ms (0x00)
Max ext adv events: 0
> HCI Event: Command Complete (0x0e) plen 4 #119 [hci0] 10.933897
LE Set Extended Advertising Enable (0x08|0x0039) ncmd 2
Status: Success (0x00)
> HCI Event: LE Meta Event (0x3e) plen 19 #120 [hci0] 10.942881
LE Connection Complete (0x01)
Status: Success (0x00)
Handle: 24
Role: Peripheral (0x01)
Peer address type: Random (0x01)
Peer address: 48:AD:99:8B:C5:3D (Resolvable)
Connection interval: 45.00 msec (0x0024)
Connection latency: 0 (0x0000)
Supervision timeout: 5000 msec (0x01f4)
Central clock accuracy: 0x01
# MGMT Event: Device Connected (0x000b) plen 13 {0x0001} [hci0] 10.943295
LE Address: 48:AD:99:8B:C5:3D (Resolvable)
Flags: 0x00000000
Data length: 0
< HCI Command: LE Read Remote Use.. (0x08|0x0016) plen 2 #121 [hci0] 10.943372
Handle: 24
> HCI Event: LE Meta Event (0x3e) plen 6 #122 [hci0] 10.944681
LE Advertising Set Terminated (0x12)
Status: Success (0x00)
Handle: 1
Connection handle: 24
Number of completed extended advertising events: 0
> HCI Event: Command Status (0x0f) plen 4 #123 [hci0] 10.946984
LE Read Remote Used Features (0x08|0x0016) ncmd 2
Status: Success (0x00)
> HCI Event: LE Meta Event (0x3e) plen 4 #124 [hci0] 10.979349
LE Channel Selection Algorithm (0x14)
Handle: 24
Algorithm: #2 (0x01)
> HCI Event: LE Meta Event (0x3e) plen 12 #125 [hci0] 11.024865
LE Read Remote Used Features (0x04)
Status: Success (0x00)
Handle: 24
Features: 0xbd 0x7f 0x00 0x37 0x01 0x00 0x00 0x00
LE Encryption
Extended Reject Indication
Peripheral-initiated Features Exchange
LE Ping
LE Data Packet Length Extension
Extended Scanner Filter Policies
LE 2M PHY
Stable Modulation Index - Transmitter
Stable Modulation Index - Receiver
LE Coded PHY
LE Extended Advertising
LE Periodic Advertising
Channel Selection Algorithm #2
Periodic Advertising Sync Transfer - Sender
Periodic Advertising Sync Transfer - Recipient
Sleep Clock Accuracy Updates
Connected Isochronous Stream - Central
Connected Isochronous Stream - Peripheral
Isochronous Channels (Host Support)
> ACL Data RX: Handle 24 flags 0x02 dlen 26 #126 [hci0] 11.158694
LE L2CAP: Enhanced Credit Connection Request (0x17) ident 9 len 18
PSM: 39 (0x0027)
MTU: 256
MPS: 251
Credits: 65535
Source CID: 75
Source CID: 82
Source CID: 64
Source CID: 65
Source CID: 66
< ACL Data TX: Handle 24 flags 0x00 dlen 10 #127 [hci0] 11.159017
LE L2CAP: Command Reject (0x01) ident 9 len 2
Reason: Command not understood (0x0000)
> ACL Data RX: Handle 24 flags 0x02 dlen 26 #128 [hci0] 11.160874
LE L2CAP: Enhanced Credit Connection Request (0x17) ident 10 len 18
PSM: 39 (0x0027)
MTU: 256
MPS: 251
Credits: 65535
Source CID: 75
Source CID: 82
Source CID: 64
Source CID: 65
Source CID: 66
< ACL Data TX: Handle 24 flags 0x00 dlen 10 #129 [hci0] 11.161137
LE L2CAP: Command Reject (0x01) ident 10 len 2
Reason: Command not understood (0x0000)
> ACL Data RX: Handle 24 flags 0x02 dlen 26 #130 [hci0] 11.162536
LE L2CAP: Enhanced Credit Connection Request (0x17) ident 11 len 18
PSM: 39 (0x0027)
MTU: 256
MPS: 251
Credits: 65535
Source CID: 75
Source CID: 82
Source CID: 64
Source CID: 65
Source CID: 66
< ACL Data TX: Handle 24 flags 0x00 dlen 10 #131 [hci0] 11.162874
LE L2CAP: Command Reject (0x01) ident 11 len 2
Reason: Command not understood (0x0000)
> ACL Data RX: Handle 24 flags 0x02 dlen 26 #132 [hci0] 11.164513
LE L2CAP: Enhanced Credit Connection Request (0x17) ident 12 len 18
PSM: 39 (0x0027)
MTU: 256
MPS: 251
Credits: 65535
Source CID: 75
Source CID: 82
Source CID: 64
Source CID: 65
Source CID: 66
< ACL Data TX: Handle 24 flags 0x00 dlen 10 #133 [hci0] 11.164839
LE L2CAP: Command Reject (0x01) ident 12 len 2
Reason: Command not understood (0x0000)
> ACL Data RX: Handle 24 flags 0x02 dlen 26 #134 [hci0] 11.166441
LE L2CAP: Enhanced Credit Connection Request (0x17) ident 13 len 18
PSM: 39 (0x0027)
MTU: 256
MPS: 251
Credits: 65535
Source CID: 75
Source CID: 82
Source CID: 64
Source CID: 65
Source CID: 66
< ACL Data TX: Handle 24 flags 0x00 dlen 10 #135 [hci0] 11.166739
LE L2CAP: Command Reject (0x01) ident 13 len 2
Reason: Command not understood (0x0000)
> ACL Data RX: Handle 24 flags 0x02 dlen 26 #136 [hci0] 11.168433
LE L2CAP: Enhanced Credit Connection Request (0x17) ident 14 len 18
PSM: 39 (0x0027)
MTU: 256
MPS: 251
Credits: 65535
Source CID: 75
Source CID: 82
Source CID: 64
Source CID: 65
Source CID: 66
< ACL Data TX: Handle 24 flags 0x00 dlen 10 #137 [hci0] 11.168788
LE L2CAP: Command Reject (0x01) ident 14 len 2
Reason: Command not understood (0x0000)
> HCI Event: Number of Completed Packets (0x13) plen 5 #138 [hci0] 11.207392
Num handles: 1
Handle: 24
Count: 1
> HCI Event: LE Meta Event (0x3e) plen 11 #139 [hci0] 11.211700
LE Data Length Change (0x07)
Handle: 24
Max TX octets: 251
Max TX time: 2120
Max RX octets: 27
Max RX time: 328
> HCI Event: Number of Completed Packets (0x13) plen 5 #140 [hci0] 11.213812
Num handles: 1
Handle: 24
Count: 1
> HCI Event: Number of Completed Packets (0x13) plen 5 #141 [hci0] 11.217827
Num handles: 1
Handle: 24
Count: 1
> HCI Event: Number of Completed Packets (0x13) plen 5 #142 [hci0] 11.221915
Num handles: 1
Handle: 24
Count: 1
> HCI Event: Number of Completed Packets (0x13) plen 5 #143 [hci0] 11.225994
Num handles: 1
Handle: 24
Count: 1
> HCI Event: Number of Completed Packets (0x13) plen 5 #144 [hci0] 11.251600
Num handles: 1
Handle: 24
Count: 1
# MGMT Command: Disconnect (0x0014) plen 7 {0x0001} [hci0] 14.821568
LE Address: 48:AD:99:8B:C5:3D (Resolvable)
< HCI Command: Disconnect (0x01|0x0006) plen 3 #145 [hci0] 14.821608
Handle: 24
Reason: Remote User Terminated Connection (0x13)
> HCI Event: Command Status (0x0f) plen 4 #146 [hci0] 14.830653
Disconnect (0x01|0x0006) ncmd 2
Status: Success (0x00)
> HCI Event: Disconnect Complete (0x05) plen 4 #147 [hci0] 14.896228
Status: Success (0x00)
Handle: 24
Reason: Connection Terminated By Local Host (0x16)
# MGMT Event: Command Complete (0x0001) plen 10 {0x0001} [hci0] 14.896709
Disconnect (0x0014) plen 7
Status: Success (0x00)
LE Address: 48:AD:99:8B:C5:3D (Resolvable)
For this project, I would like the peripheral to be able to disconnect, without getting stuck in the connect/disconnect loop.
Attempting to manually disconnect via the console in the bluetoothctl menu returns the same results.
It doesn't seem that the error is in my application. Debug statements proof that the connect method doesn't get called.
Does anyone have any suggestions/solutions for this problem?

Related

Pic32_MZEF_Curiosity_v2: USB Device only (Audio + CDC) Not Working

This is the first time for me in a USB environment hence any input is highly appreciated.
My Setup:
-Pic32 ME EF curiosity v2 board + AK4954 Codec Module attached to mikro Bus 2 using Mplab x 5V5 IDE under Harmony 3
-My current project code/ example codes / Wireshark data WIP here
-default microchip audio & cdc examples are functional
Desired result:(USB Device mode only)
I would like to emulate USB headphones (Audio playing from YT video on android phone) + CDC (custom data sent to serial USB terminal app on Android upon button press)
My progress:
I've used the default Microchip functional audio example & integrated the CDC example into it.
My USB composite device is enumerated correctly into my PC (device manager) & then I'm receiving
“This device cannot start. (Code 10)” on windows I use a software named “UsbTreeView” I checked it and It’s telling me like this:
----------------- Device Qualifier Descriptor -----------------
Error : ERROR_GEN_FAILURE
if I’ve understood the USB concept well -> The IAD(Interface
association descriptor) is also declared accurately. but I'm having a
doubt on configuration descriptors.
In windows, it shows The com port(CDC is enumerated correctly but the
audio is in an error state) but when I tried using putty no data is
flowing through but I could see the data sent from the board on
Wireshark upon button press.
I've also attached the Wireshark log as when I press the button I can see the interrupt + data sent from the device to the host. (but with this error:IRP USBD_STATUS: USBD_STATUS_CANCELED (0xc0010000))
I then connected this to my android phone & the audio is functional &
CDC terminal station "control transfer failed"
I also connected this to UBUNTU PC & the audio is functional properly
& CDC terminal TTYACM0 "Terminal open failed " by the app "Screen"
Device Descriptors
Information for device USB Headset PIC32MZEF AUD + CDC (VID=0x04D8 PID=0x0065):
------------------------------
Connection Information:
------------------------------
Device current bus speed: FullSpeed
Device supports USB 1.1 specification
Device supports USB 2.0 specification
Device address: 0x001A
Current configuration value: 0x01
Number of open pipes: 3
------------------------------
Device Descriptor:
------------------------------
0x12 bLength
0x01 bDescriptorType
0x0200 bcdUSB
0x00 bDeviceClass
0x00 bDeviceSubClass
0x00 bDeviceProtocol
0x40 bMaxPacketSize0 (64 bytes)
0x04D8 idVendor
0x0065 idProduct
0x0100 bcdDevice
0x01 iManufacturer "Microchip Technology Inc."
0x02 iProduct "USB Headset PIC32MZEF AUD + CDC"
0x03 iSerialNumber "12345678999"
0x01 bNumConfigurations
-------------------------
Configuration Descriptor:
-------------------------
0x09 bLength
0x02 bDescriptorType
0x012C wTotalLength (300 bytes)
0x05 bNumInterfaces
0x01 bConfigurationValue
0x00 iConfiguration
0xC0 bmAttributes (Self-powered Device)
0x32 bMaxPower (100 mA)
Interface Descriptor:
------------------------------
0x09 bLength
0x04 bDescriptorType
0x00 bInterfaceNumber
0x00 bAlternateSetting
0x00 bNumEndPoints
0x01 bInterfaceClass (Audio Device Class)
0x01 bInterfaceSubClass (Audio Control Interface)
0x00 bInterfaceProtocol (Audio Protocol undefined)
0x00 iInterface
AC Interface Header Descriptor:
------------------------------
0x0A bLength
0x24 bDescriptorType
0x01 bDescriptorSubtype
0x0100 bcdADC
0x0064 wTotalLength (100 bytes)
0x02 bInCollection
0x01 baInterfaceNr(1)
0x02 baInterfaceNr(2)
AC Input Terminal Descriptor:
------------------------------
0x0C bLength
0x24 bDescriptorType
0x02 bDescriptorSubtype
0x01 bTerminalID
0x0101 wTerminalType (USB Streaming)
0x00 bAssocTerminal
0x02 bNrChannels (2 channels)
0x0003 wChannelConfig
0x00 iChannelNames
0x00 iTerminal
AC Input Terminal Descriptor:
------------------------------
0x0C bLength
0x24 bDescriptorType
0x02 bDescriptorSubtype
0x04 bTerminalID
0x0201 wTerminalType (Microphone)
0x00 bAssocTerminal
0x01 bNrChannels (1 channels)
0x0004 wChannelConfig
0x00 iChannelNames
0x00 iTerminal
AC Feature Unit Descriptor:
------------------------------
0x0D bLength
0x24 bDescriptorType
0x06 bDescriptorSubtype
0x02 bUnitID
0x08 bSourceID
0x02 bControlSize
bmaControls:
0x01 Channel(0) - Mute
0x00 Channel(1)
0x00 Channel(2)
0x00 iFeature
AC Feature Unit Descriptor:
------------------------------
0x0B bLength
0x24 bDescriptorType
0x06 bDescriptorSubtype
0x05 bUnitID
0x04 bSourceID
0x02 bControlSize
bmaControls:
0x01 Channel(0) - Mute
0x00 Channel(1)
0x00 iFeature
AC Feature Unit Descriptor:
------------------------------
0x0B bLength
0x24 bDescriptorType
0x06 bDescriptorSubtype
0x07 bUnitID
0x04 bSourceID
0x02 bControlSize
bmaControls:
0x01 Channel(0) - Mute
0x00 Channel(1)
0x00 iFeature
AC Mixer Unit Descriptor:
------------------------------
0x0D bLength
0x24 bDescriptorType
0x04 bDescriptorSubtype
0x08 bUnitID
0x02 bBrInPins
0x01 baSourceID(1)
0x07 baSourceID(2)
0x02 bNrChannels
0x0003 wChannelConfig
0x00 iChannelNames
bmControls:
0x00
0x00 iMixer
AC Output Terminal Descriptor:
------------------------------
0x09 bLength
0x24 bDescriptorType
0x03 bDescriptorSubtype
0x03 bTerminalID
0x0302 wTerminalType (Headphones)
0x00 bAssocTerminal
0x02 bSourceID
0x00 iTerminal
AC Output Terminal Descriptor:
------------------------------
0x09 bLength
0x24 bDescriptorType
0x03 bDescriptorSubtype
0x06 bTerminalID
0x0101 wTerminalType (USB Streaming)
0x00 bAssocTerminal
0x05 bSourceID
0x00 iTerminal
Interface Descriptor:
------------------------------
0x09 bLength
0x04 bDescriptorType
0x01 bInterfaceNumber
0x00 bAlternateSetting
0x00 bNumEndPoints
0x01 bInterfaceClass (Audio Device Class)
0x02 bInterfaceSubClass (Audio Streaming Interface)
0x00 bInterfaceProtocol (Audio Protocol undefined)
0x00 iInterface
Interface Descriptor:
------------------------------
0x09 bLength
0x04 bDescriptorType
0x01 bInterfaceNumber
0x01 bAlternateSetting
0x01 bNumEndPoints
0x01 bInterfaceClass (Audio Device Class)
0x02 bInterfaceSubClass (Audio Streaming Interface)
0x00 bInterfaceProtocol (Audio Protocol undefined)
0x00 iInterface
AS Interface Descriptor:
------------------------------
0x07 bLength
0x24 bDescriptorType
0x01 bDescriptorSubtype
0x01 bTerminalLink
0x01 bDelay
0x0001 wFormatTag (PCM)
AS Format Type 1 Descriptor:
------------------------------
0x11 bLength
0x24 bDescriptorType
0x02 bDescriptorSubtype
0x01 bFormatType (FORMAT_TYPE_1)
0x02 bNrChannels (2 channels)
0x02 bSubframeSize
0x10 bBitResolution (16 bits per sample)
0x03 bSamFreqType (Discrete sampling frequencies)
0x003E80 tSamFreq(1) (16000 Hz)
0x007D00 tSamFreq(2) (32000 Hz)
0x00BB80 tSamFreq(3) (48000 Hz)
Endpoint Descriptor (Audio/MIDI 1.0):
------------------------------
0x09 bLength
0x05 bDescriptorType
0x01 bEndpointAddress (OUT endpoint 1)
0x09 bmAttributes (Transfer: Isochronous / Synch: Adaptive / Usage: Data)
0x00C0 wMaxPacketSize (1 x 192 bytes)
0x01 bInterval (1 frames)
0x00 bRefresh
0x00 bSynchAddress
AS Isochronous Data Endpoint Descriptor:
------------------------------
0x07 bLength
0x25 bDescriptorType
0x01 bDescriptorSubtype
0x01 bmAttributes (Sampling Frequency)
0x00 bLockDelayUnits (undefined)
0x0000 wLockDelay
Interface Descriptor:
------------------------------
0x09 bLength
0x04 bDescriptorType
0x02 bInterfaceNumber
0x00 bAlternateSetting
0x00 bNumEndPoints
0x01 bInterfaceClass (Audio Device Class)
0x02 bInterfaceSubClass (Audio Streaming Interface)
0x00 bInterfaceProtocol (Audio Protocol undefined)
0x00 iInterface
Interface Descriptor:
------------------------------
0x09 bLength
0x04 bDescriptorType
0x02 bInterfaceNumber
0x01 bAlternateSetting
0x01 bNumEndPoints
0x01 bInterfaceClass (Audio Device Class)
0x02 bInterfaceSubClass (Audio Streaming Interface)
0x00 bInterfaceProtocol (Audio Protocol undefined)
0x00 iInterface
AS Interface Descriptor:
------------------------------
0x07 bLength
0x24 bDescriptorType
0x01 bDescriptorSubtype
0x06 bTerminalLink
0x00 bDelay
0x0001 wFormatTag (PCM)
AS Format Type 1 Descriptor:
------------------------------
0x11 bLength
0x24 bDescriptorType
0x02 bDescriptorSubtype
0x01 bFormatType (FORMAT_TYPE_1)
0x01 bNrChannels (1 channels)
0x02 bSubframeSize
0x10 bBitResolution (16 bits per sample)
0x03 bSamFreqType (Discrete sampling frequencies)
0x003E80 tSamFreq(1) (16000 Hz)
0x007D00 tSamFreq(2) (32000 Hz)
0x00BB80 tSamFreq(3) (48000 Hz)
Endpoint Descriptor (Audio/MIDI 1.0):
------------------------------
0x09 bLength
0x05 bDescriptorType
0x82 bEndpointAddress (IN endpoint 2)
0x0D bmAttributes (Transfer: Isochronous / Synch: Synchronous / Usage: Data)
0x0060 wMaxPacketSize (1 x 96 bytes)
0x01 bInterval (1 frames)
0x00 bRefresh
0x00 bSynchAddress
AS Isochronous Data Endpoint Descriptor:
------------------------------
0x07 bLength
0x25 bDescriptorType
0x01 bDescriptorSubtype
0x01 bmAttributes (Sampling Frequency)
0x00 bLockDelayUnits (undefined)
0x0000 wLockDelay
Interface Association Descriptor:
------------------------------
0x08 bLength
0x0B bDescriptorType
0x03 bFirstInterface
0x02 bInterfaceCount
0x02 bFunctionClass (Communication Device Class)
0x02 bFunctionSubClass (Abstract Control Model - ACM)
0x01 bFunctionProtocol (ITU-T V.250)
0x00 iFunction
Interface Descriptor:
------------------------------
0x09 bLength
0x04 bDescriptorType
0x03 bInterfaceNumber
0x00 bAlternateSetting
0x01 bNumEndPoints
0x02 bInterfaceClass (Communication Device Class)
0x02 bInterfaceSubClass (Abstract Control Model - ACM)
0x01 bInterfaceProtocol (ITU-T V.250)
0x00 iInterface
CDC Header Functional Descriptor:
------------------------------
0x05 bFunctionalLength
0x24 bDescriptorType
0x00 bDescriptorSubtype
0x0120 bcdCDC
CDC Abstract Control Management Functional Descriptor:
------------------------------
0x04 bFunctionalLength
0x24 bDescriptorType
0x02 bDescriptorSubtype
0x02 bmCapabilities
CDC Union Functional Descriptor:
------------------------------
0x05 bFunctionalLength
0x24 bDescriptorType
0x06 bDescriptorSubtype
0x03 bControlInterface
0x04 bSubordinateInterface(0)
CDC Call Management Functional Descriptor:
------------------------------
0x05 bFunctionalLength
0x24 bDescriptorType
0x01 bDescriptorSubtype
0x00 bmCapabilities
0x04 bDataInterface
Endpoint Descriptor:
------------------------------
0x07 bLength
0x05 bDescriptorType
0x83 bEndpointAddress (IN endpoint 3)
0x03 bmAttributes (Transfer: Interrupt / Synch: None / Usage: Data)
0x0010 wMaxPacketSize (1 x 16 bytes)
0x02 bInterval (2 frames)
Interface Descriptor:
------------------------------
0x09 bLength
0x04 bDescriptorType
0x04 bInterfaceNumber
0x00 bAlternateSetting
0x02 bNumEndPoints
0x0A bInterfaceClass (CDC Data)
0x00 bInterfaceSubClass
0x00 bInterfaceProtocol
0x00 iInterface
Endpoint Descriptor:
------------------------------
0x07 bLength
0x05 bDescriptorType
0x04 bEndpointAddress (OUT endpoint 4)
0x02 bmAttributes (Transfer: Bulk / Synch: None / Usage: Data)
0x0040 wMaxPacketSize (64 bytes)
0x00 bInterval
Endpoint Descriptor:
------------------------------
0x07 bLength
0x05 bDescriptorType
0x84 bEndpointAddress (IN endpoint 4)
0x02 bmAttributes (Transfer: Bulk / Synch: None / Usage: Data)
0x0040 wMaxPacketSize (64 bytes)
0x00 bInterval
Microsoft OS Descriptor is not available. Error code: 0x0000001F
--------------------------------
String Descriptor Table
--------------------------------
Index LANGID String
0x00 0x0000 0x0409
0x01 0x0409 "Microchip Technology Inc."
0x02 0x0409 "USB Headset PIC32MZEF AUD + CDC"
0x03 0x0409 "12345678999"
------------------------------
Connection path for device:
USB xHCI Compliant Host Controller
Root Hub
Generic USB Hub
Generic USB Hub
USB Headset PIC32MZEF AUD + CDC (VID=0x04D8 PID=0x0065) Port: 1
Running on: Windows 10 or greater (Build Version 19044)
Brought to you by TDD v2.17.0, Feb 23 2021, 14:04:02
Please let me know the possible solutions & which area should I focus more on?
Thanks for your time. I really appreciate it
Have a good day

BLE Battery Level Service doesn't read phone battery level

My Setup
I'm using a TI Launchpad as a Bluetooth Low Energy Central Device, and my Samsung Galaxy S21 as a Peripheral. I'm using bTool (for my launchpad) and nRF Connect (for the phone).
From nRF Connect, I'm making my phone advertise data, so that the Launchpad can connect to it (from bTool). Everything works fine until this point.
I used the "Configure GATT Server" option from nRF Connect, added a Custom Service and selected Battery Level Service. Also added a Battery Level Characteristic, with "NOTIFY" and "READ" permissions, that also includes two Descriptors: Client Characteristic Configuration and Characteristic Presentation Format.
Expected Result
What I'm trying to do is, create a Battery Level Service (directly from the nRF Connect mobile app) that measures the battery level of my phone and sends it to my Launchpad.
The problem is, when opening bTool, I see that the battery level of my phone is not read. I can input some values by myself from the phone, but I would like the battery level of my phone to be read.
Also, I would like to be notified whenever the battery level has changed.
My question is: what did I do wrong? Does Battery Level Service actually take the battery information from the peripheral, or is it not intended for that?
** update **
This is the Battery Level service in my nRF Connect, together with its characteristics + permissions:
https://i.stack.imgur.com/TqYeK.jpg
Also, this is my bTool log, where I display all of the peripheral's services and write 01:00 to the Client Characteristic Configuration descriptor:
[1] : <Tx> - 11:40:18.260
-Type : 0x01 (Command)
-OpCode : 0xFD84 (GATT_DiscAllCharDescs)
-Data Length : 0x06 (6) byte(s)
ConnHandle : 0x0000 (0)
StartHandle : 0x0001 (1)
EndHandle : 0xFFFF (65535)
Dump(Tx):
0000:01 84 FD 06 00 00 01 00 FF FF ..........
--------------------------------------------------------------------
[2] : <Rx> - 11:40:18.290
-Type : 0x04 (Event)
-EventCode : 0x00FF (HCI_LE_ExtEvent)
-Data Length : 0x06 (6) bytes(s)
Event : 0x067F (1663) (GAP_HCI_ExtentionCommandStatus)
Status : 0x00 (0) (SUCCESS)
OpCode : 0xFD84 (GATT_DiscAllCharDescs)
DataLength : 0x00 (0)
Dump(Rx):
0000:04 FF 06 7F 06 00 84 FD 00 .........
--------------------------------------------------------------------
[3] : <Rx> - 11:40:18.411
-Type : 0x04 (Event)
-EventCode : 0x00FF (HCI_LE_ExtEvent)
-Data Length : 0x17 (23) bytes(s)
Event : 0x0505 (1285) (ATT_FindInfoRsp)
Status : 0x00 (0) (SUCCESS)
ConnHandle : 0x0000 (0)
PduLen : 0x11 (17)
Format : 0x01 (1) (HANDLE_BT_UUID_TYPE__handles_and_16_bit_Bluetooth_UUIDs)
Handle : 0001
Uuid : 00:28
Handle : 0014
Uuid : 00:28
Handle : 0028
Uuid : 00:28
Handle : 002F
Uuid : 00:28
Dump(Rx):
0000:04 FF 17 05 05 00 00 00 11 01 01 00 00 28 14 00 .............(..
0010:00 28 28 00 00 28 2F 00 00 28 .((..(/..(
--------------------------------------------------------------------
[4] : <Rx> - 11:40:18.610
-Type : 0x04 (Event)
-EventCode : 0x00FF (HCI_LE_ExtEvent)
-Data Length : 0x0B (11) bytes(s)
Event : 0x0505 (1285) (ATT_FindInfoRsp)
Status : 0x00 (0) (SUCCESS)
ConnHandle : 0x0000 (0)
PduLen : 0x05 (5)
Format : 0x01 (1) (HANDLE_BT_UUID_TYPE__handles_and_16_bit_Bluetooth_UUIDs)
Handle : 0030
Uuid : 03:28
Dump(Rx):
0000:04 FF 0B 05 05 00 00 00 05 01 30 00 03 28 ..........0..(
--------------------------------------------------------------------
[5] : <Rx> - 11:40:18.798
-Type : 0x04 (Event)
-EventCode : 0x00FF (HCI_LE_ExtEvent)
-Data Length : 0x0B (11) bytes(s)
Event : 0x0505 (1285) (ATT_FindInfoRsp)
Status : 0x00 (0) (SUCCESS)
ConnHandle : 0x0000 (0)
PduLen : 0x05 (5)
Format : 0x01 (1) (HANDLE_BT_UUID_TYPE__handles_and_16_bit_Bluetooth_UUIDs)
Handle : 0031
Uuid : 19:2A
Dump(Rx):
0000:04 FF 0B 05 05 00 00 00 05 01 31 00 19 2A ..........1..*
--------------------------------------------------------------------
[6] : <Rx> - 11:40:19.004
-Type : 0x04 (Event)
-EventCode : 0x00FF (HCI_LE_ExtEvent)
-Data Length : 0x0B (11) bytes(s)
Event : 0x0505 (1285) (ATT_FindInfoRsp)
Status : 0x00 (0) (SUCCESS)
ConnHandle : 0x0000 (0)
PduLen : 0x05 (5)
Format : 0x01 (1) (HANDLE_BT_UUID_TYPE__handles_and_16_bit_Bluetooth_UUIDs)
Handle : 0032
Uuid : 02:29
Dump(Rx):
0000:04 FF 0B 05 05 00 00 00 05 01 32 00 02 29 ..........2..)
--------------------------------------------------------------------
[7] : <Rx> - 11:40:19.193
-Type : 0x04 (Event)
-EventCode : 0x00FF (HCI_LE_ExtEvent)
-Data Length : 0x06 (6) bytes(s)
Event : 0x0505 (1285) (ATT_FindInfoRsp)
Status : 0x1A (26) (bleProcedureComplete)
ConnHandle : 0x0000 (0)
PduLen : 0x00 (0)
Dump(Rx):
0000:04 FF 06 05 05 1A 00 00 00 .........
--------------------------------------------------------------------
[8] : <Tx> - 11:40:24.896
-Type : 0x01 (Command)
-OpCode : 0xFD92 (GATT_WriteCharValue)
-Data Length : 0x06 (6) byte(s)
ConnHandle : 0x0000 (0)
Handle : 0x0032 (50)
Value : 01:00
Dump(Tx):
0000:01 92 FD 06 00 00 32 00 01 00 ......2...
--------------------------------------------------------------------
[9] : <Rx> - 11:40:24.942
-Type : 0x04 (Event)
-EventCode : 0x00FF (HCI_LE_ExtEvent)
-Data Length : 0x06 (6) bytes(s)
Event : 0x067F (1663) (GAP_HCI_ExtentionCommandStatus)
Status : 0x00 (0) (SUCCESS)
OpCode : 0xFD92 (GATT_WriteCharValue)
DataLength : 0x00 (0)
Dump(Rx):
0000:04 FF 06 7F 06 00 92 FD 00 .........
--------------------------------------------------------------------
[10] : <Rx> - 11:40:25.085
-Type : 0x04 (Event)
-EventCode : 0x00FF (HCI_LE_ExtEvent)
-Data Length : 0x06 (6) bytes(s)
Event : 0x0513 (1299) (ATT_WriteRsp)
Status : 0x00 (0) (SUCCESS)
ConnHandle : 0x0000 (0)
PduLen : 0x00 (0)
Dump(Rx):
0000:04 FF 06 13 05 00 00 00 00 .........
--------------------------------------------------------------------
** update (2) **
Log starting from GATT_DiscAllPrimaryServices:
[1] : <Tx> - 09:37:03.083
-Type : 0x01 (Command)
-OpCode : 0xFD90 (GATT_DiscAllPrimaryServices)
-Data Length : 0x02 (2) byte(s)
ConnHandle : 0x0000 (0)
Dump(Tx):
0000:01 90 FD 02 00 00 ......
--------------------------------------------------------------------
[2] : <Rx> - 09:37:03.113
-Type : 0x04 (Event)
-EventCode : 0x00FF (HCI_LE_ExtEvent)
-Data Length : 0x06 (6) bytes(s)
Event : 0x067F (1663) (GAP_HCI_ExtentionCommandStatus)
Status : 0x00 (0) (SUCCESS)
OpCode : 0xFD90 (GATT_DiscAllPrimaryServices)
DataLength : 0x00 (0)
Dump(Rx):
0000:04 FF 06 7F 06 00 90 FD 00 .........
--------------------------------------------------------------------
[3] : <Rx> - 09:37:03.249
-Type : 0x04 (Event)
-EventCode : 0x00FF (HCI_LE_ExtEvent)
-Data Length : 0x13 (19) bytes(s)
Event : 0x0511 (1297) (ATT_ReadByGrpTypeRsp)
Status : 0x00 (0) (SUCCESS)
ConnHandle : 0x0000 (0)
PduLen : 0x0D (13)
Length : 0x06 (6)
DataList
AttrHandle : 0001
EndGrpHandle : 0003
Value : 01:18
AttrHandle : 0014
EndGrpHandle : 001A
Value : 00:18
Dump(Rx):
0000:04 FF 13 11 05 00 00 00 0D 06 01 00 03 00 01 18 ................
0010:14 00 1A 00 00 18 ......
--------------------------------------------------------------------
[4] : <Rx> - 09:37:03.430
-Type : 0x04 (Event)
-EventCode : 0x00FF (HCI_LE_ExtEvent)
-Data Length : 0x1B (27) bytes(s)
Event : 0x0511 (1297) (ATT_ReadByGrpTypeRsp)
Status : 0x00 (0) (SUCCESS)
ConnHandle : 0x0000 (0)
PduLen : 0x15 (21)
Length : 0x14 (20)
DataList
AttrHandle : 0028
EndGrpHandle : 002E
Value : 25:81:E8:8C:72:2E:8F:97:EA:11:DB:31:FC:34:4A:59
Dump(Rx):
0000:04 FF 1B 11 05 00 00 00 15 14 28 00 2E 00 25 81 ..........(...%.
0010:E8 8C 72 2E 8F 97 EA 11 DB 31 FC 34 4A 59 ..r......1.4JY
--------------------------------------------------------------------
[5] : <Rx> - 09:37:03.631
-Type : 0x04 (Event)
-EventCode : 0x00FF (HCI_LE_ExtEvent)
-Data Length : 0x0D (13) bytes(s)
Event : 0x0511 (1297) (ATT_ReadByGrpTypeRsp)
Status : 0x00 (0) (SUCCESS)
ConnHandle : 0x0000 (0)
PduLen : 0x07 (7)
Length : 0x06 (6)
DataList
AttrHandle : 002F
EndGrpHandle : FFFF
Value : 0F:18
Dump(Rx):
0000:04 FF 0D 11 05 00 00 00 07 06 2F 00 FF FF 0F 18 ........../.....
--------------------------------------------------------------------
[6] : <Rx> - 09:37:03.646
-Type : 0x04 (Event)
-EventCode : 0x00FF (HCI_LE_ExtEvent)
-Data Length : 0x06 (6) bytes(s)
Event : 0x0511 (1297) (ATT_ReadByGrpTypeRsp)
Status : 0x1A (26) (bleProcedureComplete)
ConnHandle : 0x0000 (0)
PduLen : 0x00 (0)
Dump(Rx):
0000:04 FF 06 11 05 1A 00 00 00 .........
--------------------------------------------------------------------

It is possible to establish peer connection between desktop and Android using TCP USB ADB?

I would to build app that connects between Android app to computer using usb.
I have made few steps. I forwarded tcp ports using adb command:
adb forward tcp:9500 tcp:9500
I created TCP server on Android on host: 127.0.0.1 port: 9500. Then I connected to desktop to the server using TCP client on 127.0.0.1:9500 created on Node.js. At this point everything works, devices connected. In the next step devices started signaling.
Android generated offer:
{"sdp":"v=0\r\no=- 1782695619798442838 2 IN IP4 127.0.0.1\r\ns=-\r\nt=0 0\r\na=group:BUNDLE 0 1 2\r\na=msid-semantic: WMS ARDAMS\r\nm=video 9 UDP\/TLS\/RTP\/SAVPF 96 97 98 99 100 101 127\r\nc=IN IP4 0.0.0.0\r\na=rtcp:9 IN IP4 0.0.0.0\r\na=ice-ufrag:Pwou\r\na=ice-pwd:uqEm2PMHFnvFSdkIPgF\/LdCh\r\na=ice-options:trickle renomination\r\na=fingerprint:sha-256 52:E4:76:A8:57:37:EB:33:F8:4A:96:D3:D8:3F:FE:A8:F9:3D:7B:8D:E7:9D:AB:A0:C4:83:B9:46:A2:FC:5C:44\r\na=setup:actpass\r\na=mid:0\r\na=extmap:2 urn:ietf:params:rtp-hdrext:toffset\r\na=extmap:3 http:\/\/www.webrtc.org\/experiments\/rtp-hdrext\/abs-send-time\r\na=extmap:4 urn:3gpp:video-orientation\r\na=extmap:5 http:\/\/www.ietf.org\/id\/draft-holmer-rmcat-transport-wide-cc-extensions-01\r\na=extmap:6 http:\/\/www.webrtc.org\/experiments\/rtp-hdrext\/playout-delay\r\na=extmap:7 http:\/\/www.webrtc.org\/experiments\/rtp-hdrext\/video-content-type\r\na=extmap:8 http:\/\/www.webrtc.org\/experiments\/rtp-hdrext\/video-timing\r\na=extmap:9 urn:ietf:params:rtp-hdrext:sdes:mid\r\na=sendrecv\r\na=msid:ARDAMS ARDAMSv0\r\na=rtcp-mux\r\na=rtcp-rsize\r\na=rtpmap:96 VP8\/90000\r\na=rtcp-fb:96 goog-remb\r\na=rtcp-fb:96 transport-cc\r\na=rtcp-fb:96 ccm fir\r\na=rtcp-fb:96 nack\r\na=rtcp-fb:96 nack pli\r\na=rtpmap:97 rtx\/90000\r\na=fmtp:97 apt=96\r\na=rtpmap:98 VP9\/90000\r\na=rtcp-fb:98 goog-remb\r\na=rtcp-fb:98 transport-cc\r\na=rtcp-fb:98 ccm fir\r\na=rtcp-fb:98 nack\r\na=rtcp-fb:98 nack pli\r\na=rtpmap:99 rtx\/90000\r\na=fmtp:99 apt=98\r\na=rtpmap:100 red\/90000\r\na=rtpmap:101 rtx\/90000\r\na=fmtp:101 apt=100\r\na=rtpmap:127 ulpfec\/90000\r\na=ssrc-group:FID 1916955335 2452582321\r\na=ssrc:1916955335 cname:tw17+zUY4UoZ4dvY\r\na=ssrc:1916955335 msid:ARDAMS ARDAMSv0\r\na=ssrc:1916955335 mslabel:ARDAMS\r\na=ssrc:1916955335 label:ARDAMSv0\r\na=ssrc:2452582321 cname:tw17+zUY4UoZ4dvY\r\na=ssrc:2452582321 msid:ARDAMS ARDAMSv0\r\na=ssrc:2452582321 mslabel:ARDAMS\r\na=ssrc:2452582321 label:ARDAMSv0\r\nm=audio 9 UDP\/TLS\/RTP\/SAVPF 111 103 104 9 102 0 8 106 105 13 110 112 113 126\r\nc=IN IP4 0.0.0.0\r\na=rtcp:9 IN IP4 0.0.0.0\r\na=ice-ufrag:Pwou\r\na=ice-pwd:uqEm2PMHFnvFSdkIPgF\/LdCh\r\na=ice-options:trickle renomination\r\na=fingerprint:sha-256 52:E4:76:A8:57:37:EB:33:F8:4A:96:D3:D8:3F:FE:A8:F9:3D:7B:8D:E7:9D:AB:A0:C4:83:B9:46:A2:FC:5C:44\r\na=setup:actpass\r\na=mid:1\r\na=extmap:1 urn:ietf:params:rtp-hdrext:ssrc-audio-level\r\na=extmap:9 urn:ietf:params:rtp-hdrext:sdes:mid\r\na=sendrecv\r\na=msid:ARDAMS ARDAMSa0\r\na=rtcp-mux\r\na=rtpmap:111 opus\/48000\/2\r\na=rtcp-fb:111 transport-cc\r\na=fmtp:111 minptime=10;useinbandfec=1\r\na=rtpmap:103 ISAC\/16000\r\na=rtpmap:104 ISAC\/32000\r\na=rtpmap:9 G722\/8000\r\na=rtpmap:102 ILBC\/8000\r\na=rtpmap:0 PCMU\/8000\r\na=rtpmap:8 PCMA\/8000\r\na=rtpmap:106 CN\/32000\r\na=rtpmap:105 CN\/16000\r\na=rtpmap:13 CN\/8000\r\na=rtpmap:110 telephone-event\/48000\r\na=rtpmap:112 telephone-event\/32000\r\na=rtpmap:113 telephone-event\/16000\r\na=rtpmap:126 telephone-event\/8000\r\na=ssrc:3388490788 cname:tw17+zUY4UoZ4dvY\r\na=ssrc:3388490788 msid:ARDAMS ARDAMSa0\r\na=ssrc:3388490788 mslabel:ARDAMS\r\na=ssrc:3388490788 label:ARDAMSa0\r\nm=application 9 DTLS\/SCTP 5000\r\nc=IN IP4 0.0.0.0\r\na=ice-ufrag:Pwou\r\na=ice-pwd:uqEm2PMHFnvFSdkIPgF\/LdCh\r\na=ice-options:trickle renomination\r\na=fingerprint:sha-256 52:E4:76:A8:57:37:EB:33:F8:4A:96:D3:D8:3F:FE:A8:F9:3D:7B:8D:E7:9D:AB:A0:C4:83:B9:46:A2:FC:5C:44\r\na=setup:actpass\r\na=mid:2\r\na=sctpmap:5000 webrtc-datachannel 1024\r\n","type":"offer"}
Node.js Electron generated answer:
{"type":"answer","sdp":"v=0\r\no=- 3020637264513396082 2 IN IP4 127.0.0.1\r\ns=-\r\nt=0 0\r\na=group:BUNDLE 0 1 2\r\na=msid-semantic: WMS\r\nm=video 9 UDP/TLS/RTP/SAVPF 96 97 98 99 100 101 127\r\nc=IN IP4 0.0.0.0\r\na=rtcp:9 IN IP4 0.0.0.0\r\na=ice-ufrag:I5v3\r\na=ice-pwd:r+w1c6kV+e2j7GqRfdZqS+wq\r\na=fingerprint:sha-256 AA:CF:6A:FC:DB:C7:E0:63:C8:C8:FE:79:9F:18:5F:A1:79:43:D9:09:91:45:0A:28:7F:EF:4E:9E:40:9A:45:8D\r\na=setup:active\r\na=mid:0\r\na=extmap:2 urn:ietf:params:rtp-hdrext:toffset\r\na=extmap:3 http://www.webrtc.org/experiments/rtp-hdrext/abs-send-time\r\na=extmap:4 urn:3gpp:video-orientation\r\na=extmap:5 http://www.ietf.org/id/draft-holmer-rmcat-transport-wide-cc-extensions-01\r\na=extmap:6 http://www.webrtc.org/experiments/rtp-hdrext/playout-delay\r\na=recvonly\r\na=rtcp-mux\r\na=rtcp-rsize\r\na=rtpmap:96 VP8/90000\r\na=rtcp-fb:96 ccm fir\r\na=rtcp-fb:96 nack\r\na=rtcp-fb:96 nack pli\r\na=rtcp-fb:96 goog-remb\r\na=rtcp-fb:96 transport-cc\r\na=rtpmap:97 rtx/90000\r\na=fmtp:97 apt=96\r\na=rtpmap:98 VP9/90000\r\na=rtcp-fb:98 ccm fir\r\na=rtcp-fb:98 nack\r\na=rtcp-fb:98 nack pli\r\na=rtcp-fb:98 goog-remb\r\na=rtcp-fb:98 transport-cc\r\na=rtpmap:99 rtx/90000\r\na=fmtp:99 apt=98\r\na=rtpmap:100 red/90000\r\na=rtpmap:101 rtx/90000\r\na=fmtp:101 apt=100\r\na=rtpmap:127 ulpfec/90000\r\nm=audio 9 UDP/TLS/RTP/SAVPF 111 103 104 9 0 8 106 105 13 110 112 113 126\r\nc=IN IP4 0.0.0.0\r\na=rtcp:9 IN IP4 0.0.0.0\r\na=ice-ufrag:I5v3\r\na=ice-pwd:r+w1c6kV+e2j7GqRfdZqS+wq\r\na=fingerprint:sha-256 AA:CF:6A:FC:DB:C7:E0:63:C8:C8:FE:79:9F:18:5F:A1:79:43:D9:09:91:45:0A:28:7F:EF:4E:9E:40:9A:45:8D\r\na=setup:active\r\na=mid:1\r\na=extmap:1 urn:ietf:params:rtp-hdrext:ssrc-audio-level\r\na=recvonly\r\na=rtcp-mux\r\na=rtpmap:111 opus/48000/2\r\na=rtcp-fb:111 transport-cc\r\na=fmtp:111 minptime=10;useinbandfec=1\r\na=rtpmap:103 ISAC/16000\r\na=rtpmap:104 ISAC/32000\r\na=rtpmap:9 G722/8000\r\na=rtpmap:0 PCMU/8000\r\na=rtpmap:8 PCMA/8000\r\na=rtpmap:106 CN/32000\r\na=rtpmap:105 CN/16000\r\na=rtpmap:13 CN/8000\r\na=rtpmap:110 telephone-event/48000\r\na=rtpmap:112 telephone-event/32000\r\na=rtpmap:113 telephone-event/16000\r\na=rtpmap:126 telephone-event/8000\r\nm=application 9 DTLS/SCTP 5000\r\nc=IN IP4 0.0.0.0\r\nb=AS:30\r\na=ice-ufrag:I5v3\r\na=ice-pwd:r+w1c6kV+e2j7GqRfdZqS+wq\r\na=fingerprint:sha-256 AA:CF:6A:FC:DB:C7:E0:63:C8:C8:FE:79:9F:18:5F:A1:79:43:D9:09:91:45:0A:28:7F:EF:4E:9E:40:9A:45:8D\r\na=setup:active\r\na=mid:2\r\na=sctpmap:5000 webrtc-datachannel 1024\r\n"}
Then whole process fail on ICE connection. The sides can't set proper ice candidates. But after connected the devices to the same local wifi network webrtc started gathering new ice candidates and peer connection succeed. I would establish connection using USB TCP/IP way only.
Can someone point me what I am doing wrong?
You'll need to forward UDP and convince the software to generate the correct sdp (or edit it yourself).
Or you can set up a TURN server.

obexftp -l fails, return code 81

I am currently attempting to use obex tools to browse (and later mount) the file system of an Android device (7.1.1). When I try to list using obexftp -l, it simply returns nothing. I have tried almost every possible combination of file parameters after -l, but still get the same error. My end goal is to use obexfs to mount, but feel this is an intermediate stepping stone. Details below.
uname -r: 3.14.2-xilinx
bluetoothd -v: 4.101
bluetoothctl -v 5.47
lsusb: Bus 001 Device 004: ID 0a5c:21e8 Broadcom Corp. BCM20702A0 Bluetooth 4.0
hcitool dev: hci0 5C:F3:70:82:XX:XX
hciconfig -a:
hci0: Type: BR/EDR Bus: USB
BD Address: 5C:F3:70:82:XX:XX ACL MTU: 1021:8 SCO MTU: 64:1
UP RUNNING PSCAN ISCAN
RX bytes:13146 acl:211 sco:0 events:382 errors:0
TX bytes:6265 acl:219 sco:0 commands:149 errors:0
Features: 0xbf 0xfe 0xcf 0xfe 0xdb 0xff 0x7b 0x87
Packet type: DM1 DM3 DM5 DH1 DH3 DH5 HV1 HV2 HV3
Link policy: RSWITCH SNIFF
Link mode: SLAVE ACCEPT
Name: '312_BT-0'
Class: 0x000100
Service Classes: Unspecified
Device Class: Computer, Uncategorized
HCI Version: 4.0 (0x6) Revision: 0x1000
LMP Version: 4.0 (0x6) Subversion: 0x220e
Manufacturer: Broadcom Corporation (15)
Succesful file push from Linux device to Android device:
obexftp -b D4:63:C6:XX:XX:XX -B 6 -U none -p /home/root/test.txt
Suppressing FBS.
Connecting..\done
Sending "/home/root/test.txt".../done
Disconnecting..-done
Attempting to list file structure on Android device:
obexftp -b D4:63:C6:XX:XX:XX -B 6 -U none -l
Suppressing FBS.
Connecting..\done
Receiving "(null)"...|failed: (null)
The operation failed with return code 81
Disconnecting../done
Output of btmon when attempting above obexftp -l command:
= New Index: 5C:F3:70:82:XX:XX (Primary,USB,hci0) [hci0] 0.316536
< HCI Command: Create Connection (0x01|0x0005) plen 13 #1 [hci0] 3.563946
Address: D4:63:C6:XX:XX:XX (OUI D4-63-C6)
Packet type: 0xcc18
DM1 may be used
DH1 may be used
DM3 may be used
DH3 may be used
DM5 may be used
DH5 may be used
Page scan repetition mode: R2 (0x02)
Page scan mode: Mandatory (0x00)
Clock offset: 0x0000
Role switch: Allow slave (0x01)
> HCI Event: Command Status (0x0f) plen 4 #2 [hci0] 3.565628
Create Connection (0x01|0x0005) ncmd 1
Status: Success (0x00)
> HCI Event: Role Change (0x12) plen 8 #3 [hci0] 5.392513
Status: Success (0x00)
Address: D4:63:C6:XX:XX:XX (OUI D4-63-C6)
Role: Slave (0x01)
> HCI Event: Connect Complete (0x03) plen 11 #4 [hci0] 5.414518
Status: Success (0x00)
Handle: 11
Address: D4:63:C6:XX:XX:XX (OUI D4-63-C6)
Link type: ACL (0x01)
Encryption: Disabled (0x00)
< HCI Command: Read Remote Supported Features (0x01|0x001b) plen 2 #5 [hci0] 5.414709
Handle: 11
> HCI Event: Command Status (0x0f) plen 4 #6 [hci0] 5.415523
Read Remote Supported Features (0x01|0x001b) ncmd 1
Status: Success (0x00)
> HCI Event: Max Slots Change (0x1b) plen 3 #7 [hci0] 5.425523
Handle: 11
Max slots: 5
> HCI Event: Link Supervision Timeout Changed (0x38) plen 4 #8 [hci0] 5.429522
Handle: 11
Timeout: 5000.000 msec (0x1f40)
> ACL Data RX: Handle 11 flags 0x02 dlen 10 #9 [hci0] 5.432524
L2CAP: Information Request (0x0a) ident 2 len 2
Type: Extended features supported (0x0002)
< ACL Data TX: Handle 11 flags 0x00 dlen 16 #10 [hci0] 5.432580
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: Read Remote Supported Features (0x0b) plen 11 #11 [hci0] 5.438528
Status: Success (0x00)
Handle: 11
Features: 0xff 0xfe 0x8f 0xfe 0xd8 0x3f 0x5b 0x87
3 slot packets
5 slot packets
Encryption
Slot offset
Timing accuracy
Role switch
Hold mode
Sniff mode
Power control requests
Channel quality driven data rate (CQDDR)
SCO link
HV2 packets
HV3 packets
u-law log synchronous data
A-law log synchronous data
CVSD synchronous data
Paging parameter negotiation
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)
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
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 #12 [hci0] 5.438569
Handle: 11
Page: 1
> ACL Data RX: Handle 11 flags 0x02 dlen 10 #13 [hci0] 5.438782
L2CAP: Information Request (0x0a) ident 3 len 2
Type: Fixed channels supported (0x0003)
< ACL Data TX: Handle 11 flags 0x00 dlen 20 #14 [hci0] 5.438818
L2CAP: Information Response (0x0b) ident 3 len 12
Type: Fixed channels supported (0x0003)
Result: Success (0x0000)
Channels: 0x0000000000000006
L2CAP Signaling (BR/EDR)
Connectionless reception
> HCI Event: Command Status (0x0f) plen 4 #15 [hci0] 5.440527
Read Remote Extended Features (0x01|0x001c) ncmd 1
Status: Success (0x00)
> HCI Event: Number of Completed Packets (0x13) plen 5 #16 [hci0] 5.443529
Num handles: 1
Handle: 11
Count: 2
> HCI Event: Read Remote Extended Features (0x23) plen 13 #17 [hci0] 5.444528
Status: Success (0x00)
Handle: 11
Page: 1/1
Features: 0x0f 0x00 0x00 0x00 0x00 0x00 0x00 0x00
Secure Simple Pairing (Host Support)
LE Supported (Host)
Simultaneous LE and BR/EDR (Host)
Secure Connections (Host Support)
< HCI Command: Remote Name Request (0x01|0x0019) plen 10 #18 [hci0] 5.444573
Address: D4:63:C6:XX:XX:XX (OUI D4-63-C6)
Page scan repetition mode: R2 (0x02)
Page scan mode: Mandatory (0x00)
Clock offset: 0x0000
> HCI Event: Command Status (0x0f) plen 4 #19 [hci0] 5.445529
Remote Name Request (0x01|0x0019) ncmd 1
Status: Success (0x00)
> HCI Event: Remote Name Req Complete (0x07) plen 255 #20 [hci0] 5.465535
Status: Success (0x00)
Address: D4:63:C6:XX:XX:XX (OUI D4-63-C6)
Name: Moto E (4)
< HCI Command: Authentication Requested (0x01|0x0011) plen 2 #21 [hci0] 5.465591
Handle: 11
Device Connected: D4:63:C6:XX:XX:XX (0) flags 0x0000
0b 09 4d 6f 74 6f 20 45 20 28 34 29 04 0d 0c 02 ..Moto E (4)....
5a Z
> HCI Event: Command Status (0x0f) plen 4 #22 [hci0] 5.466545
Authentication Requested (0x01|0x0011) ncmd 1
Status: Success (0x00)
> HCI Event: Link Key Request (0x17) plen 6 #23 [hci0] 5.467541
Address: D4:63:C6:XX:XX:XX (OUI D4-63-C6)
< HCI Command: Link Key Request Reply (0x01|0x000b) plen 22 #24 [hci0] 5.467588
Address: D4:63:C6:XX:XX:XX (OUI D4-63-C6)
Link key: b0912a0c42db7615860023aa911d552b
> HCI Event: Command Complete (0x0e) plen 10 #25 [hci0] 5.470540
Link Key Request Reply (0x01|0x000b) ncmd 1
Status: Success (0x00)
Address: D4:63:C6:XX:XX:XX (OUI D4-63-C6)
> HCI Event: Auth Complete (0x06) plen 3 #26 [hci0] 5.489555
Status: Success (0x00)
Handle: 11
< HCI Command: Set Connection Encryption (0x01|0x0013) plen 3 #27 [hci0] 5.489604
Handle: 11
Encryption: Enabled (0x01)
> HCI Event: Command Status (0x0f) plen 4 #28 [hci0] 5.490550
Set Connection Encryption (0x01|0x0013) ncmd 1
Status: Success (0x00)
> HCI Event: Encryption Change (0x08) plen 4 #29 [hci0] 5.532580
Status: Success (0x00)
Handle: 11
Encryption: Enabled with E0 (0x01)
< ACL Data TX: Handle 11 flags 0x00 dlen 10 #30 [hci0] 5.532645
L2CAP: Information Request (0x0a) ident 1 len 2
Type: Extended features supported (0x0002)
> ACL Data RX: Handle 11 flags 0x02 dlen 16 #31 [hci0] 5.562719
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 #32 [hci0] 5.562780
L2CAP: Information Request (0x0a) ident 2 len 2
Type: Fixed channels supported (0x0003)
> HCI Event: Number of Completed Packets (0x13) plen 5 #33 [hci0] 5.565591
Num handles: 1
Handle: 11
Count: 2
> ACL Data RX: Handle 11 flags 0x02 dlen 20 #34 [hci0] 5.566462
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)
< ACL Data TX: Handle 11 flags 0x00 dlen 12 #35 [hci0] 5.566511
L2CAP: Connection Request (0x02) ident 3 len 4
PSM: 3 (0x0003)
Source CID: 64
> ACL Data RX: Handle 11 flags 0x02 dlen 16 #36 [hci0] 5.570089
L2CAP: Connection Response (0x03) ident 3 len 8
Destination CID: 67
Source CID: 64
Result: Connection successful (0x0000)
Status: No further information available (0x0000)
< ACL Data TX: Handle 11 flags 0x00 dlen 27 #37 [hci0] 5.570138
L2CAP: Configure Request (0x04) ident 4 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 #38 [hci0] 5.571470
L2CAP: Configure Request (0x04) ident 4 len 8
Destination CID: 64
Flags: 0x0000
Option: Maximum Transmission Unit (0x01) [mandatory]
MTU: 1691
< ACL Data TX: Handle 11 flags 0x00 dlen 18 #39 [hci0] 5.571521
L2CAP: Configure Response (0x05) ident 4 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 #40 [hci0] 5.573594
Num handles: 1
Handle: 11
Count: 2
> ACL Data RX: Handle 11 flags 0x02 dlen 14 #41 [hci0] 5.573967
L2CAP: Configure Response (0x05) ident 4 len 6
Source CID: 64
Flags: 0x0000
Result: Success (0x0000)
< ACL Data TX: Handle 11 flags 0x00 dlen 8 #42 [hci0] 5.574064
Channel: 67 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
> HCI Event: Number of Completed Packets (0x13) plen 5 #43 [hci0] 5.577595
Num handles: 1
Handle: 11
Count: 2
> ACL Data RX: Handle 11 flags 0x02 dlen 8 #44 [hci0] 5.577612
Channel: 64 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 18 #45 [hci0] 5.577681
Channel: 67 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 12 frame_type 0 credit_flow 15 pri 7
ack_timer 0 frame_size 1008 max_retrans 0 credits 7
> ACL Data RX: Handle 11 flags 0x02 dlen 18 #46 [hci0] 5.581473
Channel: 64 len 14 [PSM 3 mode 0] {chan 0}
RFCOMM: Unnumbered Info with Header Check (UIH) (0xef)
Address: 0x01 cr 0 dlci 0x00
Control: 0xef poll/final 0
Length: 10
FCS: 0xaa
MCC Message type: DLC Parameter Negotiation RSP (0x20)
Length: 8
dlci 12 frame_type 0 credit_flow 14 pri 7
ack_timer 0 frame_size 990 max_retrans 0 credits 7
< ACL Data TX: Handle 11 flags 0x00 dlen 8 #47 [hci0] 5.581541
Channel: 67 len 4 [PSM 3 mode 0] {chan 0}
RFCOMM: Set Async Balance Mode (SABM) (0x2f)
Address: 0x33 cr 1 dlci 0x0c
Control: 0x3f poll/final 1
Length: 0
FCS: 0x43
> HCI Event: Number of Completed Packets (0x13) plen 5 #48 [hci0] 5.584597
Num handles: 1
Handle: 11
Count: 2
> ACL Data RX: Handle 11 flags 0x02 dlen 8 #49 [hci0] 5.585096
Channel: 64 len 4 [PSM 3 mode 0] {chan 0}
RFCOMM: Unnumbered Ack (UA) (0x63)
Address: 0x33 cr 1 dlci 0x0c
Control: 0x73 poll/final 1
Length: 0
FCS: 0x88
< ACL Data TX: Handle 11 flags 0x00 dlen 12 #50 [hci0] 5.585552
Channel: 67 len 8 [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: 4
FCS: 0x70
MCC Message type: Modem Status Command CMD (0x38)
Length: 2
dlci 12
fc 0 rtc 1 rtr 1 ic 0 dv 1
> ACL Data RX: Handle 11 flags 0x02 dlen 12 #51 [hci0] 5.591479
Channel: 64 len 8 [PSM 3 mode 0] {chan 0}
RFCOMM: Unnumbered Info with Header Check (UIH) (0xef)
Address: 0x01 cr 0 dlci 0x00
Control: 0xef poll/final 0
Length: 4
FCS: 0xaa
MCC Message type: Modem Status Command RSP (0x38)
Length: 2
dlci 12
fc 0 rtc 1 rtr 1 ic 0 dv 1
> ACL Data RX: Handle 11 flags 0x02 dlen 12 #52 [hci0] 5.592601
Channel: 64 len 8 [PSM 3 mode 0] {chan 0}
RFCOMM: Unnumbered Info with Header Check (UIH) (0xef)
Address: 0x01 cr 0 dlci 0x00
Control: 0xef poll/final 0
Length: 4
FCS: 0xaa
MCC Message type: Modem Status Command CMD (0x38)
Length: 2
dlci 12
fc 0 rtc 1 rtr 1 ic 0 dv 1
< ACL Data TX: Handle 11 flags 0x00 dlen 12 #53 [hci0] 5.592664
Channel: 67 len 8 [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: 4
FCS: 0x70
MCC Message type: Modem Status Command RSP (0x38)
Length: 2
dlci 12
fc 0 rtc 1 rtr 1 ic 0 dv 1
< ACL Data TX: Handle 11 flags 0x00 dlen 9 #54 [hci0] 5.592678
Channel: 67 len 5 [PSM 3 mode 0] {chan 0}
RFCOMM: Unnumbered Info with Header Check (UIH) (0xef)
Address: 0x33 cr 1 dlci 0x0c
Control: 0xff poll/final 1
Length: 0
FCS: 0x53
Credits: 33
53 S
< ACL Data TX: Handle 11 flags 0x00 dlen 15 #55 [hci0] 5.592688
Channel: 67 len 11 [PSM 3 mode 0] {chan 0}
RFCOMM: Unnumbered Info with Header Check (UIH) (0xef)
Address: 0x33 cr 1 dlci 0x0c
Control: 0xef poll/final 0
Length: 7
FCS: 0x4f
80 00 07 10 00 04 00 4f .......O
> HCI Event: Number of Completed Packets (0x13) plen 5 #56 [hci0] 5.595604
Num handles: 1
Handle: 11
Count: 2
> HCI Event: Number of Completed Packets (0x13) plen 5 #57 [hci0] 5.598602
Num handles: 1
Handle: 11
Count: 2
> ACL Data RX: Handle 11 flags 0x02 dlen 21 #58 [hci0] 5.601479
Channel: 64 len 17 [PSM 3 mode 0] {chan 0}
RFCOMM: Unnumbered Info with Header Check (UIH) (0xef)
Address: 0x31 cr 0 dlci 0x0c
Control: 0xff poll/final 1
Length: 12
FCS: 0x89
Credits: 4
a0 00 0c 10 00 04 00 cb 00 00 00 01 89 .............
< ACL Data TX: Handle 11 flags 0x00 dlen 41 #59 [hci0] 5.601739
Channel: 67 len 37 [PSM 3 mode 0] {chan 0}
RFCOMM: Unnumbered Info with Header Check (UIH) (0xef)
Address: 0x33 cr 1 dlci 0x0c
Control: 0xef poll/final 0
Length: 33
FCS: 0x4f
83 00 21 cb 00 00 00 01 42 00 19 78 2d 6f 62 65 ..!.....B..x-obe
78 2f 66 6f 6c 64 65 72 2d 6c 69 73 74 69 6e 67 x/folder-listing
00 4f .O
> ACL Data RX: Handle 11 flags 0x02 dlen 17 #60 [hci0] 5.612611
Channel: 64 len 13 [PSM 3 mode 0] {chan 0}
RFCOMM: Unnumbered Info with Header Check (UIH) (0xef)
Address: 0x31 cr 0 dlci 0x0c
Control: 0xff poll/final 1
Length: 8
FCS: 0x89
Credits: 1
d1 00 08 cb 00 00 00 01 89 .........
< ACL Data TX: Handle 11 flags 0x00 dlen 16 #61 [hci0] 5.613075
Channel: 67 len 12 [PSM 3 mode 0] {chan 0}
RFCOMM: Unnumbered Info with Header Check (UIH) (0xef)
Address: 0x33 cr 1 dlci 0x0c
Control: 0xef poll/final 0
Length: 8
FCS: 0x4f
81 00 08 cb 00 00 00 01 4f ........O
> HCI Event: Number of Completed Packets (0x13) plen 5 #62 [hci0] 5.618623
Num handles: 1
Handle: 11
Count: 2
> ACL Data RX: Handle 11 flags 0x02 dlen 17 #63 [hci0] 5.623869
Channel: 64 len 13 [PSM 3 mode 0] {chan 0}
RFCOMM: Unnumbered Info with Header Check (UIH) (0xef)
Address: 0x31 cr 0 dlci 0x0c
Control: 0xff poll/final 1
Length: 8
FCS: 0x89
Credits: 1
a0 00 08 cb 00 00 00 01 89 .........
< ACL Data TX: Handle 11 flags 0x00 dlen 8 #64 [hci0] 5.624057
Channel: 67 len 4 [PSM 3 mode 0] {chan 0}
RFCOMM: Disconnect (DISC) (0x43)
Address: 0x33 cr 1 dlci 0x0c
Control: 0x53 poll/final 1
Length: 0
FCS: 0xa2
> ACL Data RX: Handle 11 flags 0x02 dlen 8 #65 [hci0] 5.628872
Channel: 64 len 4 [PSM 3 mode 0] {chan 0}
RFCOMM: Unnumbered Ack (UA) (0x63)
Address: 0x33 cr 1 dlci 0x0c
Control: 0x73 poll/final 1
Length: 0
FCS: 0x88
< ACL Data TX: Handle 11 flags 0x00 dlen 8 #66 [hci0] 5.628967
Channel: 67 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
> HCI Event: Number of Completed Packets (0x13) plen 5 #67 [hci0] 5.632625
Num handles: 1
Handle: 11
Count: 2
> ACL Data RX: Handle 11 flags 0x02 dlen 8 #68 [hci0] 5.632644
Channel: 64 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 #69 [hci0] 5.632733
L2CAP: Disconnection Request (0x06) ident 5 len 4
Destination CID: 67
Source CID: 64
> ACL Data RX: Handle 11 flags 0x02 dlen 12 #70 [hci0] 5.637623
L2CAP: Disconnection Response (0x07) ident 5 len 4
Destination CID: 67
Source CID: 64
> HCI Event: Number of Completed Packets (0x13) plen 5 #71 [hci0] 5.863739
Num handles: 1
Handle: 11
Count: 1
< HCI Command: Disconnect (0x01|0x0006) plen 3 #72 [hci0] 7.631380
Handle: 11
Reason: Remote User Terminated Connection (0x13)
> HCI Event: Command Status (0x0f) plen 4 #73 [hci0] 7.632590
Disconnect (0x01|0x0006) ncmd 1
Status: Success (0x00)
> HCI Event: Disconnect Complete (0x05) plen 4 #74 [hci0] 7.727640
Status: Success (0x00)
Handle: 11
Reason: Connection Terminated By Local Host (0x16)
Device Disconnected: D4:63:C6:XX:XX:XX (0) reason 2
After continuing to try many different things, I realized that is was more than likely the Android device having the issue. The solution is that the Android device needs to have an FTP Service running in order to utilize obexftp -l or obexfs. I achieved this by installing ES File Explorer on the Android device and selecting 'bluetooth' under the 'Network' tab. This opens an Obex FTP path on Bluetooth channel 20. The code below now functions; as well as obexfs.
obexftp -b D4:63:C6:XX:XX:XX -B 20 -U none -l

Bluetooth connection lost issue

This is not really something I'm developing, more like something I'm trying to debug. For some reason my HTC Desire HD keeps disconnecting from my car's bluetooth. It worked fine on phone's original rom, then I upgraded to Gingerbread (HTC rom) and it started to disconnect. I'm not sure what happened next (possibly I've installed something? mb the car's computer was reset as I had a service?) but it actually started to work after a few months and all was good until I upgraded again to 2.3.5 (HTC official upgrade). The phone connects to my car without any issues, then looses the connection within a minute and will not reconnect until the phone or the car's restarted. Here's some log data that I was able to collect in case someone might be familiar with how the bluetooth works on android:
I//system/bin/btld(23506): ##### USERIAL_Ioctl: BT_Sleep, USERIAL_IO_BT_WAKE_DEASSERT ####
W/ (23507): bta_dm_pm_timer_cback 0x255fa4
W/ (23507): dm_pm_timer expires 0
W/ (23507): proc dm_pm_timer expires
I//system/bin/btld(23506): ##### USERIAL_Ioctl: BT_Wake, USERIAL_IO_BT_WAKE_ASSERT ####
I/PTIM (23507): Call GKI_add_to_timer_list in ptim_start_timer
W/ (23507): start dm_pm_timer:0, 5000
D/dalvikvm(23586): GC_CONCURRENT freed 381K, 48% free 3295K/6279K, external 0K/0K, paused 2ms+3ms
I/keystore( 1264): uid: 1000 action: e -> 7 state: 1 -> 1 retry: 4
I/BtAtPhonebook( 1631): Refreshed phonebook ME with 255 results
I/keystore( 1264): uid: 1000 action: e -> 7 state: 1 -> 1 retry: 4
I/BtAtPhonebook( 1631): Refreshed phonebook ME with 255 results
D/dalvikvm(15887): GC_EXPLICIT freed 124K, 44% free 4129K/7303K, external 0K/512K, paused 79ms
I//system/bin/btld(23506): ##### USERIAL_Ioctl: BT_Sleep, USERIAL_IO_BT_WAKE_DEASSERT ####
W/ (23507): stop dm_pm_timer:0
W/HeadsetBase.cpp( 1631): RFCOMM poll() returned success (1), but with an unexpected revents bitmask: 0x11
I/HeadsetBase( 1631): headset read error 5
I//system/bin/btld(23506): send_ctrl_msg: [BTL_IFS CTRL] send BTLIF_DISCONNECT_IND (AG) 8 pbytes (hdl 18)
I//system/bin/btld(23506): BTL_IF_DisconnectDatapath: Disconnect datapath on handle 21
I//system/bin/btld(23506): wrp_setup_rxflow: wrp_setup_rxflow : 0 (fd 21)
I//system/bin/btld(23506): wsactive_del: delete wsock 21 from active list [212ef8]
I//system/bin/btld(23506): wrp_close_data: wrp_close 21 [brcm.bt.btlif]
I//system/bin/btld(23506): wsactive_del: delete wsock 21 from active list [212ef8]
I/BTL_IFC ( 1631): btl_ifc_ctrl_rx: [BTL_IFC CTRL] recv BTLIF_DISCONNECT_IND (AG) 10 pbytes (hdl 92)
D/BLZ_WRAPPER( 1631): blz_ctrl_msg: [blz ctrl] received message [BTLIF_DISCONNECT_IND]
D/BLZ_WRAPPER( 1631): blz_ctrl_msg: Channel disconnected remotely, rf_ch 65535
I/BTL_IFC_WRP( 1631): wrp_find_wsock_by_rfhdl: wrp_find_wsock_by_rfhdl : no entry found, lst 0, rfchan 65535
I/BLZ_WRAPPER( 1631): btl_if_close: btl_if_close (105)
D/BLZ_WRAPPER( 1631): btl_if_close: [btl_if_close] : (105:100), disc_pending 0, asnc 0, selct 0, flags 2
I/BTL_IFC ( 1631): send_ctrl_msg: [BTL_IFC CTRL] send BTLIF_DISCONNECT_REQ (AG) 8 pbytes (hdl 92)
W/ (23507): Could not find conn_info for chdl=0x3
D/BluetoothHeadsetService( 1631): Device: 00:13:A9:A1:19:1E Headset state 2 -> 0, result = 0
W/ (23507): BTA_DM_LINK_DOWN_EVT::bdaddr 00:13:a9:a1:19:1e reason x15
D/DTUN_HCID4(23540): dtun_dm_sig_link_down()
I/DTUN_HCID4(23540): dtun_dm_sig_link_down device = 0xf750 handle = 256 reason = 0x15
I//system/bin/btld(23506): send_ctrl_msg: [BTL_IFS CTRL] send BTLIF_DTUN_SIGNAL_EVT (CTRL) 11 pbytes (hdl 17)
D/BTL_IFC_WRP( 1631): wrp_close_s_only: wrp_close_s_only [105] (105:100) [brcm.bt.btlif]
D/BTL_IFC_WRP( 1631): wrp_close_s_only: data socket closed
D/BTL_IFC_WRP( 1631): wsactive_del: delete wsock 105 from active list [ad3ca3c0]
I/DTUN_HCID4(23540): [embedded]LINK_DOWN name = UHP, address = 00:13:A9:A1:19:1E, reason = 0x15
D/BluetoothService( 1379): Device property changed:00:13:A9:A1:19:1E property:Connected
I/BluetoothHeadsetService( 1631): [embedded] HSP/HFP state : address: 00:13:A9:A1:19:1E name: UHP State:2->0
I/BTL_IFC ( 1631): send_ctrl_msg: [BTL_IFC CTRL] send BTLIF_DISCONNECT_REQ (SCO) 0 pbytes (hdl 102)
W/ (23507): Could not find conn_info with active SCO
I/BluetoothA2dpService( 1379): BluetoothHeadset disconnected, remove AV CONNECT_TO msg
I/StatusBarPolicy( 1577): updateBluetooth bt icon:true,HS:0,A2DP:false
D/AudioPolicyManagerBase( 1260): setDeviceConnectionState() device: 40, state 0, address 00:13:A9:A1:19:1E
I/AudioPolicyManagerBase( 1260): setOutputDevice() output 4 device 0 delayMs 0
I/AudioPolicyManagerBase( 1260): setOutputDevice() setting same device 0 or null device for output 4
I/BluetoothDeviceProfileState( 1379): Entering IncomingHandsfree state with: 6
I/BluetoothDeviceProfileState( 1379): Processing command:6
I/BluetoothDeviceProfileState( 1379): Entering ACL Connected state with: 102
I/NaviReceiver(23556): Got BluetoothHeadset.ACTION_STATE_CHANGED
I/NaviReceiver(23556): conn state = 0

Categories

Resources