T3.6 USB Host - Bluetooth

If I run the viewer app with Bluetooth debug turned on, and with out the pairing option: JoystickController joystick(myusb);

The debug output I see includes:
Code:
USB Host Testing

ST7789_t3::init mode: 0
BluetoothController claim this=20007ec0 vid:pid=a12:1
    9 4 0 0 3 e0 1 1 0 7 5 81 3 10 0 1 7 5 2 2 40 0 1 7 5 82 2 40 0 1 9 4 1 0 2 e0 1 1 0 7 5 3 1 0 0 1 7 5 83 1 0 0 1 9 4 1 1 2 e0 1 1 0 7 5 
    3 1 9 0 1 7 5 83 1 9 0 1 9 4 1 2 2 e0 1 1 0 7 5 3 1 11 0 1 7 5 83 1 11 0 1 9 4 1 3 2 e0 1 1 0 7 5 3 1 19 0 1 7 5 83 1 19 0 1 9 4 1 4 2 e0 
    1 1 0 7 5 3 1 21 0 1 7 5 83 1 21 0 1 9 4 1 5 2 e0 1 1 0 7 5 3 1 31 0 1 7 5 83 1 31 0 1 
      rxep=1(16) txep=2(64) rx2ep=2(64)
HCI_RESET called (03 0c 00 )
    Control callback (bluetooth): 1 : 3 c 0 
BT rx_data(6): e 4 1 3 c 0 
    Command Completed! 
HCI_WRITE_CLASS_OF_DEV called (24 0c 03 04 08 00 )
    Control callback (bluetooth): 3 : 24 c 3 4 8 0 
BT rx_data(6): e 4 1 24 c 0 
    Command Completed! 
HCI_Read_BD_ADDR called (09 10 00 )
    Control callback (bluetooth): 4 : 9 10 0 
BT rx_data(12): e a 1 9 10 0 13 71 da 7d 1a 0 
    Command Completed! 
   BD Addr 0:1a:7d:da:71:13
HCI_Read_Local_Version_Information called (01 10 00 )
    Control callback (bluetooth): 4 : 1 10 0 
BT rx_data(14): e c 1 1 10 0 6 bb 22 6 a 0 bb 22 
    Command Completed! 
    Local Version: 6
HCI_WRITE_SCAN_ENABLE called(1a 0c 01 02 )
    Control callback (bluetooth): 0 : 1a c 1 2 
BT rx_data(6): e 4 1 1a c 0 
    Command Completed! 
Write_Scan_enable Completed
*** Device Bluet a12:1 - connected ***
BT rx_data(12): 4 a dc 13 d6 1b aa 9c 8 5 0 1 
    Event: Incoming Connect -  dc:13:d6:1b:aa:9c CL:508 LT:1
      Peripheral device
        Gamepad
BluetoothController::find_driver  driver 20004bd8
Keyboard Controller::claim_bluetooth - Class 508
  driver 20004e78
Keyboard Controller::claim_bluetooth - Class 508
  driver 20004a48
MouseController Controller::claim_bluetooth - Class 508
  driver 20007978
    *** Claimed ***
HCI_OP_REMOTE_NAME_REQ called (19 04 0a dc 13 d6 1b aa 9c 01 00 00 00 )
*** BTHID Device tablet 0:0 - connected ***
    Control callback (bluetooth): 0 : 19 4 a dc 13 d6 1b aa 9c 1 0 0 0 
BT rx_data(6): f 4 0 1 19 4 
    Command 419 Status 0
BT rx_data(16): 7 ff 0 dc 13 d6 1b aa 9c 58 62 6f 78 20 57 69 
BT rx_data(16): 72 65 6c 65 73 73 20 43 6f 6e 74 72 6f 6c 6c 65 
BT rx_data(16): 72 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 
BT rx_data(16): 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 
BT rx_data(16): 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 
BT rx_data(16): 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 
BT rx_data(16): 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 
BT rx_data(16): 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 
BT rx_data(16): 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 
BT rx_data(16): 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 
BT rx_data(16): 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 
BT rx_data(16): 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 
BT rx_data(16): 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 
BT rx_data(16): 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 
BT rx_data(16): 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 
BT rx_data(16): 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 
BT rx_data(1): 0 
    Event: handle_hci_remote_name_complete(0)
    Remote Name: Xbox Wireless Controller
HCI_OP_ACCEPT_CONN_REQ called (09 04 07 dc 13 d6 1b aa 9c 00 )
    Control callback (bluetooth): 0 : 9 4 7 dc 13 d6 1b aa 9c 0 
BT rx_data(6): f 4 0 1 9 4 
    Command 409 Status 0
BT rx_data(10): 12 8 0 dc 13 d6 1b aa 9c 0 
BT rx_data(13): 3 b 0 48 0 dc 13 d6 1b aa 9c 1 0 
    Connection Complete - ST:0 LH:48
BT rx_data(9): 20 7 dc 13 d6 1b aa 9c 1 
BT rx_data(5): 1b 3 48 0 5 
BT rx_data(8): 17 6 dc 13 d6 1b aa 9c 
    Event: Link Key Request dc:13:d6:1b:aa:9c
HCI_LINK_KEY_NEG_REPLY called (0c 04 06 dc 13 d6 1b aa 9c )
    Control callback (bluetooth): 120 : c 4 6 dc 13 d6 1b aa 9c 
BT rx_data(12): e a 1 c 4 0 dc 13 d6 1b aa 9c 
    Command Completed! 
BT rx_data(6): 5 4 0 48 0 15 
    Event: HCI Disconnect complete(0): handle: 48, reason:15
*** BTHID Device tablet - disconnected ***
Note: Arduino 1.8.13 plus new beta :D

Now if I try it with the pairingversion: BluetoothController bluet(myusb, true, "0000"); // Version does pairing to device
Code:
USB Host Testing

ST7789_t3::init mode: 0
BluetoothController claim this=20007ec0 vid:pid=a12:1
    9 4 0 0 3 e0 1 1 0 7 5 81 3 10 0 1 7 5 2 2 40 0 1 7 5 82 2 40 0 1 9 4 1 0 2 e0 1 1 0 7 5 3 1 0 0 1 7 5 83 1 0 0 1 9 4 1 1 2 e0 1 1 0 7 5 
    3 1 9 0 1 7 5 83 1 9 0 1 9 4 1 2 2 e0 1 1 0 7 5 3 1 11 0 1 7 5 83 1 11 0 1 9 4 1 3 2 e0 1 1 0 7 5 3 1 19 0 1 7 5 83 1 19 0 1 9 4 1 4 2 e0 
    1 1 0 7 5 3 1 21 0 1 7 5 83 1 21 0 1 9 4 1 5 2 e0 1 1 0 7 5 3 1 31 0 1 7 5 83 1 31 0 1 
      rxep=1(16) txep=2(64) rx2ep=2(64)
HCI_RESET called (03 0c 00 )
    Control callback (bluetooth): 1 : 3 c 0 
BT rx_data(6): e 4 1 3 c 0 
    Command Completed! 
HCI_WRITE_CLASS_OF_DEV called (24 0c 03 04 08 00 )
    Control callback (bluetooth): 3 : 24 c 3 4 8 0 
BT rx_data(6): e 4 1 24 c 0 
    Command Completed! 
HCI_Read_BD_ADDR called (09 10 00 )
    Control callback (bluetooth): 4 : 9 10 0 
BT rx_data(12): e a 1 9 10 0 13 71 da 7d 1a 0 
    Command Completed! 
   BD Addr 0:1a:7d:da:71:13
HCI_Read_Local_Version_Information called (01 10 00 )
    Control callback (bluetooth): 4 : 1 10 0 
BT rx_data(14): e c 1 1 10 0 6 bb 22 6 a 0 bb 22 
    Command Completed! 
    Local Version: 6
HCI_WRITE_INQUIRY_MODE called (45 0c 01 02 )
    Control callback (bluetooth): 6 : 45 c 1 2 
BT rx_data(6): e 4 1 45 c 0 
    Command Completed! 
HCI_Set_Event_Mask called (01 0c 08 ff ff ff ff ff 5f 00 00 )
    Control callback (bluetooth): 7 : 1 c 8 ff ff ff ff ff 5f 0 0 
BT rx_data(6): e 4 1 1 c 0 
    Command Completed! 
HCI_INQUIRY called (01 04 05 33 8b 9e 30 0a )
    Control callback (bluetooth): 8 : 1 4 5 33 8b 9e 30 a 
BT rx_data(6): f 4 0 1 1 4 
    Command 401 Status 0
*** Device Bluet a12:1 - connected ***
BT rx_data(16): 2f ff 1 16 ac b3 26 3f c8 1 2 8 5 0 71 74 
BT rx_data(16): a0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 
BT rx_data(16): 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 
BT rx_data(16): 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 
BT rx_data(16): 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 
BT rx_data(16): 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 
BT rx_data(16): 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 
BT rx_data(16): 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 
BT rx_data(16): 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 
BT rx_data(16): 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 
BT rx_data(16): 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 
BT rx_data(16): 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 
BT rx_data(16): 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 
BT rx_data(16): 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 
BT rx_data(16): 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 
BT rx_data(16): 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 
BT rx_data(1): 0 
    Extended Inquiry Result - Count: 1
      BD:16:ac:b3:26:3f:c8, PS:1, class: 508
      Peripheral device
        Gamepad
BluetoothController::find_driver  driver 20004bd8
Keyboard Controller::claim_bluetooth - Class 508
  driver 20004e78
Keyboard Controller::claim_bluetooth - Class 508
  driver 20004a48
MouseController Controller::claim_bluetooth - Class 508
  driver 20007978
    *** Claimed ***
HCI_INQUIRY_CANCEL called (02 04 00 )
*** BTHID Device tablet 0:0 - connected ***
    Control callback (bluetooth): 100 : 2 4 0 
BT rx_data(6): e 4 1 2 4 0 
    Command Completed! 
HCI_CREATE_CONNECTION called (05 04 0d 16 ac b3 26 3f c8 18 cc 01 00 00 00 00 )
    Control callback (bluetooth): 101 : 5 4 d 16 ac b3 26 3f c8 18 cc 1 0 0 0 0 
BT rx_data(6): f 4 0 1 5 4 
    Command 405 Status 0
BT rx_data(13): 3 b 0 48 0 16 ac b3 26 3f c8 1 0 
    Connection Complete - ST:0 LH:48
HCI_AUTH_REQUESTED called (11 04 02 48 00 )
    Control callback (bluetooth): 110 : 11 4 2 48 0 
BT rx_data(6): f 4 0 0 11 4 
    Command 411 Status 0

=====================
BT rx2_data(16): 48 20 c 0 8 0 1 0 2 1 4 0 1 0 40 0 
    L2CAP Connection Request: ID: 1, PSM: 1, SCID: 40
BT rx_data(5): 1b 3 48 0 5 
BT rx_data(8): 17 6 16 ac b3 26 3f c8 
    Event: Link Key Request 16:ac:b3:26:3f:c8
HCI_LINK_KEY_NEG_REPLY called (0c 04 06 16 ac b3 26 3f c8 )
BT rx_data(6): f 4 0 1 0 0 
    Command 0 Status 0
    Control callback (bluetooth): 120 : c 4 6 16 ac b3 26 3f c8 
BT rx_data(12): e a 1 c 4 0 16 ac b3 26 3f c8 
    Command Completed! 
BT rx_data(8): 16 6 16 ac b3 26 3f c8 
    Event: Pin Code Request 16:ac:b3:26:3f:c8
HCI_PIN_CODE_REPLY called (0d 04 17 16 ac b3 26 3f c8 04 30 30 30 30 00 00 00 00 00 00 00 00 00 00 00 00 )
    Control callback (bluetooth): 130 : d 4 17 16 ac b3 26 3f c8 4 30 30 30 30 0 0 0 0 0 0 0 0 0 0 0 0 
BT rx_data(12): e a 1 d 4 0 16 ac b3 26 3f c8 
    Command Completed! 
BT rx_data(5): 6 3 6 48 0 
    Event: HCI Authentication complete(6): handle: 48
ConnectionRequest called(48 20 0c 00 08 00 01 00 02 00 04 00 11 00 70 00 )
tx_data callback (bluetooth): 0 : 48 20 c 0 8 0 1 0 2 0 4 0 11 0 70 0 
BT rx_data(7): 13 5 1 48 0 1 0 

=====================
BT rx2_data(20): 48 20 10 0 c 0 1 0 3 0 8 0 40 0 70 0 3 0 0 0 
    L2CAP Connection Response: ID: 0, Dest:40, Source:70, Result:3, Status: 0
      Control Response
L2CAP_ConfigRequest called(48 20 10 00 0c 00 01 00 04 00 08 00 40 00 00 00 01 02 ff ff )
tx_data callback (bluetooth): 0 : 48 20 10 0 c 0 1 0 4 0 8 0 40 0 0 0 1 2 ff ff 
BT rx_data(7): 13 5 1 48 0 1 0 

=====================
BT rx2_data(18): 48 20 e 0 a 0 1 0 1 0 6 0 2 0 40 0 0 0 
    L2CAP command reject: ID: 0, length:6, Reason:2,  Data: 0 40

Note: it looks like it is failing a config request... Need to see what we do then?
 
Good Morning
I was trying to trace that this morning as well but didnt see where we were calling it from or what we were sending
 
I am completely rusty on this!!!
Code:
BT rx2_data(20): 48 20 10 0 c 0 1 0 3 0 8 0 40 0 70 0 3 0 0 0 
    L2CAP Connection Response: ID: 0, Dest:40, Source:70, Result:3, Status: 0
      Control Response
L2CAP_ConfigRequest called(48 20 10 00 0c 00 01 00 04 00 08 00 40 00 00 00 01 02 ff ff )
tx_data callback (bluetooth): 0 : 48 20 10 0 c 0 1 0 4 0 8 0 40 0 0 0 1 2 ff ff 
BT rx_data(7): 13 5 1 48 0 1 0 

=====================
BT rx2_data(18): 48 20 e 0 a 0 1 0 1 0 6 0 2 0 40 0 0 0 
    L2CAP command reject: ID: 0, length:6, Reason[COLOR="#FF0000"]:2[/COLOR],  Data: [COLOR="#FF0000"]0 40[/COLOR]

So the last command we sent was the config request...

The last message we received back was the command reject.

Looking at some Linux Sources and the like for rejection ...
Code:
/* L2CAP Command rej. reasons */
#define L2CAP_REJ_NOT_UNDERSTOOD	0x0000
#define L2CAP_REJ_MTU_EXCEEDED		0x0001
#define L2CAP_REJ_INVALID_CID		0x0002
So it is saying the CID is not valid... and data is 0 40...

So we sent that with the code:
Code:
void BluetoothController::sendl2cap_ConfigRequest(uint16_t handle, uint8_t rxid, uint16_t dcid) {
	 	uint8_t l2capbuf[12];
        l2capbuf[0] = L2CAP_CMD_CONFIG_REQUEST; // Code
        l2capbuf[1] = rxid; // Identifier
        l2capbuf[2] = 0x08; // Length
        l2capbuf[3] = 0x00;
        l2capbuf[4] = dcid & 0xff; // Destination CID
        l2capbuf[5] = (dcid >> 8) & 0xff;
        l2capbuf[6] = 0x00; // Flags
        l2capbuf[7] = 0x00;
        l2capbuf[8] = 0x01; // Config Opt: type = MTU (Maximum Transmission Unit) - Hint
        l2capbuf[9] = 0x02; // Config Opt: length
        l2capbuf[10] = 0xFF; // MTU
        l2capbuf[11] = 0xFF;

		DBGPrintf("L2CAP_ConfigRequest called(");
        sendL2CapCommand(handle, l2capbuf, sizeof(l2capbuf));
}
So it looks like dcid...
Structure in Bluetooth DOC In the version I have Vol 3, Part A section 4.4 (P1754)


Now need to look to see where we grab that from.
 
@KurtE
I just found that I can do a BT snoop from my Android phone (glad I kept it). Anyway I attaching it for reference but you will need to download and install Wireshark to read it in plain English:
 

Attachments

  • btsnoop_hci.zip
    9.3 KB · Views: 54
@KurtE
I just found that I can do a BT snoop from my Android phone (glad I kept it). Anyway I attaching it for reference but you will need to download and install Wireshark to read it in plain English:

What's the Android BT snoop app called? And maker?
 
Actually it’s built in. Go to settings then developer options the enable hci log. Then turn on by and pair with device. I disconnected by then, went to root and the log file was their. To decode it use wireshark and you will see everything u need. Need my nap now then back to it.
 
@KurtE
To save a bit of time this is a bit of an extract from the log on config request and response:
Code:
No.	Time	Source	Destination	Protocol	Length	Info
209	21.090794	Microsof_db:a7:e9 (Xbox Wireless Controller)	localhost (SAMSUNG-SM-G900V)	L2CAP	17	Rcvd Connection Request (SDP, SCID: 0x0040)
0000   02 0c 20 0c 00 08 00 01   00 02 01 04 00 01 00 40
0010   00

0000   02 0c 20 10 00 0c 00 01   00 03 01 08 00 41 00 40   .. ..........A.@
0010   00 01 00 00 00                                    .....

211	21.091881	Microsof_db:a7:e9 (Xbox Wireless Controller)	localhost (SAMSUNG-SM-G900V)	L2CAP	21	Rcvd Information Response (Extended Features Mask, Success)
0000   02 0c 20 10 00 0c 00 01   00 0b 02 08 00 02 00 00   .. .............
0010   00 10 00 00 00                                    .....

212	21.092734	localhost (SAMSUNG-SM-G900V)	Microsof_db:a7:e9 (Xbox Wireless Controller)	L2CAP	21	Sent Connection Response - Success (SCID: 0x0040, DCID: 0x0041)
0000   02 0c 20 10 00 0c 00 01    00 03 01 08 00 41 00 40   .. ..........A.@
0010   00 00 00 00 00                                    .....


213	21.093100	controller	host	HCI_EVT	7	Rcvd Command Status (Read Remote Supported Features)
0000   04 0f 04 00 01 1b 04                              .......

214	21.093517	localhost (SAMSUNG-SM-G900V)	Microsof_db:a7:e9 (Xbox Wireless Controller)	L2CAP	21	Sent Configure Request (DCID: 0x0040)
0000   02 0c 20 10 00 0c 00 01     00 04 03 08 00 40 00 00
0010   00 01 02 a0 02


215	21.093906	host	controller	HCI_CMD	8	Sent Write Link Policy Settings
0000   01 0d 08 04 0c 00 05 00

216	21.094305	controller	host	HCI_EVT	14	Rcvd Read Remote Supported Features
0000   04 0b 0b 00 0c 00 bf 3e 8d fe db fd 7b 87


217	21.097590	controller	host	HCI_EVT	9	Rcvd Command Complete (Write Link Policy Settings)
0000   04 0e 06 01 0d 08 00 0c 00


218	21.098102	host	controller	HCI_CMD	8	Sent Write Link Supervision Timeout
0000   01 37 0c 04 0c 00 40 1f


219	21.098508	controller	host	HCI_EVT	8	Rcvd Number of Completed Packets
0000   04 13 05 01 0c 00 02 00


220	21.098927	Microsof_db:a7:e9 (Xbox Wireless Controller)	localhost (SAMSUNG-SM-G900V)	L2CAP	21	Rcvd Configure Request (DCID: 0x0041)
0000   02 0c 20 10 00 0c 00 01    00 04 02 08 00 41 00 00
0010   00 01 02 c8 05


221	21.099481	localhost (SAMSUNG-SM-G900V)	Microsof_db:a7:e9 (Xbox Wireless Controller)	L2CAP	19	Sent Configure Response - Success (SCID: 0x0040)
0000   02 0c 20 0e 00 0a 00 01     00 05 02 06 00 40 00 00
0010   00 00 00


222	21.099861	controller	host	HCI_EVT	8	Rcvd Number of Completed Packets
0000   04 13 05 01 0c 00 02 00


223	21.100263	controller	host	HCI_EVT	9	Rcvd Command Complete (Write Link Supervision Timeout)
0000   04 0e 06 01 37 0c 00 0c 00


224	21.100673	host	controller	HCI_CMD	6	Sent Authentication Requested
0000   01 11 04 02 0c 00


225	21.101116	Microsof_db:a7:e9 (Xbox Wireless Controller)	localhost (SAMSUNG-SM-G900V)	L2CAP	19	Rcvd Configure Response - Success (SCID: 0x0041)
0000   02 0c 20 0e 00 0a 00 01     00 05 03 06 00 41 00 00
0010   00 00 00

226	21.101589	controller	host	HCI_EVT	7	Rcvd Command Status (Authentication Requested)
0000   04 0f 04 00 01 11 04
 
Thanks @mjs513 - I was looking at some of the data from the Wireshark app... I tried changing the data part of the config request, to match some of your data and it did not help. Will look some more today.
 
@KurtE
BT Dump from host shield:
Code:
HID Bluetooth Library Started
Bluetooth Dongle Initialized
No response to HCI Reset
HCI Reset complete
Write class of device
Local Bluetooth Address: 00:15:83:F6:2B:28
Please enable discovery of your device
Gamepad found
HID device found
Now just create the instance like so:
BTHID bthid(&Btd);
And then press any button on the device
Connecting to HID device
Connected to HID device

L2CAP Connection Request - PSM: 00 01 SCID: 00 40 Identifier: 04

SDP Incoming Connection Request

L2CAP_COMMAND: 0x48 - Channel ID: 00 01
 Data:  48 20 10 00 0C 00 01 00 03 04 08 00 50 00 40 00 01 00 00 00

L2CAP_COMMAND: 0x48 - Channel ID: 00 01
 Data:  48 20 10 00 0C 00 01 00 03 04 08 00 50 00 40 00 00 00 00 00

L2CAP_COMMAND: 0x48 - Channel ID: 00 01
 Data:  48 20 10 00 0C 00 01 00 04 05 08 00 40 00 00 00 01 02 FF FF

Received Key Request

Bluetooth pin is set too: 0000

SDP Configuration Request

L2CAP_COMMAND: 0x48 - Channel ID: 00 01
 Data:  48 20 12 00 0E 00 01 00 05 05 0A 00 40 00 00 00 00 00 01 02 A0 02

SDP Configuration Complete
SDP Successfully Configured
SDP_SERVICE_SEARCH_ATTRIBUTE_REQUEST
UUID: 1200
Length: 000D
Data: 35 03 19 12 00 00 64 35 03 09 00 01 00 

L2CAP_COMMAND: 0x48 - Channel ID: 00 40
 Data:  48 20 0E 00 0A 00 40 00 07 00 02 00 05 00 02 35 00 00

SDP_SERVICE_SEARCH_REQUEST

L2CAP_COMMAND: 0x48 - Channel ID: 00 40
 Data:  48 20 0E 00 0A 00 40 00 03 00 03 00 05 00 00 00 00 00

Disconnect Request: SDP Channel
Disconnected SDP Channel

L2CAP_COMMAND: 0x48 - Channel ID: 00 01
 Data:  48 20 0C 00 08 00 01 00 07 06 04 00 50 00 40 00

Pairing Failed: 06

HCI Disconnected from Device
Wait For Incoming Connection

By the way if I connect the xbox one via usb it doesnt work but with the host shield it works.
 
Thanks,

Here is the current one for my XBox One S...
Code:
USB Host Testing

960

BluetoothController claim this=20005120 vid:pid=a12:1
    9 4 0 0 3 e0 1 1 0 7 5 81 3 10 0 1 7 5 2 2 40 0 1 7 5 82 2 40 0 1 9 4 1 0 2 e0 1 1 0 7 5 3 1 0 0 1 7 5 83 1 0 0 1 9 4 1 1 2 e0 1 1 0 7 5 
    3 1 9 0 1 7 5 83 1 9 0 1 9 4 1 2 2 e0 1 1 0 7 5 3 1 11 0 1 7 5 83 1 11 0 1 9 4 1 3 2 e0 1 1 0 7 5 3 1 19 0 1 7 5 83 1 19 0 1 9 4 1 4 2 e0 
    1 1 0 7 5 3 1 21 0 1 7 5 83 1 21 0 1 9 4 1 5 2 e0 1 1 0 7 5 3 1 31 0 1 7 5 83 1 31 0 1 
      rxep=1(16) txep=2(64) rx2ep=2(64)
HCI_RESET called (03 0c 00 )
BT rx_data(6): e 4 1 3 c 0 
HCI_WRITE_CLASS_OF_DEV called (24 0c 03 04 08 00 )
BT rx_data(6): e 4 1 24 c 0 
HCI_Read_BD_ADDR called (09 10 00 )
BT rx_data(12): e a 1 9 10 0 13 71 da 7d 1a 0 
   BD Addr 0:1a:7d:da:71:13
HCI_Read_Local_Version_Information called (01 10 00 )
BT rx_data(14): e c 1 1 10 0 6 bb 22 6 a 0 bb 22 
    Local Version: 6
HCI_WRITE_INQUIRY_MODE called (45 0c 01 02 )
BT rx_data(6): e 4 1 45 c 0 
HCI_Set_Event_Mask called (01 0c 08 ff ff ff ff ff 5f 00 00 )
BT rx_data(6): e 4 1 1 c 0 
HCI_INQUIRY called (01 04 05 33 8b 9e 30 0a )
BT rx_data(6): f 4 0 1 1 4 
BT rx_data(16): 2f ff 1 16 ac b3 26 3f c8 1 2 8 5 0 f3 24 
BT rx_data(16): a0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 
BT rx_data(16): 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 
BT rx_data(16): 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 
BT rx_data(16): 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 
BT rx_data(16): 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 
BT rx_data(16): 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 
BT rx_data(16): 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 
BT rx_data(16): 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 
BT rx_data(16): 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 
BT rx_data(16): 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 
BT rx_data(16): 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 
BT rx_data(16): 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 
BT rx_data(16): 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 
BT rx_data(16): 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 
BT rx_data(16): 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 
BT rx_data(1): 0 
    Extended Inquiry Result - Count: 1
      BD:16:ac:b3:26:3f:c8, PS:1, class: 508
      Peripheral device
        Gamepad
BluetoothController::find_driver  driver 20005858
    *** Claimed ***
HCI_INQUIRY_CANCEL called (02 04 00 )
BT rx_data(6): e 4 1 2 4 0 
HCI_CREATE_CONNECTION called (05 04 0d 16 ac b3 26 3f c8 18 cc 01 00 00 00 00 )
BT rx_data(6): f 4 0 1 5 4 
*** Device Bluet a12:1 - connected ***
  product: CSR8510 A10
  BDADDR: 13:71:da:7d:1a:0
*** BTHID Device Joystick1 0:0 - connected ***
  Serial:  
BT rx_data(13): 3 b 0 48 0 16 ac b3 26 3f c8 1 0 
    Connection Complete - ST:0 LH:48
HCI_AUTH_REQUESTED called (11 04 02 48 00 )
BT rx_data(6): f 4 0 0 11 4 

=====================
BT rx2_data(16): 48 20 c 0 8 0 1 0 2 1 4 0 1 0 40 0 
    L2CAP Connection Request: ID: 1, PSM: 1, SCID: 40
BT rx_data(5): 1b 3 48 0 5 
BT rx_data(8): 17 6 16 ac b3 26 3f c8 
    Event: Link Key Request 16:ac:b3:26:3f:c8
HCI_LINK_KEY_NEG_REPLY called (0c 04 06 16 ac b3 26 3f c8 )
BT rx_data(6): f 4 0 1 0 0 
BT rx_data(12): e a 1 c 4 0 16 ac b3 26 3f c8 
BT rx_data(8): 16 6 16 ac b3 26 3f c8 
    Event: Pin Code Request 16:ac:b3:26:3f:c8
HCI_PIN_CODE_REPLY called (0d 04 17 16 ac b3 26 3f c8 04 30 30 30 30 00 00 00 00 00 00 00 00 00 00 00 00 )
BT rx_data(12): e a 1 d 4 0 16 ac b3 26 3f c8 
BT rx_data(5): 6 3 6 48 0 
    Event: HCI Authentication complete(6): handle: 48
ConnectionRequest called(48 20 0c 00 08 00 01 00 02 00 04 00 11 00 70 00 )
BT rx_data(7): 13 5 1 48 0 1 0 

=====================
BT rx2_data(20): 48 20 10 0 c 0 1 0 3 0 8 0 40 0 70 0 3 0 0 0 
    L2CAP Connection Response: ID: 0, Dest:40, Source:70, Result:3, Status: 0
      Control Response
L2CAP_ConfigRequest called(48 20 10 00 0c 00 01 00 04 00 08 00 40 00 00 00 01 02 ff ff )

=====================
BT rx2_data(18): 48 20 e 0 a 0 1 0 1 0 6 0 2 0 40 0 0 0 
    L2CAP command reject: ID: 0, length:6, Reason:2,  Data: 0 40 
BT rx_data(7): 13 5 1 48 0 1 0

And I forgot I had another controller I never took out of box after purchase :0 a one for the Switch, which also does not work:
It's BT stuff shows:
Code:
USB Host Testing

960

BluetoothController claim this=20005120 vid:pid=a12:1
    9 4 0 0 3 e0 1 1 0 7 5 81 3 10 0 1 7 5 2 2 40 0 1 7 5 82 2 40 0 1 9 4 1 0 2 e0 1 1 0 7 5 3 1 0 0 1 7 5 83 1 0 0 1 9 4 1 1 2 e0 1 1 0 7 5 
    3 1 9 0 1 7 5 83 1 9 0 1 9 4 1 2 2 e0 1 1 0 7 5 3 1 11 0 1 7 5 83 1 11 0 1 9 4 1 3 2 e0 1 1 0 7 5 3 1 19 0 1 7 5 83 1 19 0 1 9 4 1 4 2 e0 
    1 1 0 7 5 3 1 21 0 1 7 5 83 1 21 0 1 9 4 1 5 2 e0 1 1 0 7 5 3 1 31 0 1 7 5 83 1 31 0 1 
      rxep=1(16) txep=2(64) rx2ep=2(64)
HCI_RESET called (03 0c 00 )
BT rx_data(6): e 4 1 3 c 0 
HCI_WRITE_CLASS_OF_DEV called (24 0c 03 04 08 00 )
BT rx_data(6): e 4 1 24 c 0 
HCI_Read_BD_ADDR called (09 10 00 )
BT rx_data(12): e a 1 9 10 0 13 71 da 7d 1a 0 
   BD Addr 0:1a:7d:da:71:13
HCI_Read_Local_Version_Information called (01 10 00 )
BT rx_data(14): e c 1 1 10 0 6 bb 22 6 a 0 bb 22 
    Local Version: 6
HCI_WRITE_INQUIRY_MODE called (45 0c 01 02 )
BT rx_data(6): e 4 1 45 c 0 
HCI_Set_Event_Mask called (01 0c 08 ff ff ff ff ff 5f 00 00 )
BT rx_data(6): e 4 1 1 c 0 
HCI_INQUIRY called (01 04 05 33 8b 9e 30 0a )
BT rx_data(6): f 4 0 1 1 4 
*** Device Bluet a12:1 - connected ***
  product: CSR8510 A10
  BDADDR: 13:71:da:7d:1a:0
BT rx_data(16): 2f ff 1 25 63 20 46 84 a6 1 2 8 25 0 3b 65 
BT rx_data(16): e0 5 3 24 11 0 12 f 9 50 72 6f 20 43 6f 6e 
BT rx_data(16): 74 72 6f 6c 6c 65 72 9 10 2 0 7e 5 9 20 0 
BT rx_data(16): 1 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 
BT rx_data(16): 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 
BT rx_data(16): 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 
BT rx_data(16): 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 
BT rx_data(16): 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 
BT rx_data(16): 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 
BT rx_data(16): 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 
BT rx_data(16): 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 
BT rx_data(16): 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 
BT rx_data(16): 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 
BT rx_data(16): 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 
BT rx_data(16): 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 
BT rx_data(16): 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 
BT rx_data(1): 0 
    Extended Inquiry Result - Count: 1
      BD:25:63:20:46:84:a6, PS:1, class: 2508
      Local Name: Pro Controller
      Peripheral device
        Gamepad
BluetoothController::find_driver  driver 20005858
    *** Claimed ***
HCI_INQUIRY_CANCEL called (02 04 00 )
*** BTHID Device Joystick1 0:0 - connected ***
  product: Pro Controller
  Serial:  
BT rx_data(6): e 4 1 2 4 0 
HCI_CREATE_CONNECTION called (05 04 0d 25 63 20 46 84 a6 18 cc 01 00 00 00 00 )
BT rx_data(6): f 4 0 1 5 4 
BT rx_data(13): 3 b 0 48 0 25 63 20 46 84 a6 1 0 
    Connection Complete - ST:0 LH:48
HCI_AUTH_REQUESTED called (11 04 02 48 00 )
BT rx_data(6): f 4 0 0 11 4 
BT rx_data(5): 1b 3 48 0 5 
BT rx_data(8): 17 6 25 63 20 46 84 a6 
    Event: Link Key Request 25:63:20:46:84:a6
HCI_LINK_KEY_NEG_REPLY called (0c 04 06 25 63 20 46 84 a6 )
BT rx_data(6): f 4 0 1 0 0 
BT rx_data(12): e a 1 c 4 0 25 63 20 46 84 a6 
BT rx_data(8): 16 6 25 63 20 46 84 a6 
    Event: Pin Code Request 25:63:20:46:84:a6
HCI_PIN_CODE_REPLY called (0d 04 17 25 63 20 46 84 a6 04 30 30 30 30 00 00 00 00 00 00 00 00 00 00 00 00 )
BT rx_data(12): e a 1 d 4 0 25 63 20 46 84 a6 
BT rx_data(5): 6 3 6 48 0 
    Event: HCI Authentication complete(6): handle: 48
ConnectionRequest called(48 20 0c 00 08 00 01 00 02 00 04 00 11 00 70 00 )

=====================
BT rx2_data(20): 48 20 10 0 c 0 1 0 3 0 8 0 40 0 70 0 0 0 0 0 
    L2CAP Connection Response: ID: 0, Dest:40, Source:70, Result:0, Status: 0
      Control Response
L2CAP_ConfigRequest called(48 20 10 00 0c 00 01 00 04 00 08 00 40 00 00 00 01 02 ff ff )
BT rx_data(7): 13 5 1 48 0 1 0 

=====================
BT rx2_data(20): 48 20 10 0 c 0 1 0 4 3 8 0 70 0 0 0 1 2 48 0 
    L2CAP config Request: ID: 3, Dest:70, Flags:0,  Options: 1 2 48 0
      Control Configuration request
L2CAP_ConfigResponse called(48 20 12 00 0e 00 01 00 05 03 0a 00 40 00 00 00 00 00 01 02 a0 02 )
BT rx_data(7): 13 5 1 48 0 1 0 

=====================
BT rx2_data(18): 48 20 e 0 a 0 1 0 5 0 6 0 70 0 0 0 0 0 
    L2CAP config Response: ID: 0, Source:70, Flags:0, Result:0, Config: 48
Set HID Protocol 0 (48 20 05 00 01 00 40 00 70 )
ConnectionRequest called(48 20 0c 00 08 00 01 00 02 01 04 00 13 00 71 00 )
BT rx_data(7): 13 5 1 48 0 1 0 
BT rx_data(7): 13 5 1 48 0 1 0 

=====================
BT rx2_data(20): 48 20 10 0 c 0 1 0 3 1 8 0 41 0 71 0 0 0 0 0 
    L2CAP Connection Response: ID: 1, Dest:41, Source:71, Result:0, Status: 0
      Interrupt Response
L2CAP_ConfigRequest called(48 20 10 00 0c 00 01 00 04 02 08 00 41 00 00 00 01 02 ff ff )
BT rx_data(7): 13 5 1 48 0 1 0 

=====================
BT rx2_data(20): 48 20 10 0 c 0 1 0 4 4 8 0 71 0 0 0 1 2 48 0 
    L2CAP config Request: ID: 4, Dest:71, Flags:0,  Options: 1 2 48 0
      Interrupt Configuration request
L2CAP_ConfigResponse called(48 20 12 00 0e 00 01 00 05 04 0a 00 41 00 00 00 00 00 01 02 a0 02 )
BT rx_data(7): 13 5 1 48 0 1 0 

=====================
BT rx2_data(18): 48 20 e 0 a 0 1 0 5 2 6 0 71 0 0 0 0 0 
    L2CAP config Response: ID: 2, Source:71, Flags:0, Result:0, Config: 48
HCI_WRITE_SCAN_ENABLE called(1a 0c 01 02 )
BT rx_data(7): 13 5 1 48 0 1 0 
BT rx_data(6): e 4 1 1a c 0 
Write_Scan_enable Completed

I have not tried plugging that one directly in yet.
 
@KurtE
Morning. Got that last night for both of those controllers. Neither one works wired either to save you some time :)

In going USBHostShield2.0 and the issue and the code Lazurus has for BT the HCI log is making sense. His BTHID functions also implements SDP/SPP for Bluetooth which the XBOX needs to work. Looks like that Nintendo Switch Pro controller we picked up also needs it. Also looks like the XBOX controller also needs a heartbeat message to stay connected as well :)

Don't think it will just be a simple change. Also, dont think he ever fully got it to work.

But knowing about the SDP and SPP messages that HCI Log/Wireshark dump is making sense.

EDIT: Just attached that Switch controller via usb and ran the XBOXUSB sketch and it works wired with the USBHost Shield. Wired it shows as a XBOX360
 
Last edited:
@mjs513 - Some reason got distracted today ;)

Was playing some with the switch controller plugged into USB. Have some of that working, in that it is now finding and setting up the end points.

It is showing HID data in debug. But our code is not understanding the state information yet. The cod thinks it is an XBOx360 plugged in device. But the first bytes status are a bit different
 
@mjs513 - Some reason got distracted today ;)

Was playing some with the switch controller plugged into USB. Have some of that working, in that it is now finding and setting up the end points.

It is showing HID data in debug. But our code is not understanding the state information yet. The cod thinks it is an XBOx360 plugged in device. But the first bytes status are a bit different

Yeah was just playing with that a bit. Funny thing is that USBHost shield recognizes it as 360 and its working but cant see any differences from the xbox one s. Didnt try that ???? But my eyes are closing now.
 
Morning @KurtE

Was playing with your update this morning. Think I isolated the problem.

Based on what you currently have the report id is 0x14 but the code only seems to accept rpt 0x01. If I look at the other for xbox it has:
Code:
if(readBuf[0] != 0x00 || readBuf[1] != 0x14) return;
which makes sense to what we are seeing for the 360w anyway.

If I add rpt 14 then the data gets processed but the 360 data structure is off for buttons and hats. Thats the easy part to fix :)

What you think?
 
Early Morning:
Yes you are along the same line as I was later yesterday.

I changed my entry:
{ 0x045e, 0x028E, SWITCH, false}, // Switch?

Where SWITCH was added to enum...

Added a typedef near the others (about line 650)
Code:
typedef struct {
	uint8_t state;
	uint8_t id_or_type;
	// From online references button order: 
	//     sync, dummy, start, back, a, b, x, y
	//     dpad up, down left, right
	//	   lb, rb, left stick, right stick
	// Axis: 
	//     lt, rt, lx, ly, rx, ry
	//
	uint16_t buttons; 
	uint8_t lt;
	uint8_t rt;
	int16_t	axis[4];
} switchdataUSB_t;

And added section to: rx_data
Code:
	} else if (joystickType_ == SWITCH) {
		switchdataUSB_t  *switchd = (switchdataUSB_t *)transfer->buffer;
        if (buttons != switchd->buttons) {
        	buttons = switchd->buttons;
        	anychange = true;
        }
		axis_mask_ = 0x3f;	
		axis_changed_mask_ = 0;	// assume none for now

		for (uint8_t i = 0; i < 4; i++) {
			if (axis[i] != switchd->axis[i]) {
				axis[i] = switchd->axis[i];
				axis_changed_mask_ |= (1 << i);
				anychange = true;
			}
		}
		// the two triggers show up as 4 and 5
		if (axis[4] != switchd->lt) {
			axis[4] = switchd->lt;
			axis_changed_mask_ |= (1 << 4);
			anychange = true;
		}

		if (axis[5] != switchd->rt) {
			axis[5] = switchd->rt;
			axis_changed_mask_ |= (1 << 5);
			anychange = true;
		}

		if (anychange) joystickEvent = true;
Also added an entry in the USBHost_Viewer sketch for switch, although did not save that one...

And was seeing some data :D

But was not sure yet if that is the correct approach.

Found another website that looks like it might have some interesting data: https://github.com/dekuNukem/Nintendo_Switch_Reverse_Engineering

Need to play more!
 
@KurtE
Yep - early morning - guess i am a morning person :)

Was thinking along the same lines as you, started doing the same thing.

The one thing that will have to be adjusted is the structure for the data the buttons seem to be data elements :
Code:
Dpad: data[2]: u-1, d-2, l-4, r-8
Letters: data[3] x-80  ,  y-40, b-10, a-20
(-)(+) button: data[2]:  (-)20, (+)10
Home: data[3]-4
L1-data[3]-1, R1-2
l2-data[4] - ff,
R2-data[5]-ff
Left Hat
UP/D - dat[8-9]
L/R-dat[6-7]
Right Hat:
UP/D - dat[12-13]
L/R - dat[10-11]
 
@KurtE
Once I commented the println's in the rx_data section (right at the beginning), looks like its working without any changes necessary to the structure.

Bottom line: looks like you got it resolved. Give it a try.
 
@KurtE
The only things that don't seem to work are Rumble and LEDs? Can't seem to break the code on that.
 
Back
Top