I'm trying to use my Raspberry Pi 3B to communicate with a BLE enabled device which dosen't require a PIN.
I first tried with Ionic on iOS using cordova BLE central (https://github.com/don/cordova-plugin-ble-central), which worked as expected, here is the exchanged packets :
iOS (PacketLogger)
May 21 07:59:36.825 Note 0x0000 Product: iPhone9,3
May 21 07:59:36.825 Note 0x0000 Software: Version 13.4 (Build 17E255)
May 21 08:09:42.178 Config 0x0041 315X Connected: C4:64:E3:9B:04:44 - Handle: 0x41 - 315X - C7D0F30E-78B4-C82C-6912-DD0F5A5BCA2E
May 21 08:09:43.690 HCI Command 0x0041 00:00:00:00:00:00 Disconnect - Connection Handle: 0x0041 - Reason: Remote User Terminated Connection
May 21 08:09:43.690 Power 0x0000 H4 wake
May 21 08:09:43.690 HCI Event 0x0000 Command Status - Disconnect
May 21 08:09:43.705 LMP Sent 0x0041 00:00:00:00:00:00 LE Terminate Indicator - Error: 0x13
May 21 08:09:43.706 HCI Event 0x0041 00:00:00:00:00:00 Disconnection Complete - Success
May 21 08:09:43.710 Config 0x0000 (
May 21 08:09:43.710 Config 0x0000 Invalid packet
May 21 08:09:43.710 Config 0x0000 (
May 21 08:09:43.710 Config 0x0000 Invalid packet
May 21 08:09:43.710 Config 0x0000 Invalid packet
May 21 08:09:43.710 Config 0x0000 Invalid packet
May 21 08:09:43.891 Power 0x0000 H4 sleep
May 21 08:09:47.801 HCI Command 0x0000 LE Set Scan Enable - 0x00, Filter Duplicates: 1
May 21 08:09:47.801 Power 0x0000 H4 wake
May 21 08:09:47.803 HCI Event 0x0000 Command Complete [200C] - LE Set Scan Enable
May 21 08:09:47.803 HCI Command 0x0000 Vendor Specific Command
May 21 08:09:47.804 HCI Event 0x0000 Command Complete [FCE9] -
May 21 08:09:47.804 HCI Command 0x0000 Vendor Specific Command
May 21 08:09:47.804 HCI Event 0x0000 Command Complete [FCE9] -
May 21 08:09:47.804 HCI Command 0x0000 Vendor Specific Command
May 21 08:09:47.804 HCI Event 0x0000 Command Complete [FCE9] -
May 21 08:09:47.804 HCI Command 0x0000 Vendor Specific Command
May 21 08:09:47.805 HCI Event 0x0000 Command Complete [FCE9] -
May 21 08:09:47.805 HCI Command 0x0000 LE Set Scan Parameters - Active - 30/40 (ms)
May 21 08:09:47.805 HCI Event 0x0000 Command Complete [200B] - LE Set Scan Parameters
May 21 08:09:47.805 HCI Command 0x0000 LE Set Scan Enable - 0x01, Filter Duplicates: 1
May 21 08:09:47.805 HCI Event 0x0000 Command Complete [200C] - LE Set Scan Enable
May 21 08:09:47.808 HCI Event 0x0000 315X LE - Advertising Report - 1 Report - Normal - Public - C4:64:E3:9B:04:44 -59 dBm - Channel 37
May 21 08:09:47.809 HCI Event 0x0000 315X LE - Advertising Report - 1 Report - Normal - Public - C4:64:E3:9B:04:44 -60 dBm - Manufacturer Specific Data - 315X - Channel 37
May 21 08:09:48.006 Power 0x0000 H4 sleep
May 21 08:09:48.636 HCI Command 0x0000 315X LE Add Device To White List - Public - C4:64:E3:9B:04:44
May 21 08:09:48.636 Power 0x0000 H4 wake
May 21 08:09:48.636 HCI Event 0x0000 Command Complete [2011] - LE Add Device To White List
May 21 08:09:48.643 HCI Command 0x0000 LE Create Connection - 00:00:00:00:00:00, Scan Window/Interval: 30ms/30ms, Min/Max Conn Interval: 10ms/30ms
May 21 08:09:48.647 HCI Event 0x0000 Command Status - LE Create Connection
May 21 08:09:48.701 HCI Event 0x0000 315X LE - Advertising Report - 1 Report - Normal - Public - C4:64:E3:9B:04:44 -57 dBm - Channel 38/37
May 21 08:09:48.702 HCI Event 0x0041 315X LE - Enhanced Connection Complete - Master - Public - C4:64:E3:9B:04:44 local - 00:00:00:00:00:00 peer - 00:00:00:00:00:00 - Conn Interval: 30 ms
May 21 08:09:48.704 HCI Command 0x0000 315X LE Remove Device From White List - 0 - C4:64:E3:9B:04:44
May 21 08:09:48.704 HCI Event 0x0000 Command Complete [2012] - LE Remove Device From White List
May 21 08:09:48.704 HCI Command 0x0000 Vendor Specific Command
May 21 08:09:48.704 HCI Event 0x0000 Command Complete [FDC1] -
May 21 08:09:48.706 HCI Command 0x0041 315X LE Start Encryption - Connection Handle: 0x0041
May 21 08:09:48.706 HCI Event 0x0000 Command Status - LE Start Encryption
May 21 08:09:48.712 LMP Sent 0x0041 315X LE Version Indicator
May 21 08:09:48.741 LMP Received 0x0041 315X LE Version Indicator
May 21 08:09:48.772 LMP Sent 0x0041 315X LE Encryption Request
May 21 08:09:48.801 LMP Received 0x0041 315X LE Encryption Response
May 21 08:09:48.861 LMP Received 0x0041 315X LE Start Encryption Request
May 21 08:09:48.891 LMP Sent 0x0041 315X LE Start Encryption Response
May 21 08:09:48.922 HCI Event 0x0041 315X Encryption Change Complete - Encryption Enabled
May 21 08:09:48.922 HCI Command 0x0041 315X Read Remote Version Information - Connection Handle: 0x0041
May 21 08:09:48.922 LMP Received 0x0041 315X LE Start Encryption Response
May 21 08:09:48.922 HCI Event 0x0000 Command Status - Read Remote Version Information
May 21 08:09:48.922 HCI Event 0x0041 315X Read Remote Version Information Complete
May 21 08:09:48.922 HCI Command 0x0041 315X LE Read Remote Used Features - Connection Handle: 0x0041
May 21 08:09:48.922 HCI Event 0x0000 Command Status - LE Read Remote Used Features
May 21 08:09:48.923 HCI Command 0x0000 Vendor Specific Command
May 21 08:09:48.923 HCI Event 0x0000 Command Complete [FD82] -
May 21 08:09:48.952 LMP Sent 0x0041 315X LE Feature Request - Feature Set: 0x00000000000000FD
May 21 08:09:48.982 HCI Event 0x0041 315X LE - Read Remote Used Features Complete - DPLE Supported
May 21 08:09:48.982 LMP Received 0x0041 315X LE Feature Response - Feature Set: 0x00000000000000FD
May 21 08:09:49.012 LMP Sent 0x0041 315X LE Length Request
May 21 08:09:49.042 HCI Event 0x0041 315X LE - Data Length Change
May 21 08:09:49.042 LMP Received 0x0041 315X LE Length Response
May 21 08:09:49.044 ATT Send 0x0041 315X Exchange MTU Request - MTU: 185
May 21 08:09:49.101 ATT Receive 0x0041 315X Exchange MTU Response - MTU: 65
May 21 08:09:49.102 Config 0x0000 A(
May 21 08:09:49.102 Config 0x0000 Invalid packet
May 21 08:09:49.102 Config 0x0000 A(
May 21 08:09:49.102 Config 0x0000 Invalid packet
May 21 08:09:49.102 Config 0x0000 Invalid packet
May 21 08:09:49.102 Config 0x0000 Invalid packet
May 21 08:09:49.102 ATT Send 0x0041 315X Read By Type Request - Start Handle: 0x0008 - End Handle: 0x0008 - UUID: GATT Characteristic Declaration
May 21 08:09:49.130 HCI Event 0x0041 315X Number Of Completed Packets - Handle: 0x0041 - Packets: 0x0002
May 21 08:09:49.161 ATT Receive 0x0041 315X Error Response - Attribute Handle: 0x0008 - Error Code: Attribute Not Found (0x0A)
May 21 08:09:49.162 Config 0x0000 Invalid packet
May 21 08:09:49.162 Config 0x0000 Invalid packet
May 21 08:09:49.162 Config 0x0000 Invalid packet
May 21 08:09:49.162 Config 0x0000 Invalid packet
May 21 08:09:49.165 Config 0x0000 Invalid packet
May 21 08:09:49.165 Config 0x0000 Invalid packet
May 21 08:09:49.165 Config 0x0000 Invalid packet
May 21 08:09:49.165 Config 0x0000 Invalid packet
May 21 08:09:49.165 Config 0x0000 Invalid packet
May 21 08:09:49.165 Config 0x0000 Invalid packet
May 21 08:09:49.169 ATT Send 0x0041 315X Read Request - Handle:0x0012
May 21 08:09:49.222 ATT Receive 0x0041 315X Read Response - Value: 4175 746F 6D6F 7765 7200 0000 0000 0000 …
May 21 08:09:49.224 ATT Send 0x0041 315X Write Request - Handle:0x000F - Value: 0100
May 21 08:09:49.250 HCI Event 0x0041 315X Number Of Completed Packets - Handle: 0x0041 - Packets: 0x0002
May 21 08:09:49.281 ATT Receive 0x0041 315X Write Response
For raspberry I'm using noble (https://github.com/abandonware/noble), I'm able to discover device and read characteristics but look like the write commands dosen't work as expected.
hcidump
pi#raspberrypi:~ $ sudo hcidump -t -x
HCI sniffer - Bluetooth packet analyzer ver 5.50
device: hci0 snap_len: 1500 filter: 0xffffffff
2020-06-02 08:49:48.643635 < HCI Command: Set Event Mask (0x03|0x0001) plen 8
Mask: 0xfffffbff07f8bf3d
2020-06-02 08:49:48.644192 > HCI Event: Command Complete (0x0e) plen 4
Set Event Mask (0x03|0x0001) ncmd 1
status 0x00
2020-06-02 08:49:48.644641 < HCI Command: LE Set Event Mask (0x08|0x0001) plen 8
mask 0x1f00000000000000 (Reserved)
2020-06-02 08:49:48.645116 > HCI Event: Command Complete (0x0e) plen 4
LE Set Event Mask (0x08|0x0001) ncmd 1
status 0x00
2020-06-02 08:49:48.645147 < HCI Command: Read Local Version Information (0x04|0x0001) plen 0
2020-06-02 08:49:48.645641 > HCI Event: Command Complete (0x0e) plen 12
Read Local Version Information (0x04|0x0001) ncmd 1
status 0x00
HCI Version: 4.1 (0x7) HCI Revision: 0x1ed
LMP Version: 4.1 (0x7) LMP Subversion: 0x2209
Manufacturer: Broadcom Corporation (15)
2020-06-02 08:49:48.645672 < HCI Command: Write LE Host Supported (0x03|0x006d) plen 2
01 00
2020-06-02 08:49:48.646081 > HCI Event: Command Complete (0x0e) plen 4
Write LE Host Supported (0x03|0x006d) ncmd 1
00
2020-06-02 08:49:48.646264 < HCI Command: Read LE Host Supported (0x03|0x006c) plen 0
2020-06-02 08:49:48.646731 > HCI Event: Command Complete (0x0e) plen 6
Read LE Host Supported (0x03|0x006c) ncmd 1
00 01 00
2020-06-02 08:49:48.646767 < HCI Command: Read BD ADDR (0x04|0x0009) plen 0
2020-06-02 08:49:48.647206 > HCI Event: Command Complete (0x0e) plen 10
Read BD ADDR (0x04|0x0009) ncmd 1
status 0x00 bdaddr B8:27:EB:08:5F:F0
2020-06-02 08:49:48.654744 < HCI Command: LE Set Scan Enable (0x08|0x000c) plen 2
value 0x00 (scanning disabled)
filter duplicates 0x01 (enabled)
2020-06-02 08:49:48.655164 > HCI Event: Command Complete (0x0e) plen 4
LE Set Scan Enable (0x08|0x000c) ncmd 1
status 0x0c
Error: Command Disallowed
2020-06-02 08:49:48.655465 < HCI Command: LE Set Scan Parameters (0x08|0x000b) plen 7
type 0x01 (active)
interval 10.000ms window 10.000ms
own address: 0x00 (Public) policy: All
2020-06-02 08:49:48.655928 > HCI Event: Command Complete (0x0e) plen 4
LE Set Scan Parameters (0x08|0x000b) ncmd 1
status 0x00
2020-06-02 08:49:48.669824 < HCI Command: LE Set Scan Enable (0x08|0x000c) plen 2
value 0x00 (scanning disabled)
filter duplicates 0x01 (enabled)
2020-06-02 08:49:48.670225 > HCI Event: Command Complete (0x0e) plen 4
LE Set Scan Enable (0x08|0x000c) ncmd 1
status 0x0c
Error: Command Disallowed
2020-06-02 08:49:48.670261 < HCI Command: LE Set Scan Parameters (0x08|0x000b) plen 7
type 0x01 (active)
interval 10.000ms window 10.000ms
own address: 0x00 (Public) policy: All
2020-06-02 08:49:48.670716 > HCI Event: Command Complete (0x0e) plen 4
LE Set Scan Parameters (0x08|0x000b) ncmd 1
status 0x00
2020-06-02 08:49:48.670754 < HCI Command: LE Set Scan Enable (0x08|0x000c) plen 2
value 0x01 (scanning enabled)
filter duplicates 0x01 (enabled)
2020-06-02 08:49:48.671215 > HCI Event: Command Complete (0x0e) plen 4
LE Set Scan Enable (0x08|0x000c) ncmd 1
status 0x00
2020-06-02 08:49:48.842103 > HCI Event: LE Meta Event (0x3e) plen 27
LE Advertising Report
ADV_IND - Connectable undirected advertising (0)
bdaddr 9C:20:7B:BE:14:6E (Public)
Flags: 0x1a
Unknown type 0xff with 10 bytes data
RSSI: -68
2020-06-02 08:49:48.842525 > HCI Event: LE Meta Event (0x3e) plen 12
LE Advertising Report
SCAN_RSP - Scan Response (4)
bdaddr 9C:20:7B:BE:14:6E (Public)
RSSI: -68
2020-06-02 08:49:49.384917 > HCI Event: LE Meta Event (0x3e) plen 33
LE Advertising Report
ADV_IND - Connectable undirected advertising (0)
bdaddr C4:64:E3:9B:04:44 (Public)
Flags: 0x06
Unknown type 0x06 with 16 bytes data
RSSI: -95
2020-06-02 08:49:49.385781 > HCI Event: LE Meta Event (0x3e) plen 28
LE Advertising Report
SCAN_RSP - Scan Response (4)
bdaddr C4:64:E3:9B:04:44 (Public)
Unknown type 0xff with 8 bytes data
Shortened local name: '315X'
RSSI: -95
2020-06-02 08:49:49.392478 < HCI Command: LE Set Scan Enable (0x08|0x000c) plen 2
value 0x00 (scanning disabled)
filter duplicates 0x01 (enabled)
2020-06-02 08:49:49.394279 > HCI Event: Command Complete (0x0e) plen 4
LE Set Scan Enable (0x08|0x000c) ncmd 1
status 0x00
2020-06-02 08:49:49.399822 < HCI Command: LE Create Connection (0x08|0x000d) plen 25
bdaddr C4:64:E3:9B:04:44 type 0
interval 96 window 48 initiator_filter 0
own_bdaddr_type 0 min_interval 6 max_interval 12
latency 0 supervision_to 200 min_ce 4 max_ce 6
2020-06-02 08:49:49.400717 > HCI Event: Command Status (0x0f) plen 4
LE Create Connection (0x08|0x000d) status 0x00 ncmd 1
2020-06-02 08:49:59.914436 > HCI Event: LE Meta Event (0x3e) plen 19
LE Connection Complete
status 0x00 handle 64, role master
bdaddr C4:64:E3:9B:04:44 (Public)
2020-06-02 08:49:59.914783 < HCI Command: LE Read Remote Used Features (0x08|0x0016) plen 2
40 00
2020-06-02 08:49:59.915700 > HCI Event: Command Status (0x0f) plen 4
LE Read Remote Used Features (0x08|0x0016) status 0x00 ncmd 1
2020-06-02 08:50:00.205123 > HCI Event: LE Meta Event (0x3e) plen 12
LE Read Remote Used Features Complete
status 0x00 handle 64
Features: 0x1d 0x00 0x00 0x00 0x00 0x00 0x00 0x00
2020-06-02 08:50:00.211514 < ACL data: handle 64 flags 0x00 dlen 7
ATT: MTU req (0x02)
client rx mtu 256
2020-06-02 08:50:00.249993 > ACL data: handle 64 flags 0x02 dlen 7
ATT: MTU resp (0x03)
server rx mtu 65
2020-06-02 08:50:00.252698 < ACL data: handle 64 flags 0x00 dlen 11
ATT: Read By Group req (0x10)
start 0x0001, end 0xffff
type-uuid 0x2800
2020-06-02 08:50:00.295009 > HCI Event: Number of Completed Packets (0x13) plen 5
handle 64 packets 2
2020-06-02 08:50:00.385200 > ACL data: handle 64 flags 0x02 dlen 18
ATT: Read By Group resp (0x11)
attr handle 0x0001, end group handle 0x0007
value 0x00 0x18
attr handle 0x0008, end group handle 0x0008
value 0x01 0x18
2020-06-02 08:50:00.386993 < ACL data: handle 64 flags 0x00 dlen 11
ATT: Read By Group req (0x10)
start 0x0009, end 0xffff
type-uuid 0x2800
2020-06-02 08:50:00.460829 > ACL data: handle 64 flags 0x02 dlen 26
ATT: Read By Group resp (0x11)
attr handle 0x0009, end group handle 0xffff
value 0xe4 0x6d 0xdc 0x75 0xbf 0xdd 0xe5 0x84 0x1a 0x42 0x0e 0x0b 0x01 0x00 0xbd 0x98
2020-06-02 08:50:00.464756 < ACL data: handle 64 flags 0x00 dlen 11
ATT: Read By Type req (0x08)
start 0x0009, end 0xffff
type-uuid 0x2803
2020-06-02 08:50:00.490056 > HCI Event: Number of Completed Packets (0x13) plen 5
handle 64 packets 2
2020-06-02 08:50:00.520226 > ACL data: handle 64 flags 0x02 dlen 27
2020-06-02 08:50:00.535226 > ACL data: handle 64 flags 0x01 dlen 27
2020-06-02 08:50:00.580143 > ACL data: handle 64 flags 0x01 dlen 15
ATT: Read By Type resp (0x09)
length: 21
handle 0x000a, value 0x04 0x0b 0x00 0xe4 0x6d 0xdc 0x75 0xbf 0xdd 0xe5 0x84 0x1a 0x42 0x0e 0x0b 0x02 0x00 0xbd 0x98
handle 0x000d, value 0x12 0x0e 0x00 0xe4 0x6d 0xdc 0x75 0xbf 0xdd 0xe5 0x84 0x1a 0x42 0x0e 0x0b 0x03 0x00 0xbd 0x98
handle 0x0011, value 0x02 0x12 0x00 0xe4 0x6d 0xdc 0x75 0xbf 0xdd 0xe5 0x84 0x1a 0x42 0x0e 0x0b 0x04 0x00 0xbd 0x98
2020-06-02 08:50:00.582577 < ACL data: handle 64 flags 0x00 dlen 11
ATT: Read By Type req (0x08)
start 0x0013, end 0xffff
type-uuid 0x2803
2020-06-02 08:50:00.730061 > ACL data: handle 64 flags 0x02 dlen 9
ATT: Error (0x01)
Error: Attribute not found (10)
Read By Type req (0x08) on handle 0x0013
2020-06-02 08:50:00.737443 < ACL data: handle 64 flags 0x00 dlen 7
ATT: Read req (0x0a)
handle 0x0012
2020-06-02 08:50:00.759998 > HCI Event: Number of Completed Packets (0x13) plen 5
handle 64 packets 2
2020-06-02 08:50:00.760889 > ACL data: handle 64 flags 0x02 dlen 25
ATT: Read resp (0x0b)
41 75 74 6F 6D 6F 77 65 72 00 00 00 00 00 00 00 00 00 00 00
2020-06-02 08:50:00.823478 < ACL data: handle 64 flags 0x00 dlen 32
ATT: Write cmd (0x52)
handle 0x000b value 0x02 0xfd 0x01 0x60 0x00 0x00 0x00 0x00 0x00 0x00 0x00 0x2e 0x01 0x49 0x01 0x1f 0x8f 0x07 0x50 0x00 0x00 0x00 0x00 0x04 0x0d
2020-06-02 08:50:00.828900 < ACL data: handle 64 flags 0x00 dlen 14
ATT: Write cmd (0x52)
handle 0x000b value 0x61 0x69 0x06 0xe0 0x00 0xf0 0x03
2020-06-02 08:50:00.940081 > HCI Event: Number of Completed Packets (0x13) plen 5
handle 64 packets 2
2020-06-02 08:50:01.294462 < ACL data: handle 64 flags 0x00 dlen 24
ATT: Write cmd (0x52)
handle 0x000b value 0x02 0xfd 0x00 0xa0 0x00 0x91 0x1f 0x08 0xf7 0x05 0x00 0x7c 0x00 0x80 0x01 0x28 0x03
2020-06-02 08:50:01.562877 > HCI Event: Number of Completed Packets (0x13) plen 5
handle 64 packets 1
2020-06-02 08:50:01.774077 < ACL data: handle 64 flags 0x00 dlen 32
ATT: Write cmd (0x52)
handle 0x000b value 0x02 0xfd 0x01 0x00 0x00 0x91 0x1f 0x08 0xf7 0x05 0x01 0x52 0x00 0x0a 0x0f 0x5a 0x12 0x00 0x20 0x00 0x00 0x00 0x02 0x30 0x03
2020-06-02 08:50:01.937876 > HCI Event: Number of Completed Packets (0x13) plen 5
handle 64 packets 1
2020-06-02 08:50:02.281245 < ACL data: handle 64 flags 0x00 dlen 32
ATT: Write cmd (0x52)
handle 0x000b value 0x02 0xfd 0x01 0x00 0x00 0x91 0x1f 0x08 0xf7 0x05 0x01 0x52 0x00 0x0a 0x0f 0x38 0x12 0x00 0x20 0x00 0x00 0x00 0x08 0xe0 0x03
2020-06-02 08:50:02.562878 > HCI Event: Number of Completed Packets (0x13) plen 5
handle 64 packets 1
2020-06-02 08:50:02.773394 < ACL data: handle 64 flags 0x00 dlen 32
ATT: Write cmd (0x52)
handle 0x000b value 0x02 0xfd 0x01 0x20 0x00 0x91 0x1f 0x08 0xf7 0x05 0x01 0x28 0x00 0x0a 0x0f 0x38 0x12 0x00 0x40 0x00 0x02 0x00 0x0d 0x20 0x04
2020-06-02 08:50:02.776651 < ACL data: handle 64 flags 0x00 dlen 9
ATT: Write cmd (0x52)
handle 0x000b value 0xee 0x03
2020-06-02 08:50:02.876322 > HCI Event: Number of Completed Packets (0x13) plen 5
handle 64 packets 2
2020-06-02 08:50:03.284576 < ACL data: handle 64 flags 0x00 dlen 32
ATT: Write cmd (0x52)
handle 0x000b value 0x02 0xfd 0x01 0x00 0x00 0x91 0x1f 0x08 0xf7 0x05 0x01 0x52 0x00 0x0a 0x0f 0x38 0x12 0x00 0x30 0x00 0x00 0x00 0x00 0x10 0x03
2020-06-02 08:50:03.437917 > HCI Event: Number of Completed Packets (0x13) plen 5
handle 64 packets 1
2020-06-02 08:50:03.773593 < ACL data: handle 64 flags 0x00 dlen 32
ATT: Write cmd (0x52)
handle 0x000b value 0x02 0xfd 0x01 0x00 0x00 0x91 0x1f 0x08 0xf7 0x05 0x01 0x52 0x00 0x0a 0x0f 0xea 0x11 0x00 0x50 0x00 0x00 0x00 0x0e 0xc0 0x03
2020-06-02 08:50:03.937996 > HCI Event: Number of Completed Packets (0x13) plen 5
handle 64 packets 1
I've noticed that on iOs I've an encryption process which look like triggered automatically on connect :
a May 21 08:09:48.706 HCI Command 0x0041 315X LE Start Encryption - Connection Handle: 0x0041
while on the Pi I only have a create connection :
2020-06-02 08:49:49.399822 < HCI Command: LE Create Connection (0x08|0x000d) plen 25
bdaddr C4:64:E3:9B:04:44 type 0
interval 96 window 48 initiator_filter 0
own_bdaddr_type 0 min_interval 6 max_interval 12
latency 0 supervision_to 200 min_ce 4 max_ce 6
I've tried to manually pair the BLE device using bluetoothctl but look like the pairing isn't working :
pi#raspberrypi:~ $ bluetoothctl
Agent registered
[bluetooth]# connect C4:64:E3:9B:04:44
Attempting to connect to C4:64:E3:9B:04:44
[CHG] Device C4:64:E3:9B:04:44 Connected: yes
Connection successful
[NEW] Primary Service
/org/bluez/hci0/dev_C4_64_E3_9B_04_44/service0008
00001801-0000-1000-8000-00805f9b34fb
Generic Attribute Profile
[NEW] Primary Service
/org/bluez/hci0/dev_C4_64_E3_9B_04_44/service0009
98bd0001-0b0e-421a-84e5-ddbf75dc6de4
Vendor specific
[NEW] Characteristic
/org/bluez/hci0/dev_C4_64_E3_9B_04_44/service0009/char000a
98bd0002-0b0e-421a-84e5-ddbf75dc6de4
Vendor specific
[NEW] Descriptor
/org/bluez/hci0/dev_C4_64_E3_9B_04_44/service0009/char000a/desc000c
00002901-0000-1000-8000-00805f9b34fb
Characteristic User Description
[NEW] Characteristic
/org/bluez/hci0/dev_C4_64_E3_9B_04_44/service0009/char000d
98bd0003-0b0e-421a-84e5-ddbf75dc6de4
Vendor specific
[NEW] Descriptor
/org/bluez/hci0/dev_C4_64_E3_9B_04_44/service0009/char000d/desc000f
00002902-0000-1000-8000-00805f9b34fb
Client Characteristic Configuration
[NEW] Descriptor
/org/bluez/hci0/dev_C4_64_E3_9B_04_44/service0009/char000d/desc0010
00002901-0000-1000-8000-00805f9b34fb
Characteristic User Description
[NEW] Characteristic
/org/bluez/hci0/dev_C4_64_E3_9B_04_44/service0009/char0011
98bd0004-0b0e-421a-84e5-ddbf75dc6de4
Vendor specific
[NEW] Descriptor
/org/bluez/hci0/dev_C4_64_E3_9B_04_44/service0009/char0011/desc0013
00002901-0000-1000-8000-00805f9b34fb
Characteristic User Description
[CHG] Device C4:64:E3:9B:04:44 UUIDs: 00001800-0000-1000-8000-00805f9b34fb
[CHG] Device C4:64:E3:9B:04:44 UUIDs: 00001801-0000-1000-8000-00805f9b34fb
[CHG] Device C4:64:E3:9B:04:44 UUIDs: 98bd0001-0b0e-421a-84e5-ddbf75dc6de4
[CHG] Device C4:64:E3:9B:04:44 ServicesResolved: yes
[315X]# pair C4:64:E3:9B:04:44
Attempting to pair with C4:64:E3:9B:04:44
Failed to pair: org.bluez.Error.AuthenticationFailed
[CHG] Device C4:64:E3:9B:04:44 ServicesResolved: no
[CHG] Device C4:64:E3:9B:04:44 Connected: no
EDIT
Ok, it's look like the encryption process is being triggered when I try to subscribe to the notify characteristics but pairing fail :
2020-06-02 10:57:45.657381 > ACL data: handle 64 flags 0x02 dlen 9
ATT: Error (0x01)
Error: Insufficient authentication (5)
Read By Type req (0x08) on handle 0x000f
2020-06-02 10:57:45.658692 < ACL data: handle 64 flags 0x00 dlen 11
SMP: Pairing Request (0x01)
capability 0x03 oob 0x00 auth req 0x01
max key size 0x10 init key dist 0x00 resp key dist 0x01
Capability: NoInputNoOutput (OOB data not present)
Authentication: Bonding (No MITM Protection)
Initiator Key Distribution:
Responder Key Distribution: LTK
2020-06-02 10:57:45.687326 > ACL data: handle 64 flags 0x02 dlen 6
SMP: Pairing Failed (0x05)
reason 0x05
Reason Pairing Not Supported
I don't know how to solve this pairing issue
Edit 2
It look like this was a device issue which allow pairing inconsistently or is being activated via a specific gatt command, I'll dive deeper to figure out
This looks to be happening because pairing is not supported on the Raspberry Pi. You can resolve this through a combination of btmgmt and bluetoothctl commands:-
sudo btmgmt power off
sudo btmgmt discov on
sudo btmgmt connectable on
sudo btmgmt pairable on
sudo btmgmt power on
Also, according to your logs you have set the IO Capability to 0x03 (NoInputNoOutput). You can change this by launching bluetoothctl using:-
bluetoothctl --agent KeyboardDisplay
After that, you should be prompted to enter a passkey or accept incoming connection on the Raspberry Pi. You can play with all the different IO Capabilities to see which one works best for you. The commands for doing this are:-
bluetoothctl --agent DisplayOnly
bluetoothctl --agent DisplayYesNo
bluetoothctl --agent KeyboardOnly
bluetoothctl --agent NoInputNoOutput
bluetoothctl --agent KeyboardDisplay
More details can be found in the links below
BLE Pairing the Raspberry Pi 3 Model B
Configuring Bluetooth devices with bluetoothctl
How to Encrypt Data Using BLE Connection Using BlueZ
I hope this helps.
I had a similar issue. I used Raspberry Pi 4 and nRF Connect tool.
I could bond the devices and connect it. But, it failed to read encrypted gatt characteristic even after bonding. StackOverflow Link to the problem.
The root cause of the issue and the solution is given in this Github Link.
Issue:
Boot up the Pi.
Start the agent, advertisement and gatt server.
Bond the device.
Connect it.
Try to read the encrypted characteristic. It fails.
Root Cause:
After much digging, I noticed that this problem is caused by the state
the bluetooth chip is in at the time BlueZ is fired up (you can check
the state with hciconfig hci0). If it's in "UP RUNNING" state or in
"UP RUNNING PSCAN ISCAN" state, BlueZ complains with one or more of
these:
Failed to set mode: Rejected (0x0b) Failed to set mode: Rejected
(0x0b) Failed to set privacy: Rejected (0x0b)
But if it's in "DOWN" state, BlueZ starts with no issues. So, you
first have to do hciconfig hci0 down before the bluetooth service
starts up. But before you can use hciconfig, you also need to ensure
the sys-subsystem-bluetooth-devices-hci0.device service has started!
Solution 1:
I ended up disabling the automatic boot sequence, and run this script instead:
systemctl start sys-subsystem-bluetooth-devices-hci0.device; hciconfig hci0 down; systemctl start bluetooth
Solution 2:
Delaying the running of bthelper by a couple of seconds fixed this
issue for me, without me having to disable the automatic boot sequence
and run any manual commands.
I added an ExecStartPre line to /lib/systemd/system/bthelper#.service
such that the Service section now looks like this:
[Service]
Type=simple
ExecStartPre=/bin/sleep 2
ExecStart=/usr/bin/bthelper %I
Related
I'm trying to read the characteristic value of BLE devices, in my case BLE device is Minew S1 Temperature and Humidity sensor, the attribute value I'm trying to read is "Radio Tx Power".
I'm using RaspberryPi 4 and bluetoothctl version is 5.55.
Primary Service (Handle 0x0004)
/org/bluez/hci0/dev_AC_23_3F_AB_7B_D8/service001f
a3c87500-8ed3-4bdf-8a39-a01bebede295
Eddystone Configuration Service
Characteristic (Handle 0x6510)
/org/bluez/hci0/dev_AC_23_3F_AB_7B_D8/service001f/char002c
a3c8750b-8ed3-4bdf-8a39-a01bebede295
(Advanced) Factory reset
Characteristic (Handle 0x0d78)
/org/bluez/hci0/dev_AC_23_3F_AB_7B_D8/service001f/char002a
a3c8750a-8ed3-4bdf-8a39-a01bebede295
ADV Slot Data
Characteristic (Handle 0x0d78)
/org/bluez/hci0/dev_AC_23_3F_AB_7B_D8/service001f/char0028
a3c87505-8ed3-4bdf-8a39-a01bebede295
(Advanced) Advertised Tx Power
Characteristic (Handle 0x0d78)
/org/bluez/hci0/dev_AC_23_3F_AB_7B_D8/service001f/char0026
a3c87504-8ed3-4bdf-8a39-a01bebede295
Radio Tx Power
Characteristic (Handle 0x0d78)
/org/bluez/hci0/dev_AC_23_3F_AB_7B_D8/service001f/char0024
a3c87503-8ed3-4bdf-8a39-a01bebede295
Advertising Interval
Characteristic (Handle 0x0d78)
/org/bluez/hci0/dev_AC_23_3F_AB_7B_D8/service001f/char0022
a3c87502-8ed3-4bdf-8a39-a01bebede295
Active Slot
Characteristic (Handle 0x0d78)
/org/bluez/hci0/dev_AC_23_3F_AB_7B_D8/service001f/char0020
a3c87501-8ed3-4bdf-8a39-a01bebede295
Capabilities
Primary Service (Handle 0xa2d8)
/org/bluez/hci0/dev_AC_23_3F_AB_7B_D8/service001b
7f280001-8204-f393-e0a9-e50e24dcca9e
Vendor specific
Characteristic (Handle 0xad98)
/org/bluez/hci0/dev_AC_23_3F_AB_7B_D8/service001b/char001c
7f280002-8204-f393-e0a9-e50e24dcca9e
Vendor specific
Descriptor (Handle 0x0000)
/org/bluez/hci0/dev_AC_23_3F_AB_7B_D8/service001b/char001c/desc001e
00002902-0000-1000-8000-00805f9b34fb
Client Characteristic Configuration
using bluetoothctl I tried to read the data but I got this error
[nRF5x]# select-attribute /org/bluez/hci0/dev_AC_23_3F_AB_7B_D8/service001f/char0026
[nRF5x:/service001f/char0026]# read
Attempting to read /org/bluez/hci0/dev_AC_23_3F_AB_7B_D8/service001f/char0026
[CHG] Device AC:23:3F:AB:7B:D8 ServicesResolved: no
[CHG] Device AC:23:3F:AB:7B:D8 Connected: no
Failed to read: org.bluez.Error.Failed
[bluetooth]#
and all these are working fine when connected to android mobile.
please help me to solve this problem.
Edited (added debug):
> HCI Event: Command Complete (0x0e) plen 4 #37 [hci0] 23.110065
LE Set Scan Enable (0x08|0x000c) ncmd 1
Status: Success (0x00)
< HCI Command: LE Create Connection (0x08|0x000d) plen 25 #38 [hci0] 23.110095
Scan interval: 60.000 msec (0x0060)
Scan window: 60.000 msec (0x0060)
Filter policy: White list is not used (0x00)
Peer address type: Public (0x00)
Peer address: AC:23:3F:AB:7B:D8 (Shenzhen Minew Technologies Co., Ltd.)
Own address type: Public (0x00)
Min connection interval: 30.00 msec (0x0018)
Max connection interval: 50.00 msec (0x0028)
Connection latency: 0 (0x0000)
Supervision timeout: 420 msec (0x002a)
Min connection length: 0.000 msec (0x0000)
Max connection length: 0.000 msec (0x0000)
> HCI Event: Command Status (0x0f) plen 4 #39 [hci0] 23.110613
LE Create Connection (0x08|0x000d) ncmd 1
Status: Success (0x00)
> HCI Event: LE Meta Event (0x3e) plen 19 #40 [hci0] 23.210757
LE Connection Complete (0x01)
Status: Success (0x00)
Handle: 64
Role: Master (0x00)
Peer address type: Public (0x00)
Peer address: AC:23:3F:AB:7B:D8 (Shenzhen Minew Technologies Co., Ltd.)
Connection interval: 48.75 msec (0x0027)
Connection latency: 0 (0x0000)
Supervision timeout: 420 msec (0x002a)
Master clock accuracy: 0x00
# MGMT Event: Device Connected (0x000b) plen 37 {0x0001} [hci0] 23.210785
LE Address: AC:23:3F:AB:7B:D8 (Shenzhen Minew Technologies Co., Ltd.)
Flags: 0x00000000
Data length: 24
Flags: 0x06
LE General Discoverable Mode
BR/EDR Not Supported
16-bit Service UUIDs (complete): 1 entry
Unknown (0xffe1)
Service Data (UUID 0xffe1): a101641cfd48e6d87bab3f23ac
< HCI Command: LE Read Remote Used Features (0x08|0x0016) plen 2 #41 [hci0] 23.210905
Handle: 64
> HCI Event: Command Status (0x0f) plen 4 #42 [hci0] 23.211771
LE Read Remote Used Features (0x08|0x0016) ncmd 1
Status: Success (0x00)
> HCI Event: Command Complete (0x0e) plen 14 #43 [hci0] 23.211775
LE Read Remote Used Features (0x08|0x0016) ncmd 1
Status: Success (0x00)
00 00 00 00 00 00 00 00 00 00 ..........
> HCI Event: LE Meta Event (0x3e) plen 12 #44 [hci0] 23.337233
LE Read Remote Used Features (0x04)
Status: Success (0x00)
Handle: 64
Features: 0x21 0x00 0x00 0x00 0x00 0x00 0x00 0x00
LE Encryption
LE Data Packet Length Extension
< ACL Data TX: Handle 64 flags 0x00 dlen 7 #45 [hci0] 23.337677
ATT: Exchange MTU Request (0x02) len 2
Client RX MTU: 517
> ACL Data RX: Handle 64 flags 0x02 dlen 7 #46 [hci0] 23.532018
ATT: Exchange MTU Response (0x03) len 2
Server RX MTU: 23
< ACL Data TX: Handle 64 flags 0x00 dlen 7 #47 [hci0] 23.532452
ATT: Read Request (0x0a) len 2
Handle: 0x0003
> HCI Event: Number of Completed Packets (0x13) plen 5 #48 [hci0] 23.580957
Num handles: 1
Handle: 64
Count: 2
> ACL Data RX: Handle 64 flags 0x02 dlen 10 #49 [hci0] 23.629552
ATT: Read Response (0x0b) len 5
Value: 6e52463578
< ACL Data TX: Handle 64 flags 0x00 dlen 7 #50 [hci0] 23.629713
ATT: Read Request (0x0a) len 2
Handle: 0x0005
> ACL Data RX: Handle 64 flags 0x02 dlen 7 #51 [hci0] 23.727010
ATT: Read Response (0x0b) len 2
Value: 0000
< ACL Data TX: Handle 64 flags 0x00 dlen 7 #52 [hci0] 23.727179
ATT: Read Request (0x0a) len 2
Handle: 0x0027
> HCI Event: Number of Completed Packets (0x13) plen 5 #53 [hci0] 23.775948
Num handles: 1
Handle: 64
Count: 2
> HCI Event: Disconnect Complete (0x05) plen 4 #54 [hci0] 32.502249
Status: Success (0x00)
Handle: 64
Reason: Remote User Terminated Connection (0x13)
# MGMT Event: Device Disconnected (0x000c) plen 8 {0x0001} [hci0] 32.502320
LE Address: AC:23:3F:AB:7B:D8 (Shenzhen Minew Technologies Co., Ltd.)
Reason: Connection terminated by remote host (0x03)
thank you.
I'm currently working on USB headset using stm32 microcontroller. I used example code from X-CUBE-USB-AUDIO package to stream audio to\from PC. Everything seems to work fine. Now I want to modify the code to allow USB device to notify the host of volume/mute changes. According to USB audio specification 1.0 p.30, an optional Status Interrupt Endpoint can be used for this purpose. So I modified device descriptor to include that optional endpoint. Here is the original descriptor:
Information for device STM32 AUDIO Streaming in FS Mode (VID=0x0483 PID=0x5730):
Connection Information:
------------------------------
Device current bus speed: FullSpeed
Device supports USB 1.1 specification
Device supports USB 2.0 specification
Device address: 0x004B
Current configuration value: 0x01
Number of open pipes: 0
Device Descriptor:
------------------------------
0x12 bLength
0x01 bDescriptorType
0x0200 bcdUSB
0x00 bDeviceClass
0x00 bDeviceSubClass
0x00 bDeviceProtocol
0x40 bMaxPacketSize0 (64 bytes)
0x0483 idVendor
0x5730 idProduct
0x0200 bcdDevice
0x01 iManufacturer "STMicroelectronics"
0x02 iProduct "STM32 AUDIO Streaming in FS Mode"
0x03 iSerialNumber "368932633438"
0x01 bNumConfigurations
Configuration Descriptor:
------------------------------
0x09 bLength
0x02 bDescriptorType
0x00CB wTotalLength (203 bytes)
0x03 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
0x0048 wTotalLength (72 bytes)
0x02 bInCollection
0x01 baInterfaceNr(1)
0x02 baInterfaceNr(2)
AC Input Terminal Descriptor:
------------------------------
0x0C bLength
0x24 bDescriptorType
0x02 bDescriptorSubtype
0x12 bTerminalID
0x0101 wTerminalType (USB Streaming)
0x00 bAssocTerminal
0x02 bNrChannels (2 channels)
0x0003 wChannelConfig
0x00 iChannelNames
0x00 iTerminal
AC Feature Unit Descriptor:
------------------------------
0x0A bLength
0x24 bDescriptorType
0x06 bDescriptorSubtype
0x16 bUnitID
0x12 bSourceID
0x01 bControlSize
bmaControls:
0x03 Channel(0) - Mute / Volume
0x00 Channel(1)
0x00 Channel(2)
0x00 iFeature
AC Output Terminal Descriptor:
------------------------------
0x09 bLength
0x24 bDescriptorType
0x03 bDescriptorSubtype
0x14 bTerminalID
0x0301 wTerminalType (Speaker)
0x00 bAssocTerminal
0x16 bSourceID
0x00 iTerminal
AC Input Terminal Descriptor:
------------------------------
0x0C bLength
0x24 bDescriptorType
0x02 bDescriptorSubtype
0x11 bTerminalID
0x0201 wTerminalType (Microphone)
0x00 bAssocTerminal
0x02 bNrChannels (2 channels)
0x0003 wChannelConfig
0x00 iChannelNames
0x00 iTerminal
AC Feature Unit Descriptor:
------------------------------
0x0A bLength
0x24 bDescriptorType
0x06 bDescriptorSubtype
0x15 bUnitID
0x11 bSourceID
0x01 bControlSize
bmaControls:
0x03 Channel(0) - Mute / Volume
0x00 Channel(1)
0x00 Channel(2)
0x00 iFeature
AC Output Terminal Descriptor:
------------------------------
0x09 bLength
0x24 bDescriptorType
0x03 bDescriptorSubtype
0x13 bTerminalID
0x0101 wTerminalType (USB Streaming)
0x00 bAssocTerminal
0x15 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
0x02 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
0x12 bTerminalLink
0x01 bDelay
0x0001 wFormatTag (PCM)
AS Format Type 1 Descriptor:
------------------------------
0x0B bLength
0x24 bDescriptorType
0x02 bDescriptorSubtype
0x01 bFormatType (FORMAT_TYPE_1)
0x02 bNrChannels (2 channels)
0x02 bSubframeSize
0x10 bBitResolution (16 bits per sample)
0x01 bSamFreqType (Discrete sampling frequencies)
0x00BB80 tSamFreq(1) (48000 Hz)
Endpoint Descriptor (Audio/MIDI 1.0):
------------------------------
0x09 bLength
0x05 bDescriptorType
0x01 bEndpointAddress (OUT endpoint 1)
0x05 bmAttributes (Transfer: Isochronous / Synch: Asynchronous / Usage: Data)
0x00C4 wMaxPacketSize (1 x 196 bytes)
0x01 bInterval (1 frames)
0x00 bRefresh
0x81 bSynchAddress
AS Isochronous Data Endpoint Descriptor:
------------------------------
0x07 bLength
0x25 bDescriptorType
0x01 bDescriptorSubtype
0x00 bmAttributes
0x00 bLockDelayUnits (undefined)
0x0000 wLockDelay
Endpoint Descriptor (Audio/MIDI 1.0):
------------------------------
0x09 bLength
0x05 bDescriptorType
0x81 bEndpointAddress (IN endpoint 1)
0x01 bmAttributes (Transfer: Isochronous / Synch: None / Usage: Data)
0x0003 wMaxPacketSize (1 x 3 bytes)
0x01 bInterval (1 frames)
0x07 bRefresh
0x00 bSynchAddress
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
0x13 bTerminalLink
0x01 bDelay
0x0001 wFormatTag (PCM)
AS Format Type 1 Descriptor:
------------------------------
0x0B bLength
0x24 bDescriptorType
0x02 bDescriptorSubtype
0x01 bFormatType (FORMAT_TYPE_1)
0x02 bNrChannels (2 channels)
0x02 bSubframeSize
0x10 bBitResolution (16 bits per sample)
0x01 bSamFreqType (Discrete sampling frequencies)
0x00BB80 tSamFreq(1) (48000 Hz)
Endpoint Descriptor (Audio/MIDI 1.0):
------------------------------
0x09 bLength
0x05 bDescriptorType
0x82 bEndpointAddress (IN endpoint 2)
0x01 bmAttributes (Transfer: Isochronous / Synch: None / 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
0x00 bmAttributes
0x00 bLockDelayUnits (undefined)
0x0000 wLockDelay
Microsoft OS Descriptor is not available. Error code: 0x0000001F
String Descriptor Table
--------------------------------
Index LANGID String
0x00 0x0000 0x0409
0x01 0x0409 "STMicroelectronics"
0x02 0x0409 "STM32 AUDIO Streaming in FS Mode"
0x03 0x0409 "368932633438"
------------------------------
Connection path for device:
USB xHCI Compliant Host Controller
Root Hub
STM32 AUDIO Streaming in FS Mode (VID=0x0483 PID=0x5730) Port: 5
Running on: Windows 10 or greater (Build Version 19043)
Brought to you by TDD v2.15.0, Jun 8 2020, 17:18:07
And here is the modified descriptor:
Information for device STM32 AUDIO Streaming in FS Mode (VID=0x0483 PID=0x5730):
Connection Information:
------------------------------
Device current bus speed: FullSpeed
Device supports USB 1.1 specification
Device supports USB 2.0 specification
Device address: 0x001B
Current configuration value: 0x01
Number of open pipes: 1
Device Descriptor:
------------------------------
0x12 bLength
0x01 bDescriptorType
0x0200 bcdUSB
0x00 bDeviceClass
0x00 bDeviceSubClass
0x00 bDeviceProtocol
0x40 bMaxPacketSize0 (64 bytes)
0x0483 idVendor
0x5730 idProduct
0x0200 bcdDevice
0x01 iManufacturer "STMicroelectronics"
0x02 iProduct "STM32 AUDIO Streaming in FS Mode"
0x03 iSerialNumber "368932633438"
0x01 bNumConfigurations
Configuration Descriptor:
------------------------------
0x09 bLength
0x02 bDescriptorType
0x00D4 wTotalLength (212 bytes)
0x03 bNumInterfaces
0x01 bConfigurationValue
0x00 iConfiguration
0xC0 bmAttributes (Self-powered Device)
0x32 bMaxPower (100 mA)
Interface Descriptor:
------------------------------
0x09 bLength
0x04 bDescriptorType
0x00 bInterfaceNumber
0x00 bAlternateSetting
0x01 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
0x0048 wTotalLength (72 bytes)
0x02 bInCollection
0x01 baInterfaceNr(1)
0x02 baInterfaceNr(2)
AC Input Terminal Descriptor:
------------------------------
0x0C bLength
0x24 bDescriptorType
0x02 bDescriptorSubtype
0x12 bTerminalID
0x0101 wTerminalType (USB Streaming)
0x00 bAssocTerminal
0x02 bNrChannels (2 channels)
0x0003 wChannelConfig
0x00 iChannelNames
0x00 iTerminal
AC Feature Unit Descriptor:
------------------------------
0x0A bLength
0x24 bDescriptorType
0x06 bDescriptorSubtype
0x16 bUnitID
0x12 bSourceID
0x01 bControlSize
bmaControls:
0x03 Channel(0) - Mute / Volume
0x00 Channel(1)
0x00 Channel(2)
0x00 iFeature
AC Output Terminal Descriptor:
------------------------------
0x09 bLength
0x24 bDescriptorType
0x03 bDescriptorSubtype
0x14 bTerminalID
0x0301 wTerminalType (Speaker)
0x00 bAssocTerminal
0x16 bSourceID
0x00 iTerminal
AC Input Terminal Descriptor:
------------------------------
0x0C bLength
0x24 bDescriptorType
0x02 bDescriptorSubtype
0x11 bTerminalID
0x0201 wTerminalType (Microphone)
0x00 bAssocTerminal
0x02 bNrChannels (2 channels)
0x0003 wChannelConfig
0x00 iChannelNames
0x00 iTerminal
AC Feature Unit Descriptor:
------------------------------
0x0A bLength
0x24 bDescriptorType
0x06 bDescriptorSubtype
0x15 bUnitID
0x11 bSourceID
0x01 bControlSize
bmaControls:
0x03 Channel(0) - Mute / Volume
0x00 Channel(1)
0x00 Channel(2)
0x00 iFeature
AC Output Terminal Descriptor:
------------------------------
0x09 bLength
0x24 bDescriptorType
0x03 bDescriptorSubtype
0x13 bTerminalID
0x0101 wTerminalType (USB Streaming)
0x00 bAssocTerminal
0x15 bSourceID
0x00 iTerminal
Endpoint Descriptor (Audio/MIDI 1.0):
------------------------------
0x09 bLength
0x05 bDescriptorType
0x83 bEndpointAddress (IN endpoint 3)
0x03 bmAttributes (Transfer: Interrupt / Synch: None / Usage: Data)
0x0002 wMaxPacketSize (1 x 2 bytes)
0x0A bInterval (10 frames)
0x00 bRefresh
0x00 bSynchAddress
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
0x02 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
0x12 bTerminalLink
0x01 bDelay
0x0001 wFormatTag (PCM)
AS Format Type 1 Descriptor:
------------------------------
0x0B bLength
0x24 bDescriptorType
0x02 bDescriptorSubtype
0x01 bFormatType (FORMAT_TYPE_1)
0x02 bNrChannels (2 channels)
0x02 bSubframeSize
0x10 bBitResolution (16 bits per sample)
0x01 bSamFreqType (Discrete sampling frequencies)
0x00BB80 tSamFreq(1) (48000 Hz)
Endpoint Descriptor (Audio/MIDI 1.0):
------------------------------
0x09 bLength
0x05 bDescriptorType
0x01 bEndpointAddress (OUT endpoint 1)
0x05 bmAttributes (Transfer: Isochronous / Synch: Asynchronous / Usage: Data)
0x00C4 wMaxPacketSize (1 x 196 bytes)
0x01 bInterval (1 frames)
0x00 bRefresh
0x81 bSynchAddress
AS Isochronous Data Endpoint Descriptor:
------------------------------
0x07 bLength
0x25 bDescriptorType
0x01 bDescriptorSubtype
0x00 bmAttributes
0x00 bLockDelayUnits (undefined)
0x0000 wLockDelay
Endpoint Descriptor (Audio/MIDI 1.0):
------------------------------
0x09 bLength
0x05 bDescriptorType
0x81 bEndpointAddress (IN endpoint 1)
0x01 bmAttributes (Transfer: Isochronous / Synch: None / Usage: Data)
0x0003 wMaxPacketSize (1 x 3 bytes)
0x01 bInterval (1 frames)
0x07 bRefresh
0x00 bSynchAddress
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
0x13 bTerminalLink
0x01 bDelay
0x0001 wFormatTag (PCM)
AS Format Type 1 Descriptor:
------------------------------
0x0B bLength
0x24 bDescriptorType
0x02 bDescriptorSubtype
0x01 bFormatType (FORMAT_TYPE_1)
0x02 bNrChannels (2 channels)
0x02 bSubframeSize
0x10 bBitResolution (16 bits per sample)
0x01 bSamFreqType (Discrete sampling frequencies)
0x00BB80 tSamFreq(1) (48000 Hz)
Endpoint Descriptor (Audio/MIDI 1.0):
------------------------------
0x09 bLength
0x05 bDescriptorType
0x82 bEndpointAddress (IN endpoint 2)
0x01 bmAttributes (Transfer: Isochronous / Synch: None / 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
0x00 bmAttributes
0x00 bLockDelayUnits (undefined)
0x0000 wLockDelay
Microsoft OS Descriptor is not available. Error code: 0x0000001F
String Descriptor Table
--------------------------------
Index LANGID String
0x00 0x0000 0x0409
0x01 0x0409 "STMicroelectronics"
0x02 0x0409 "STM32 AUDIO Streaming in FS Mode"
0x03 0x0409 "368932633438"
------------------------------
Connection path for device:
USB xHCI Compliant Host Controller
Root Hub
STM32 AUDIO Streaming in FS Mode (VID=0x0483 PID=0x5730) Port: 5
Running on: Windows 10 or greater (Build Version 19043)
Brought to you by TDD v2.15.0, Jun 8 2020, 17:18:07
The changes I've made are:
Add AC Interrupt endpoint descriptor.
Change wTotalLength in Configuration Descriptor.
Change bNumEndPoints in AC Interface descriptor from 0 to 1.
USB device seems to enumerate fine and there is audio, however when looking at the output of Beagle USB logic analyzer, I don't see any data being requested by the host from the interrupt endpoint. So my question is, is there something wrong with the way I modified the descriptors or is it something else? Has anyone managed to get the Status Interrupt Endpoint working properly for USB audio devices?
Running on: Windows 10 or greater (Build Version 19043)
Windows doesn't handle this interrupt in my experience. Try it on Linux or MacOS.
I am currently working on performing a secure boot on the imx6ul using HABv4. I followed the steps provided in the following document.
http://marc.info/?l=u-boot&m=139227973004718&q=p5
After performing all the steps I have described below, I typed hab_status in the U-boot command prompt. Then I get the HAB Events I have shown below. The only step I did not perform is fusing the SRK table. I would like to know the following information:
Is it a must to fuse the SRK table during the development stage?
From where can I find the load address that has to specify in the csf file? I used the following value defined in the Uboot configuration file. The document AN4581 (Rev.0,10/2012) describes that start* = TEXT_BASE and that it is defined in the config.mk file. However, config.mk file is not available in my U-boot folder (Probably because I am using a newer version).
#define CONFIG_SYS_TEXT_BASE 0x87800000
AN4581(Rev. 1, 10/2015) does not provide any information regarding this.
How does the Uboot knows the starting pointer of cfs? Should we specify it in any other location?
I have specified the steps I performed below. Let me know whether anything I am doing wrongly.
Steps Performed:
Please see the steps performed below.
Built u-boot.imx enabling the secure mode.
Generated all root public key files and corresponding hash.
Created csf file with the following content. Content of the file is attached at the end.
My u-uboot.imx file is 0x60830. I extended it to 0x61000 using the following command.
objcopy -I binary -O binary --pad-to 0x61000 --gap-fill=0x5A u-boot.imx u-boot-pad.imx
Then I generated csf.bin file using the command below.
./cst -o u-boot_csf.bin -i uboot.csf
Merged image and csf data using the command below.
cat u-boot-pad.imx u-boot_csf.bin > u-boot-signed.imx
Then extended the final image to 0x63000
objcopy -I binary -O binary --pad-to 0x63000 --gap-fill=0x5A u-boot-signed.imx u-boot-signed-pad.imx
The length of the block is calculated as: Length = u-boot-pad.imx (0x61000) - IVT_OFFSET (0x400).
And added 400 to the starting address as shown below.
# Address Offset Length Data File Path
Blocks = 0x87800400 0x400 0x00060C00 "u-boot-pad.imx"
HAB Events:
HAB Configuration: 0xf0, HAB State: 0x66
--------- HAB Event 1 -----------------
event data:
0xdb 0x00 0x1c 0x42 0x33 0x18 0xc0 0x00
0xca 0x00 0x14 0x00 0x02 0xc5 0x00 0x00
0x00 0x00 0x0d 0x34 0x87 0x80 0x04 0x00
0x00 0x06 0x0c 0x00
--------- HAB Event 2 -----------------
event data:
0xdb 0x00 0x14 0x42 0x33 0x0c 0xa0 0x00
0x00 0x00 0x00 0x00 0x87 0x7f 0xf7 0xd0
0x00 0x00 0x00 0x20
--------- HAB Event 3 -----------------
event data:
0xdb 0x00 0x14 0x42 0x33 0x0c 0xa0 0x00
0x00 0x00 0x00 0x00 0x87 0x7f 0xf7 0xfc
0x00 0x00 0x01 0xf0
--------- HAB Event 4 -----------------
event data:
0xdb 0x00 0x14 0x42 0x33 0x0c 0xa0 0x00
0x00 0x00 0x00 0x00 0x87 0x7f 0xf7 0xf0
0x00 0x00 0x00 0x01
--------- HAB Event 5 -----------------
event data:
0xdb 0x00 0x14 0x42 0x33 0x0c 0xa0 0x00
0x00 0x00 0x00 0x00 0x87 0x80 0x00 0x00
0x00 0x00 0x00 0x04
Command Sequency File Description:
#Illustrative Command Sequence File Description
[Header]
Version = 4.1
Hash Algorithm = sha256
Engine = ANY
Engine Configuration = 0
Certificate Format = X509
Signature Format = CMS
[Install SRK]
File = "../crts/SRK_1_2_3_4_table.bin"
# Index of the key location in the SRK table to be installed
Source index = 0
[Install CSFK]
# Key used to authenticate the CSF data
File = "../crts/CSF1_1_sha256_2048_65537_v3_usr_crt.pem"
[Authenticate CSF]
[Install Key]
# Key to install
File= "../crts/IMG1_1_sha256_2048_65537_v3_usr_crt.pem"
# Target key slot in HAB key store where key will be installed
Target Index = 2
# Key slot index used to authenticate the key to be installed
Verification index = 0
[Authenticate Data]
# Address Offset Length Data File Path
Blocks = 0x87800400 0x400 0x00060C00 "u-boot-pad.imx"
# Key slot index used to authenticate the image data
Verification index = 2
Best Regards
I'm trying to send/receive audio over USB from my embedded linux device to/from a Windows host.
I understand there are 2 protocols to send audio over USB - USB Audio Class 1 and 2 (UAC1 & UAC2). I found them explained here: http://www.thewelltemperedcomputer.com/HW/USB_Audio.htm.
I have currently used the existing UAC1 device driver in Linux to get audio from the host PC. It works for me. I am now trying to change the device driver to also be capable of sending audio to the host PC.
I see that there's a UAC2 driver (in the latest Linux kernel) that both sends and receives audio from the host. But I'd like to have a UAC1 driver that does that, so that I don't have to install any extra drivers on the Windows host (especially ones I have to buy: http://www.thesycon.de/eng/usb_audiodriver.shtml).
I've modified the linux device driver at linux/drivers/usb/gadget/f_audio.c (I'm using an older kernel). I've changed the USB header descriptor to include the extra endpoint for sending audio to host.
static struct usb_descriptor_header *hs_audio_desc[] = {
(struct usb_descriptor_header *)&std_ac_if_desc,
(struct usb_descriptor_header *)&ac_hdr_desc,
(struct usb_descriptor_header *)&usb_it_desc,
(struct usb_descriptor_header *)&usb_ot_desc,
(struct usb_descriptor_header *)&std_as_out_if0_desc,
(struct usb_descriptor_header *)&std_as_out_if1_desc,
(struct usb_descriptor_header *)&as_out_hdr_desc,
(struct usb_descriptor_header *)&as_out_fmt1_desc,
(struct usb_descriptor_header *)&hs_epout_desc,
(struct usb_descriptor_header *)&as_iso_out_desc,
(struct usb_descriptor_header *)&std_as_in_if0_desc,
(struct usb_descriptor_header *)&std_as_in_if1_desc,
(struct usb_descriptor_header *)&as_in_hdr_desc,
(struct usb_descriptor_header *)&as_in_fmt1_desc,
(struct usb_descriptor_header *)&hs_epin_desc,
(struct usb_descriptor_header *)&as_iso_in_desc,
NULL,
};
The OUT endpoint is defined as:
struct usb_endpoint_descriptor hs_epout_desc = {
.bLength = USB_DT_ENDPOINT_SIZE,
.bDescriptorType = USB_DT_ENDPOINT,
.bmAttributes = USB_ENDPOINT_XFER_ISOC | USB_ENDPOINT_SYNC_ASYNC,
.wMaxPacketSize = __constant_cpu_to_le16(OUT_EP_MAX_PACKET_SIZE),
.bInterval = 4,
};
The IN endpoint is defined as:
struct usb_endpoint_descriptor hs_epin_desc = {
.bLength = USB_DT_ENDPOINT_SIZE,
.bDescriptorType = USB_DT_ENDPOINT,
.bEndpointAddress = USB_DIR_IN,
.bmAttributes = USB_ENDPOINT_XFER_ISOC | USB_ENDPOINT_SYNC_ASYNC,
.wMaxPacketSize = __constant_cpu_to_le16(OUT_EP_MAX_PACKET_SIZE),
.bInterval = 4,
};
In epautoconf.c, the bEndpointAddress field is usually OR'ed with the endpoint number. I see in my case that this is happening.
The 'bEndpointAddress' field for my OUT endpoint is 0x01 and for my IN endpoint is 0x81 when I print it in epautoconf.c.
I'm however not able to see it on the host side. On my Windows PC, I use USB View tool to see the descriptors and I see that the values are 0x00 and 0x80.
What could have possibly changed the value of bEndpointAdress?
These are the USB descriptors I see in Windows using USB View tool:
Device Descriptor:
bcdUSB: 0x0200
bDeviceClass: 0x00
bDeviceSubClass: 0x00
bDeviceProtocol: 0x00
bMaxPacketSize0: 0x40 (64)
idVendor: 0x1D6B
idProduct: 0x0101
bcdDevice: 0x0316
iManufacturer: 0x01
0x0409: "Linux 3.2.0 with musb-hdrc"
iProduct: 0x02
0x0409: "Linux USB Audio Gadget"
iSerialNumber: 0x00
bNumConfigurations: 0x01
ConnectionStatus: DeviceConnected
Current Config Value: 0x01
Device Bus Speed: High
Device Address: 0x13
Open Pipes: 0
Configuration Descriptor:
wTotalLength: 0x0095
bNumInterfaces: 0x03
bConfigurationValue: 0x01
iConfiguration: 0x00
bmAttributes: 0xC0 (Bus Powered Self Powered )
MaxPower: 0x01 (2 Ma)
Interface Descriptor:
bInterfaceNumber: 0x00
bAlternateSetting: 0x00
bNumEndpoints: 0x00
bInterfaceClass: 0x01 (Audio)
bInterfaceSubClass: 0x01 (Audio Control)
bInterfaceProtocol: 0x00
iInterface: 0x04
0x0409: "Topology Control"
Audio Control Interface Header Descriptor:
bLength: 0x0A
bDescriptorType: 0x24
bDescriptorSubtype: 0x01
bcdADC: 0x0100
wTotalLength: 0x001F
bInCollection: 0x02
baInterfaceNr[1]: 0x01
baInterfaceNr[2]: 0x02
Audio Control Input Terminal Descriptor:
bLength: 0x0C
bDescriptorType: 0x24
bDescriptorSubtype: 0x02
bTerminalID: 0x02
wTerminalType: 0x0201 (Microphone)
bAssocTerminal: 0x00
bNrChannels: 0x02
wChannelConfig: 0x0003
iChannelNames: 0x00
iTerminal: 0x07
Audio Control Output Terminal Descriptor:
bLength: 0x09
bDescriptorType: 0x24
bDescriptorSubtype: 0x03
bTerminalID: 0x01
wTerminalType: 0x0301 (Speaker)
bAssocTerminal: 0x00
bSoruceID: 0x00
iTerminal: 0x09
Interface Descriptor:
bInterfaceNumber: 0x01
bAlternateSetting: 0x00
bNumEndpoints: 0x00
bInterfaceClass: 0x01 (Audio)
bInterfaceSubClass: 0x02 (Audio Streaming)
bInterfaceProtocol: 0x00
iInterface: 0x0B
0x0409: "Playback Inactive"
Interface Descriptor:
bInterfaceNumber: 0x01
bAlternateSetting: 0x01
bNumEndpoints: 0x01
bInterfaceClass: 0x01 (Audio)
bInterfaceSubClass: 0x02 (Audio Streaming)
bInterfaceProtocol: 0x00
iInterface: 0x0C
0x0409: "Playback Active"
Audio Streaming Class Specific Interface Descriptor:
bLength: 0x07
bDescriptorType: 0x24
bDescriptorSubtype: 0x01
bTerminalLink: 0x01
bDelay: 0x01
wFormatTag: 0x0001 (PCM)
Audio Streaming Format Type Descriptor:
bLength: 0x0B
bDescriptorType: 0x24
bDescriptorSubtype: 0x02
bFormatType: 0x01
bNrChannels: 0x00
bSubframeSize: 0x02
bBitResolution: 0x10
bSamFreqType: 0x01
tSamFreq[1]: 0x00BB80 (48000 Hz)
Endpoint Descriptor:
bEndpointAddress: 0x00 OUT
Transfer Type: Isochronous
wMaxPacketSize: 0x00C8 (200)
bInterval: 0x04
Audio Streaming Class Specific Audio Data Endpoint Descriptor:
bLength: 0x07
bDescriptorType: 0x25
bDescriptorSubtype: 0x01
bmAttributes: 0x00
bLockDelayUnits: 0x00
wLockDelay: 0x0000
Interface Descriptor:
bInterfaceNumber: 0x02
bAlternateSetting: 0x00
bNumEndpoints: 0x00
bInterfaceClass: 0x01 (Audio)
bInterfaceSubClass: 0x02 (Audio Streaming)
bInterfaceProtocol: 0x00
iInterface: 0x0D
0x0409: "Capture Inactive"
Interface Descriptor:
bInterfaceNumber: 0x02
bAlternateSetting: 0x01
bNumEndpoints: 0x01
bInterfaceClass: 0x01 (Audio)
bInterfaceSubClass: 0x02 (Audio Streaming)
bInterfaceProtocol: 0x00
iInterface: 0x0E
0x0409: "Capture Active"
Audio Streaming Class Specific Interface Descriptor:
bLength: 0x07
bDescriptorType: 0x24
bDescriptorSubtype: 0x01
bTerminalLink: 0x02
bDelay: 0x01
wFormatTag: 0x0001 (PCM)
Audio Streaming Format Type Descriptor:
bLength: 0x0B
bDescriptorType: 0x24
bDescriptorSubtype: 0x02
bFormatType: 0x01
bNrChannels: 0x00
bSubframeSize: 0x02
bBitResolution: 0x10
bSamFreqType: 0x01
tSamFreq[1]: 0x00BB80 (48000 Hz)
Endpoint Descriptor:
bEndpointAddress: 0x80 IN
Transfer Type: Isochronous
wMaxPacketSize: 0x00C8 (200)
bInterval: 0x04
Audio Streaming Class Specific Audio Data Endpoint Descriptor:
bLength: 0x07
bDescriptorType: 0x25
bDescriptorSubtype: 0x01
bmAttributes: 0x00
bLockDelayUnits: 0x00
wLockDelay: 0x0000
Why won't Windows install the UAC1 driver?
For my first question, I got an answer from the linux-usb mailing list. It turns out that 'epautoconf.c' does not change 'bEndpointAdress'. So I changed the value in the definition of 'bEndpointAdress' and it is correctly conveyed to the host now.
Windows installs the UAC1 driver correctly when I use this configuration:
ConnectionStatus: DeviceConnected
Current Config Value: 0x01
Device Bus Speed: High
Device Address: 0x11
Open Pipes: 0
Configuration Descriptor:
wTotalLength: 0x00E7
bNumInterfaces: 0x03
bConfigurationValue: 0x01
iConfiguration: 0x00
bmAttributes: 0xC0 (Bus Powered Self Powered )
MaxPower: 0x01 (2 Ma)
Interface Descriptor:
bInterfaceNumber: 0x00
bAlternateSetting: 0x00
bNumEndpoints: 0x00
bInterfaceClass: 0x01 (Audio)
bInterfaceSubClass: 0x01 (Audio Control)
bInterfaceProtocol: 0x00
iInterface: 0x00
Audio Control Interface Header Descriptor:
bLength: 0x0A
bDescriptorType: 0x24
bDescriptorSubtype: 0x01
bcdADC: 0x0100
wTotalLength: 0x0065
bInCollection: 0x02
baInterfaceNr[1]: 0x01
baInterfaceNr[2]: 0x02
Audio Control Input Terminal Descriptor:
bLength: 0x0C
bDescriptorType: 0x24
bDescriptorSubtype: 0x02
bTerminalID: 0x01
wTerminalType: 0x0201 (Microphone)
bAssocTerminal: 0x00
bNrChannels: 0x02
wChannelConfig: 0x0003
iChannelNames: 0x00
iTerminal: 0x00
Audio Control Feature Unit Descriptor:
bLength: 0x0A
bDescriptorType: 0x24
bDescriptorSubtype: 0x06
bUnitID: 0x02
bSourceID: 0x01
bControlSize: 0x01
bmaControls[0]:
03
bmaControls[1]:
00
bmaControls[2]:
00
iFeature: 0x00
Audio Control Input Terminal Descriptor:
bLength: 0x0C
bDescriptorType: 0x24
bDescriptorSubtype: 0x02
bTerminalID: 0x03
wTerminalType: 0x0402 (Headset)
bAssocTerminal: 0x09
bNrChannels: 0x02
wChannelConfig: 0x0003
iChannelNames: 0x00
iTerminal: 0x00
Audio Control Feature Unit Descriptor:
bLength: 0x0A
bDescriptorType: 0x24
bDescriptorSubtype: 0x06
bUnitID: 0x04
bSourceID: 0x03
bControlSize: 0x01
bmaControls[0]:
03
bmaControls[1]:
00
bmaControls[2]:
00
iFeature: 0x00
Audio Control Selector Unit Descriptor:
bLength: 0x06
bDescriptorType: 0x24
bDescriptorSubtype: 0x05
bUnitID: 0x05
bNrInPins: 0x01
baSourceID[1]: 0x04
iSelector: 0x09
Audio Control Output Terminal Descriptor:
bLength: 0x09
bDescriptorType: 0x24
bDescriptorSubtype: 0x03
bTerminalID: 0x06
wTerminalType: 0x0101 (USB streaming)
bAssocTerminal: 0x00
bSoruceID: 0x05
iTerminal: 0x00
Audio Control Input Terminal Descriptor:
bLength: 0x0C
bDescriptorType: 0x24
bDescriptorSubtype: 0x02
bTerminalID: 0x07
wTerminalType: 0x0101 (USB streaming)
bAssocTerminal: 0x00
bNrChannels: 0x02
wChannelConfig: 0x0003
iChannelNames: 0x00
iTerminal: 0x00
Audio Control Feature Unit Descriptor:
bLength: 0x0A
bDescriptorType: 0x24
bDescriptorSubtype: 0x06
bUnitID: 0x08
bSourceID: 0x0A
bControlSize: 0x01
bmaControls[0]:
01
bmaControls[1]:
02
bmaControls[2]:
02
iFeature: 0x00
Audio Control Output Terminal Descriptor:
bLength: 0x09
bDescriptorType: 0x24
bDescriptorSubtype: 0x03
bTerminalID: 0x09
wTerminalType: 0x0402 (Headset)
bAssocTerminal: 0x03
bSoruceID: 0x08
iTerminal: 0x00
Audio Control Mixer Unit Descriptor:
bLength: 0x0D
bDescriptorType: 0x24
bDescriptorSubtype: 0x04
bUnitID: 0x0A
bNrInPins: 0x02
baSourceID[1]: 0x07
baSourceID[2]: 0x02
bNrChannels: 0x02
wChannelConfig: 0x0003
iChannelNames: 0x00
bmControls:
00
iMixer: 0x00
Interface Descriptor:
bInterfaceNumber: 0x01
bAlternateSetting: 0x00
bNumEndpoints: 0x00
bInterfaceClass: 0x01 (Audio)
bInterfaceSubClass: 0x02 (Audio Streaming)
bInterfaceProtocol: 0x00
iInterface: 0x00
Interface Descriptor:
bInterfaceNumber: 0x01
bAlternateSetting: 0x01
bNumEndpoints: 0x01
bInterfaceClass: 0x01 (Audio)
bInterfaceSubClass: 0x02 (Audio Streaming)
bInterfaceProtocol: 0x00
iInterface: 0x00
Audio Streaming Class Specific Interface Descriptor:
bLength: 0x07
bDescriptorType: 0x24
bDescriptorSubtype: 0x01
bTerminalLink: 0x06
bDelay: 0x01
wFormatTag: 0x0001 (PCM)
Audio Streaming Format Type Descriptor:
bLength: 0x0B
bDescriptorType: 0x24
bDescriptorSubtype: 0x02
bFormatType: 0x01
bNrChannels: 0x02
bSubframeSize: 0x02
bBitResolution: 0x10
bSamFreqType: 0x01
tSamFreq[1]: 0x00BB80 (48000 Hz)
Endpoint Descriptor:
bEndpointAddress: 0x01 OUT
Transfer Type: Isochronous
wMaxPacketSize: 0x00C8 (200)
bInterval: 0x04
Audio Streaming Class Specific Audio Data Endpoint Descriptor:
bLength: 0x07
bDescriptorType: 0x25
bDescriptorSubtype: 0x01
bmAttributes: 0x01
bLockDelayUnits: 0x00
wLockDelay: 0x0000
Interface Descriptor:
bInterfaceNumber: 0x02
bAlternateSetting: 0x00
bNumEndpoints: 0x00
bInterfaceClass: 0x01 (Audio)
bInterfaceSubClass: 0x02 (Audio Streaming)
bInterfaceProtocol: 0x00
iInterface: 0x00
Interface Descriptor:
bInterfaceNumber: 0x02
bAlternateSetting: 0x01
bNumEndpoints: 0x01
bInterfaceClass: 0x01 (Audio)
bInterfaceSubClass: 0x02 (Audio Streaming)
bInterfaceProtocol: 0x00
iInterface: 0x00
Audio Streaming Class Specific Interface Descriptor:
bLength: 0x07
bDescriptorType: 0x24
bDescriptorSubtype: 0x01
bTerminalLink: 0x07
bDelay: 0x01
wFormatTag: 0x0001 (PCM)
Audio Streaming Format Type Descriptor:
bLength: 0x0B
bDescriptorType: 0x24
bDescriptorSubtype: 0x02
bFormatType: 0x01
bNrChannels: 0x02
bSubframeSize: 0x02
bBitResolution: 0x10
bSamFreqType: 0x01
tSamFreq[1]: 0x00BB80 (48000 Hz)
Endpoint Descriptor:
bEndpointAddress: 0x81 IN
Transfer Type: Isochronous
wMaxPacketSize: 0x00C8 (200)
bInterval: 0x04
Audio Streaming Class Specific Audio Data Endpoint Descriptor:
bLength: 0x07
bDescriptorType: 0x25
bDescriptorSubtype: 0x01
bmAttributes: 0x01
bLockDelayUnits: 0x01
wLockDelay: 0x0004
I am trying to implement Bluetooth on an existing embedded device. The controller I’m using is the LS Research TiWi-uB2, which uses the Ti CC2564 dual mode IC. The host is a LPC2378 microcontroller. The device needs to be discoverable by other devices (Android devices & PCs for the moment). There is no ready made BT stack for this device which suits me needs (cost, static memory allocation, memory size) so I’m writing my own stack.
Going through Volume 2 Part E of the specification I eventually got meaningful communication on the HCI, but the device does not ever appear to be ‘discoverable’ by anything else. At this point I’m only using the BR/EDR features rather than the LE features.
Here is a debug dump of the HCI interface (including the UART packet types):
BT_Reset
Tx: 0x01 0x03 0x0C 0x00
Rx: 0x04 0x0E 0x04 0x01 0x03 0x0C 0x00
Device info
Tx: 0x01 0x01 0x10 0x00
Rx: 0x04 0x0E 0x0C 0x01 0x01 0x10 0x00 0x06 0x00 0x00 0x06 0x0D 0x00 0x0F 0x1B
Local supported commands
Tx: 0x01 0x02 0x10 0x00
Rx: 0x04 0x0E 0x44 0x01 0x02 0x10 0x00 0xFF 0xFF 0xFF 0x03 0xCE 0xFF 0xFF 0xFF 0xFF
Local supported features
Tx: 0x01 0x03 0x10 0x00
Rx: 0x04 0x0E 0x0C 0x01 0x03 0x10 0x00 0xFF 0xFE 0x2D 0xFE 0xDB 0xFF 0x7B 0x87
Get device address
Tx: 0x01 0x09 0x10 0x00
Rx: 0x04 0x0E 0x0A 0x01 0x09 0x10 0x00 0x81 0xA6 0xD3 0x2F 0x18 0x00
Address: 00 18 2F D3 A6 81
Read buffer size
Tx: 0x01 0x05 0x10 0x00
Rx: 0x04 0x0E 0x0B 0x01 0x05 0x10 0x00 0xFD 0x03 0xB4 0x04 0x00 0x04 0x00
ACL len = 1021
Write buffer size
Tx: 0x01 0x33 0x0C 0x07 0xFC 0x00 0x00 0x00 0x00 0x00 0x00
Rx: 0x04 0x0E 0x04 0x01 0x33 0x0C 0x00
Write local name
Tx: 0x01 0x13 0x0C 0x08 0x42 0x54 0x5F 0x54 0x65 0x73 0x74 0x00
Rx: 0x04 0x0E 0x04 0x01 0x13 0x0C 0x00
Read class of device
Tx: 0x01 0x23 0x0C 0x00
Rx: 0x04 0x0E 0x07 0x01 0x23 0x0C 0x00 0x14 0x01 0x08
Write class of device
Tx: 0x01 0x24 0x0C 0x03 0x14 0x01 0x08
Rx: 0x04 0x0E 0x04 0x01 0x24 0x0C 0x00
Write scan enabled
Tx: 0x01 0x1A 0x0C 0x01 0x03
Rx: 0x04 0x0E 0x04 0x01 0x1A 0x0C 0x00
Finished
I can also do link inquiry:
Tx: 0x01 0x01 0x04 0x05 0x33 0x8B 0x9E 0x0A 0x0A
Rx: 0x04 0x0F 0x04 0x00 0x01 0x01 0x04
…
Rx: 0x04 0x01 0x01 0x00
But it does not find any devices.
I’m sure I’m missing something fairly obvious out, but can’t see what it might be. I can't see that the CC2564 needs to be specially treated to run in BR/EDR mode, and all the defaults seem reasonable.
Update
The module needs an initialization script (aka 'service pack'). See https://code.google.com/p/btstack/wiki/MSP430GettingStarted under 'Init Scripts'. The good news is that with the script the module is now discoverable. The bad news is that according to LS Research my own stack would not be Bluetooth SIG complaint - I would have to use the Bluetopia stack. It seems that everything is geared heavily to using the Ti processor.
At this point I'll have to wait until the BR/EDR/BLE modules with a higher level interface come on line.
Bluetooth compliance is only needed, when you are using public profiles (SPP for example), or when you expose your device in a connectable manner for other devices in public (like headsets or keyboards). Shortly, qualification is only needed if you are selling your device on global market as a "Bluetooth" device (so you can use the logo)...at least in my understanding...
And the service pack does not contain any part of the stack, so its completely royalty free.
And there are no Bluetooth specific operations (even discovery) permitted before loading the service pack according to this document:
cc256x guide