T3.6 USB Host - Bluetooth

Been quite a while since I've checked in on this thread... (Feb 2020)

Had wondered where development was headed at getting multiple device support. (Was looking to use 2 PS3 Move Navigation controllers)

Looks like KurtE found some time, and some merges happened since then:
https://github.com/PaulStoffregen/USBHost_t36/pull/38

I'll have to get my project back out and see if I can get things working.


Thank you for the continued work
 
I want to use a BT4.0 dongle and I need to source a known-good unit. Is there something current?

Also, I'm going to be experimenting with the BT4.0 dongles to see if they can be used with only 3.3v instead of 5v supplies so a variety of units would be best. This lets me use an existing 3.7v battery system. Thread is here:
https://forum.pjrc.com/threads/6758...h-only-3-3v-instead-of-5v?p=282251#post282251

This didn't get looked at yet with the release of TD 1.54.

Wondering if the Bt4.0 dongle tested to work functioned when running off a LiPo cell ...
 
Evening all decided to get a new toy to play with via bluetooth: https://www.amazon.com/gp/product/B00UA55ZOG/ref=ppx_yo_dt_b_asin_title_o02_s00?ie=UTF8&psc=1. Basically its a key board that attaches to the DS4/PS4 but still need to connect to the teensy dongle.
91uR7OoHA2L._SL1500_.jpg

Unfortunately think getting this working is wrapped up with getting a PS4 working with USBHost. It recognizes the keyboard - tries to connect and then crashes - crash report comes in handy for debugging:
Code:
CrashReport:
  A problem occurred at (system time) 0:1:31
  Code was executing from address 0x6F1E
  CFSR: 82
	(DACCVIOL) Data Access Violation
	(MMARVALID) Accessed Address: 0x5A781A4B
  Temperature inside the chip was 0.00 °C
  Startup CPU clock speed is 600MHz


USB Host Testing
960
BluetoothController claim this=20005d00 vid:pid=a5c:21e8
    9 4 0 0 3 ff 1 1 0 7 5 81 3 10 0 1 7 5 82 2 40 0 1 7 5 2 2 40 0 1 9 4 1 0 2 ff 1 1 0 7 5 83 1 0 0 1 7 5 3 1 0 0 1 9 4 1 1 2 ff 1 1 0 7 5 
    83 1 9 0 1 7 5 3 1 9 0 1 9 4 1 2 2 ff 1 1 0 7 5 83 1 11 0 1 7 5 3 1 11 0 1 9 4 1 3 2 ff 1 1 0 7 5 83 1 19 0 1 7 5 3 1 19 0 1 9 4 1 4 2 ff 
    1 1 0 7 5 83 1 21 0 1 7 5 3 1 21 0 1 9 4 1 5 2 ff 1 1 0 7 5 83 1 31 0 1 7 5 3 1 31 0 1 9 4 2 0 2 ff ff ff 0 7 5 84 2 20 0 1 7 5 4 2 20 0 1 9 
    4 3 0 0 fe 1 1 0 9 21 5 88 13 40 0 10 1 
      rxep=1(16) txep=2(64) rx2ep=2(64)
HCI_RESET called (03 0c 00 )
*** Device Bluet a5c:21e8 - connected ***
  manufacturer: Broadcom Corp
  product: BCM20702A0
  Serial: 001986000EE0
    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 e0 e 0 86 19 0 
    Command Completed! 
   BD Addr 0:19:86:0:e:e0
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 0 10 6 f 0 e 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
BT rx_data(16): 2f ff 1 3e 81 c1 17 62 67 1 0 40 25 0 3a 5b 
BT rx_data(16): cb 18 9 4e 59 4b 4f 20 54 59 50 45 20 50 41 44 
BT rx_data(16): 20 20 20 20 20 20 20 20 20 20 3 3 24 11 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:3e:81:c1:17:62:67, PS:1, class: 2540
      Local Name: NYKO TYPE PAD          
      Peripheral device
        Keyboard
BluetoothController::find_driver  driver 200039f8
Keyboard Controller::claim_bluetooth - Class 2540
KeyboardController::claim_bluetooth TRUE
    *** Claimed ***
HCI_INQUIRY_CANCEL called (02 04 00 )
    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 3e 81 c1 17 62 67 18 cc 01 00 00 00 00 )
    Control callback (bluetooth): 101 : 5 4 d 3e 81 c1 17 62 67 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 b 0 3e 81 c1 17 62 67 1 0 
    Connection Complete - ST:0 LH:b
HCI_AUTH_REQUESTED called (11 04 02 0b 00 )
    Control callback (bluetooth): 110 : 11 4 2 b 0 
BT rx_data(6): f 4 0 1 11 4 
    Command 411 Status 0
BT rx_data(8): 17 6 3e 81 c1 17 62 67 
    Event: Link Key Request 3e:81:c1:17:62:67
HCI_LINK_KEY_NEG_REPLY called (0c 04 06 3e 81 c1 17 62 67 )
    Control callback (bluetooth): 120 : c 4 6 3e 81 c1 17 62 67 
BT rx_data(12): e a 1 c 4 0 3e 81 c1 17 62 67 
    Command Completed! 
BT rx_data(8): 16 6 3e 81 c1 17 62 67 
    Event: Pin Code Request 3e:81:c1:17:62:67
HCI_PIN_CODE_REPLY called (0d 04 17 3e 81 c1 17 62 67 06 39 36 38 33 33 32 00 00 00 00 00 00 00 00 00 00 )
    Control callback (bluetooth): 130 : d 4 17 3e 81 c1 17 62 67 6 39 36 38 33 33 32 0 0 0 0 0 0 0 0 0 0 
BT rx_data(12): e a 1 d 4 0 3e 81 c1 17 62 67 
    Command Completed! 
BT rx_data(5): 6 3 8 b 0 
    Event: HCI Authentication complete(8): handle: b
ConnectionRequest called(0b 20 0c 00 08 00 01 00 02 00 04 00 11 00 70 00 )

CrashReport:
  A problem occurred at (system time) 20:43:50
  Code was executing from address 0x6F36
  CFSR: 82
	(DACCVIOL) Data Access Violation
	(MMARVALID) Accessed Address: 0x5A781A4B
  Temperature inside the chip was 0.00 °C
  Startup CPU clock speed is 600MHz
  Reboot was caused by auto reboot after fault or bad interrupt detected


USB Host Testing
960
BluetoothController claim this=20005d00 vid:pid=a5c:21e8
    9 4 0 0 3 ff 1 1 0 7 5 81 3 10 0 1 7 5 82 2 40 0 1 7 5 2 2 40 0 1 9 4 1 0 2 ff 1 1 0 7 5 83 1 0 0 1 7 5 3 1 0 0 1 9 4 1 1 2 ff 1 1 0 7 5 
    83 1 9 0 1 7 5 3 1 9 0 1 9 4 1 2 2 ff 1 1 0 7 5 83 1 11 0 1 7 5 3 1 11 0 1 9 4 1 3 2 ff 1 1 0 7 5 83 1 19 0 1 7 5 3 1 19 0 1 9 4 1 4 2 ff 
    1 1 0 7 5 83 1 21 0 1 7 5 3 1 21 0 1 9 4 1 5 2 ff 1 1 0 7 5 83 1 31 0 1 7 5 3 1 31 0 1 9 4 2 0 2 ff ff ff 0 7 5 84 2 20 0 1 7 5 4 2 20 0 1 9 
    4 3 0 0 fe 1 1 0 9 21 5 88 13 40 0 10 1 
      rxep=1(16) txep=2(64) rx2ep=2(64)
HCI_RESET called (03 0c 00 )
*** Device Bluet a5c:21e8 - connected ***
  manufacturer: Broadcom Corp
  product: BCM20702A0
  Serial: 001986000EE0
    Control callback (bluetooth): 1 : 3 c 0 
BT rx_data(7): 13 5 1 b 0 1 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 e0 e 0 86 19 0 
    Command Completed! 
   BD Addr 0:19:86:0:e:e0
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 0 10 6 f 0 e 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
BT rx_data(16): 2f ff 1 3e 81 c1 17 62 67 1 0 40 25 0 3c 74 
BT rx_data(16): bf 18 9 4e 59 4b 4f 20 54 59 50 45 20 50 41 44 
BT rx_data(16): 20 20 20 20 20 20 20 20 20 20 3 3 24 11 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:3e:81:c1:17:62:67, PS:1, class: 2540
      Local Name: NYKO TYPE PAD          
      Peripheral device
        Keyboard
BluetoothController::find_driver  driver 200039f8
Keyboard Controller::claim_bluetooth - Class 2540
KeyboardController::claim_bluetooth TRUE
    *** Claimed ***
HCI_INQUIRY_CANCEL called (02 04 00 )
    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 3e 81 c1 17 62 67 18 cc 01 00 00 00 00 )
    Control callback (bluetooth): 101 : 5 4 d 3e 81 c1 17 62 67 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 4 b 0 3e 81 c1 17 62 67 1 0 
    Connection Complete - ST:4 LH:b
HCI_AUTH_REQUESTED called (11 04 02 0b 00 )
    Control callback (bluetooth): 110 : 11 4 2 b 0 
BT rx_data(6): f 4 12 1 11 4 
    Command 411 Status 12 - ???
 
WOW! - Running at 0.00 °C !!! Saw one fault expose that as some version of NAN for that float, not sure why it would fail to return vlaid numbers from the TempCall? But it is packed under CRC - so that is the number it returned ???

Indeed very nice to get a clear restart with a note. Interesting if the provided address maps out to expected code? > executing from address 0x6F1E

If there is anything in memory ( DMAMEM - that can be cache_FLUSHED ) that status would be available to print after Crash.

I noted after TD 1.54 release - might have been handy to have the Crash handle flush ALL of DMAMEM(@, 512KB) to be sure ... instead of just (&info,#)

The other alternative would be to have a UserSketchCrashCall() that could pack up related state for review on restart. For instance: the debug On/Off viewed with a LogAnalyzer could be set in DMAMEM - then dumped after a crash to see what code path was active.
 
Evening all decided to get a new toy to play with via bluetooth: https://www.amazon.com/gp/product/B00UA55ZOG/ref=ppx_yo_dt_b_asin_title_o02_s00?ie=UTF8&psc=1. Basically its a key board that attaches to the DS4/PS4 but still need to connect to the teensy dongle.
View attachment 25273

Unfortunately think getting this working is wrapped up with getting a PS4 working with USBHost. It recognizes the keyboard - tries to connect and then crashes - crash report comes in handy for debugging:
...
Ok, I broke down and ordered one :D Supposed to get here maybe Tuesday
 
@KurtE

Had a feeling you weren't going to not be able to resist the temptation and go down another rabbit hole :)

Was playing a bit this morning. Tried pairing USBHost2, said pairing was successful but little blue light didn't stay on and no keyboard data. Then out of curiosity I tried pairing with my iPhone and that worked but interesting thing ws the phone what me to type a 4 digit number on the keypad and hit return and then connect. Just playing for now. Have to get the dump from linux later. Doing this on and off - but have a feeling it may pair the same way as the PS4's that we are having a problem with.
 
Does that "Type Pad" work stand alone or, and/or in combo with : PlayStation DualShock 4 Controller.

Never picked up a PS4 controller as they were WIP ... is there one that is a good start?
 
Does that "Type Pad" work stand alone or, and/or in combo with : PlayStation DualShock 4 Controller.

Never picked up a PS4 controller as they were WIP ... is there one that is a good start?

Good afternoon Tim
That "TypePad" works alone even though it connects to the PS4. As for a good PS4 to start - You can try the Voyee (red) that Kurt mentioned earlier - he said he was able to get it to work. I have 3 of them and none will pair.
 
Good afternoon Tim
That "TypePad" works alone even though it connects to the PS4. As for a good PS4 to start - You can try the Voyee (red) that Kurt mentioned earlier - he said he was able to get it to work. I have 3 of them and none will pair.

Hi Mike, seemed it was self powered and stand alone - just injects Audio to the controller ?

Searching thread not finding link - but a note the RED was no longer there?

This search shows two Not_RED Voyee in early listing ... White ? : amazon.com/s?k=voyee+ps4

... gotta run ... there is a payroll at stake ... Win 8 HDD corrupted ... and I just cloned it Dec 2020 ... so ReCloned from that to a fresh HDD ... now needs updated and ...
> Bummer is Acronis and old clone tool both make the Disk GPT {UEFI? boot?} not MBR as they 'clone' ... so lucky I had a dual drive Offline Clone Copy device ... as the Win 8 machine not GPT aware ...
 
My NyKo keypad arrived today... I charged it a little, actually left it charging...
screenshot.jpg

I loaded the example sketch KeyboardBT.
I built it first with: BluetoothController bluet(myusb, true, "0000"); // Version does pairing to device

Before the program started, I turned keypad on and pressed the BT button.

After it started up... Did not see many messages, but I then hit: 0000<cr>

Then I rebuilt the sketch without the pairing part

Then the program started up.... When I press the first key on the unit, it wakes up and connects and the sketch prints out the data like:
Code:
USB Host Testing
960
*** Device Bluet a12:1 - connected ***
  product: CSR8510 A10
BluetoothController::find_driver  driver 20002cd8
Keyboard Controller::claim_bluetooth - Class 2540
KeyboardController::claim_bluetooth TRUE
    *** Claimed ***
KeyboardController::process_bluetooth_HID_data
key '1'  49 MOD: 0 OEM: 1E LEDS: 0
KeyboardController::process_bluetooth_HID_data
KeyboardController::process_bluetooth_HID_data
key 'o'  111 MOD: 0 OEM: 12 LEDS: 0
KeyboardController::process_bluetooth_HID_data
KeyboardController::process_bluetooth_HID_data
key 'o'  111 MOD: 0 OEM: 12 LEDS: 0
KeyboardController::process_bluetooth_HID_data
KeyboardController::process_bluetooth_HID_data
key ','  44 MOD: 0 OEM: 36 LEDS: 0
KeyboardController::process_bluetooth_HID_data
KeyboardController::process_bluetooth_HID_data
key ','  44 MOD: 0 OEM: 36 LEDS: 0
KeyboardController::process_bluetooth_HID_data
KeyboardController::process_bluetooth_HID_data
key 'q'  113 MOD: 0 OEM: 14 LEDS: 0
KeyboardController::process_bluetooth_HID_data
KeyboardController::process_bluetooth_HID_data
key 'LEFT'  216 MOD: 0 OEM: 50 LEDS: 0
KeyboardController::process_bluetooth_HID_data
KeyboardController::process_bluetooth_HID_data
key 'RIGHT'  215 MOD: 0 OEM: 4F LEDS: 0
KeyboardController::process_bluetooth_HID_data
KeyboardController::process_bluetooth_HID_data
key 'UP'  218 MOD: 0 OEM: 52 LEDS: 0
KeyboardController::process_bluetooth_HID_data
KeyboardController::process_bluetooth_HID_data
key 'DN'  217 MOD: 0 OEM: 51 LEDS: 0
KeyboardController::process_bluetooth_HID_data
KeyboardController::process_bluetooth_HID_data
key 'LEFT'  216 MOD: 0 OEM: 50 LEDS: 0
KeyboardController::process_bluetooth_HID_data
KeyboardController::process_bluetooth_HID_data
key 'RIGHT'  215 MOD: 0 OEM: 4F LEDS: 0
KeyboardController::process_bluetooth_HID_data
KeyboardController::process_bluetooth_HID_data
key '
'  10 MOD: 0 OEM: 28 LEDS: 0
KeyboardController::process_bluetooth_HID_data
KeyboardController::process_bluetooth_HID_data
key '
'  10 MOD: 0 OEM: 28 LEDS: 0
KeyboardController::process_bluetooth_HID_data
KeyboardController::process_bluetooth_HID_data
key '
 
My NyKo keypad arrived today... I charged it a little, actually left it charging...
View attachment 25307

I loaded the example sketch KeyboardBT.
I built it first with: BluetoothController bluet(myusb, true, "0000"); // Version does pairing to device

Before the program started, I turned keypad on and pressed the BT button.

After it started up... Did not see many messages, but I then hit: 0000<cr>

Then I rebuilt the sketch without the pairing part

Then the program started up....

That looks promising! Similar function to the "Rii mini i8"?

Do you have a way to power that from a LiPo cell? Recent post #952, wondered if the Bt dongle running on less than 5V would function.
 
@KurtE - @defragster

Just tried it again. Seems a bit sensitive to pairing but once you get it, works like charm. Got it working with both a broadcom and a CSR4.0 dongle. So very promising for other projects :)

@defragster - there's a rechargeable battery in the keypad so it can work stand alone from the DS4 -only need to use the wire to charge it.
 
@KurtE - @defragster

Just tried it again. Seems a bit sensitive to pairing but once you get it, works like charm. Got it working with both a broadcom and a CSR4.0 dongle. So very promising for other projects :)

@defragster - there's a rechargeable battery in the keypad so it can work stand alone from the DS4 -only need to use the wire to charge it.

Very cool yours worked too. Just clicked order to arrive tomorrow.

@mjs513 - @kdharbert : question above was running the Teensy from LiPo - meaing the Dongle wouldn't have 5V ... does it work:
BT4.0 dongles to see if they can be used with only 3.3v instead of 5v supplies so a variety of units would be best. This lets me use an existing 3.7v battery system.
 
Type Pad arrived ... annoying wings to blend into the controller ... and that audio jack it seemed might fold away.

What code is WIP to work with? Want to see what happens when LiPo powered to Bt ...
 
Type Pad arrived ... annoying wings to blend into the controller ... and that audio jack it seemed might fold away.

What code is WIP to work with? Want to see what happens when LiPo powered to Bt ...

Just used the standard KeyboardBT sketch thats part of USBHost_T36 installed with Teensyduino - so no WIP needed :)
 
Thanks, unit unboxed and charged yesterday - but not gotten time for more than that.

Will have to locate the Bt dongle part ...
 
can't find Dongle item #1 listed : CSR 4.0

But I did find the second : PANBT400 Plugable Bt 4.0 Low Energy { LINK STILL ACTIVE }

It worked USB POWERED. Type Pad doesn't seem to always sends keys? Not sure if it sleeps or something? Seems some keys need to be MASHED?

@kdharbert ::
Then using 5V Cut cable wired a charged LiPo - at 4+V

It came up working again - usb Data only connected to PC and T_4.1 w/USB header to that Dongle works here with NYKO Type Pad.

Tried connecting Logitech Mouse with : \Mouse_KeyboardBT.ino
> it seemed to pair but - then connects and disconnects?

Much better PAIRED the Rii keypad :: been powered some 15 minutes - gone from over 4V to 3.9V or just under on 1,000 mAh cell
> It pairs and works MUCH better - keys register on CLICK - not missed or requiring mashing.
 
can't find Dongle item #1 listed : CSR 4.0

But I did find the second : PANBT400 Plugable Bt 4.0 Low Energy { LINK STILL ACTIVE }

It worked USB POWERED. Type Pad doesn't seem to always sends keys? Not sure if it sleeps or something? Seems some keys need to be MASHED?
.....


I have been using the Kinivo USB Bluetooth Adapter primarily - also tested with a CSR4.0 dongle.

Seems when I was testing as a standalone unit (not attached to the DS4) it seemed a bit more awkward to use the keys and felt like it I had to mashed the keys as well. With that said when I attached it the DS4 did seemed like I had to mash them as before, but considering its on a gamepad not bad. Once paired didn't notice that it wasn't always sending keys.

With all that said, I would not use it as a standalone keyboard - there are better ones out there. Picked this one up specifically for use with the DS4 controller.
 
Cool - the Kinivo like the PANBT400 AMZN links are still valid and both working is good.

AMZN doesn't indicate one of the Kinivo was delivered here though.

As far as @kdharbert question on usage - not running at 5V but on LiPo - at least the PANBT400 seemed to function at 3.9V at tested.
 
Note sure if best to continue here, or create a new thread...

But having some fun trying to get a better understanding of the Bluetooth, HID and SDP code and over time assuming I don't lose interest, may experiment more with some overhauling
of our Bluetooth code.

Sorry in advance for the following rambling, but thought I would mention some of this in case anyone would like to follow along.

The current code more or less has grown from mimicking a few different Bluetooth devices like some keyboards, Mice and Joysticks. So far all HID like devices. Not sure if at some point
maybe extend to some other Bluetooth protocols or not. Just doing this for my own fun.

At some point we should probably do a Bluetooth version 2 code bse, which cleans up lots of things, like adding simple calls to turn on pairing mode, and do better protocol negotiations, and handle a lot more of the underlying Bluetooth subsystems like

This current round of experiments started off when we were playing with a few different Bluetooth keyboards, like right now the Rii (https://smile.amazon.com/gp/product/B00JO80LVW)
Which I purchased over 4.5 years ago. It works as a keyboard with our current code, at least the main keyboard part works. But this device also has a touchpad on it, plus multi-media keys as well
And those don't work.

I have noticed that the normal keyboard stuff, is sent on Report 1, as our keyboard BT code expects. But it is also sending out some other different reports as well,
like when I touch the touchpad I get a report that starts with an 8, also there is a report that starts with a 3...

So started to wonder if these devices have a "HID Report Descriptor"...

First experiments were on Linux, where the keyboard works, also as mouse... And found a way to get the HID Descriptor to print out. So yes it does.

So I figured it out that the data for that was coming from the Bluetoth Service Descovery Protocol (SDP) area, which our current code does not setup a connection to. Experimented a year or two ago
with some of this but did not have that working. Note this is in Bluetooth_core_v5 pdf files in Vol3 Part B.

I now have it making an SDP connection (note I am doing this at a different time than the Linux code but it appears to work).
I then cobbled up code to send out a: ServiceSearchAttribute transaction request, and started to get a response but turned on that the response was split over two messages, so like we did
for the RX_Pipe, I had to update the RX2_Pipe code to detect this and combine two packets into one, and then I could start parsing it. Also put the code to handle the device splitting
up the response into multiple response packets. (Section 4.7). I now have them being all combined into one big buffer...

The current code is doing simple decoding the data. I won't put the whole thing here, but starts off like:
Code:
process_sdp_service_search_attribute_response: cb dat:32 cont:0 
SDP Data returned: 944 bytes
20200000 - 36 03 AD 36 00 8E 09 00  00 0A 00 00 00 00 09 00  : 6..6.... ........
20200010 - 01 35 03 19 10 00 09 00  04 35 0D 35 06 19 01 00  : .5...... .5.5....
20200020 - 09 00 01 35 03 19 00 01  09 00 05 35 03 19 10 02  : ...5.... ...5....
20200030 - 09 00 06 35 09 09 65 6E  09 00 6A 09 01 00 09 00  : ...5..en ..j.....
20200040 - 09 35 08 35 06 19 01 00  09 01 00 09 01 00 25 2F  : .5.5.... ......%/
20200050 - 42 72 6F 61 64 63 6F 6D  20 42 6C 75 65 74 6F 6F  : Broadcom  Bluetoo
20200060 - 74 68 20 57 69 72 65 6C  65 73 73 20 4B 65 79 62  : th Wirel ess Keyb
20200070 - 6F 61 72 64 20 53 44 50  20 53 65 72 76 65 72 09  : oard SDP  Server.
20200080 - 01 01 25 08 4B 65 79 62  6F 61 72 64 09 02 00 35  : ..%.Keyb oard...5
20200090 - 03 09 01 00 36 02 75 09  00 00 0A 00 01 00 00 09  : ....6.u. ........
202000A0 - 00 01 35 03 19 11 24 09  00 04 35 0D 35 06 19 01  : ..5...$. ..5.5...
202000B0 - 00 09 00 11 35 03 19 00  11 09 00 05 35 03 19 10  : ....5... ....5...
202000C0 - 02 09 00 06 35 09 09 65  6E 09 00 6A 09 01 00 09  : ....5..e n..j....
202000D0 - 00 09 35 08 35 06 19 11  24 09 01 00 09 00 0D 35  : ..5.5... $......5
202000E0 - 0F 35 0D 35 06 19 01 00  09 00 13 35 03 19 00 11  : .5.5.... ...5....
202000F0 - 09 01 00 25 3D 42 72 6F  61 64 63 6F 6D 20 42 6C  : ...%=Bro adcom Bl
20200100 - 75 65 74 6F 6F 74 68 20  57 69 72 65 6C 65 73 73  : uetooth  Wireless
20200110 - 20 20 4B 65 79 62 6F 61  72 64 20 20 20 20 20 20  :   Keyboa rd      
20200120 - 20 20 20 20 20 20 20 20  20 20 20 20 20 20 20 20  :                  
20200130 - 20 20 09 01 01 25 08 4B  65 79 62 6F 61 72 64 09  :   ...%.K eyboard.
20200140 - 01 02 25 10 42 72 6F 61  64 63 6F 6D 20 43 6F 72  : ..%.Broa dcom Cor
20200150 - 70 2E 20 20 09 02 00 09  01 00 09 02 01 09 01 11  : p.  .... ........
20200160 - 09 02 02 08 40 09 02 03  08 21 09 02 04 28 01 09  : ....@... .!...(..
20200170 - 02 05 28 01 09 02 06 36  01 54 36 01 51 08 22 26  : ..(....6 .T6.Q."&
20200180 - 01 4C 05 01 09 06 A1 01  85 01 75 01 95 08 05 07  : .L...... ..u.....
20200190 - 19 E0 29 E7 15 00 25 01  81 02 95 01 75 08 81 03  : ..)...%. ....u...
202001A0 - 95 05 75 01 05 08 19 01  29 05 91 02 95 01 75 03  : ..u..... ).....u.
202001B0 - 91 03 95 06 75 08 15 00  26 FF 00 05 07 19 00 29  : ....u... &......)
202001C0 - FF 81 00 C0 05 0C 09 01  A1 01 85 02 15 00 25 01  : ........ ......%.
202001D0 - 75 01 95 12 0A 23 02 0A  83 01 0A 0A 03 0A 0B 03  : u....#.. ........
202001E0 - 0A 05 03 0A 8A 01 0A 21  02 09 B6 09 CD 09 B5 09  : .......! ........
202001F0 - E2 09 EA 09 E9 09 B7 09  40 0A 83 01 0A 02 03 0A  : ........ @.......
20200200 - 07 03 81 02 95 01 75 06  81 03 C0 05 0C 09 01 A1  : ......u. ........
20200210 - 01 85 03 05 01 09 06 A1  02 05 06 09 20 15 00 26  : ........ .... ..&
20200220 - FF 00 75 08 95 01 81 02  C0 C0 05 01 09 80 A1 01  : ..u..... ........
20200230 - 85 04 15 00 25 01 75 01  95 01 09 82 81 02 95 01  : ....%.u. ........
20200240 - 75 07 81 03 C0 05 0C 09  01 A1 01 85 05 05 01 09  : u....... ........
20200250 - 06 A1 02 06 00 FF 25 01  75 01 95 02 0A 03 FE 0A  : ......%. u.......
20200260 - 04 FE 81 02 95 06 81 03  C0 C0 05 01 09 02 A1 01  : ........ ........
20200270 - 85 08 09 01 A1 00 05 09  19 01 29 05 15 00 25 01  : ........ ..)...%.
20200280 - 95 05 75 01 81 02 95 01  75 03 81 01 05 01 09 30  : ..u..... u......0
20200290 - 09 31 16 01 80 26 FF 7F  75 10 95 02 81 06 09 38  : .1...&.. u......8
202002A0 - 15 81 25 7F 75 08 95 01  81 06 05 0C 0A 38 02 95  : ..%.u... .....8..
202002B0 - 01 81 06 C0 C0 05 0C 09  01 A1 01 85 FF 05 06 95  : ........ ........
202002C0 - 01 75 02 19 24 29 26 81  02 75 06 81 01 C0 09 02  : .u..$)&. .u......
202002D0 - 07 35 08 35 06 09 04 09  09 01 00 09 02 08 28 00  : .5.5.... ......(.
202002E0 - 09 02 09 28 01 09 02 0A  28 01 09 02 0B 09 01 00  : ...(.... (.......
202002F0 - 09 02 0C 09 0C 80 09 02  0D 28 00 09 02 0E 28 01  : ........ .(....(.
20200300 - 09 02 0F 09 03 18 09 02  10 09 00 00 36 00 A1 09  : ........ ....6...
20200310 - 00 00 0A 00 01 00 01 09  00 01 35 03 19 12 00 09  : ........ ..5.....
20200320 - 00 04 35 0D 35 06 19 01  00 09 00 01 35 03 19 00  : ..5.5... ....5...
20200330 - 01 09 00 06 35 09 09 65  6E 09 00 6A 09 01 00 09  : ....5..e n..j....
20200340 - 00 09 35 08 35 06 19 12  00 09 01 00 09 01 00 25  : ..5.5... .......%
20200350 - 2F 42 72 6F 61 64 63 6F  6D 20 42 6C 75 65 74 6F  : /Broadco m Blueto
20200360 - 6F 74 68 20 57 69 72 65  6C 65 73 73 20 4B 65 79  : oth Wire less Key
20200370 - 62 6F 61 72 64 20 50 6E  50 20 53 65 72 76 65 72  : board Pn P Server
20200380 - 09 01 01 25 08 4B 65 79  62 6F 61 72 64 09 02 00  : ...%.Key board...
20200390 - 09 01 03 09 02 01 09 05  AC 09 02 02 09 85 02 09  : ........ ........
202003A0 - 02 03 09 01 1B 09 02 04  28 01 09 02 05 09 00 02  : ........ (.......
{s: 941
  {s: 142
    UINT: 0(0)
    UINT: 0(0)
    UINT: 1(1)
    {s: 3
      UUID: 4096(1000) }
    UINT: 4(4)
    {s: 13
      {s: 6
        UUID: 256(100)
        UINT: 1(1) }
      {s: 3
        UUID: 1(1) } }
    UINT: 5(5)
    {s: 3
      UUID: 4098(1002) }
    UINT: 6(6)
    {s: 9
      UINT: 25966(656E)
      UINT: 106(6A)
      UINT: 256(100) }
    UINT: 9(9)
    {s: 8
      {s: 6
        UUID: 256(100)
        UINT: 256(100) } }
    UINT: 256(100)
    St: 
20200050 - 42 72 6F 61 64 63 6F 6D  20 42 6C 75 65 74 6F 6F  : Broadcom  Bluetoo
20200060 - 74 68 20 57 69 72 65 6C  65 73 73 20 4B 65 79 62  : th Wirel ess Keyb
20200070 - 6F 61 72 64 20 53 44 50  20 53 65 72 76 65 72     : oard SDP  Server

    UINT: 257(101)
    St: 
20200084 - 4B 65 79 62 6F 61 72 64                           : Keyboard 

    UINT: 512(200)
    {s: 3
      UINT: 256(100) } }
  {s: 629
All of this part of code is in test program. There is some stuff added to USBHost for this...

Then I added code to ask for specific attribute, in this case 0x206 which is the HID Report Descriptor..
More information in the Bluetooth PDF Document: HUMAN INTERFACE DEVICE PROFILE 1.1

So the sort of structure output for this one specific attribute
Code:
process_sdp_service_search_attribute_response: cb dat:16 cont:0 
SDP Data returned: 358 bytes
20200000 - 36 01 63 36 00 00 36 01  5A 09 02 06 36 01 54 36  : 6.c6..6. Z...6.T6
20200010 - 01 51 08 22 26 01 4C 05  01 09 06 A1 01 85 01 75  : .Q."&.L. .......u
20200020 - 01 95 08 05 07 19 E0 29  E7 15 00 25 01 81 02 95  : .......) ...%....
20200030 - 01 75 08 81 03 95 05 75  01 05 08 19 01 29 05 91  : .u.....u .....)..
20200040 - 02 95 01 75 03 91 03 95  06 75 08 15 00 26 FF 00  : ...u.... .u...&..
20200050 - 05 07 19 00 29 FF 81 00  C0 05 0C 09 01 A1 01 85  : ....)... ........
20200060 - 02 15 00 25 01 75 01 95  12 0A 23 02 0A 83 01 0A  : ...%.u.. ..#.....
20200070 - 0A 03 0A 0B 03 0A 05 03  0A 8A 01 0A 21 02 09 B6  : ........ ....!...
20200080 - 09 CD 09 B5 09 E2 09 EA  09 E9 09 B7 09 40 0A 83  : ........ .....@..
20200090 - 01 0A 02 03 0A 07 03 81  02 95 01 75 06 81 03 C0  : ........ ...u....
202000A0 - 05 0C 09 01 A1 01 85 03  05 01 09 06 A1 02 05 06  : ........ ........
202000B0 - 09 20 15 00 26 FF 00 75  08 95 01 81 02 C0 C0 05  : . ..&..u ........
202000C0 - 01 09 80 A1 01 85 04 15  00 25 01 75 01 95 01 09  : ........ .%.u....
202000D0 - 82 81 02 95 01 75 07 81  03 C0 05 0C 09 01 A1 01  : .....u.. ........
202000E0 - 85 05 05 01 09 06 A1 02  06 00 FF 25 01 75 01 95  : ........ ...%.u..
202000F0 - 02 0A 03 FE 0A 04 FE 81  02 95 06 81 03 C0 C0 05  : ........ ........
20200100 - 01 09 02 A1 01 85 08 09  01 A1 00 05 09 19 01 29  : ........ .......)
20200110 - 05 15 00 25 01 95 05 75  01 81 02 95 01 75 03 81  : ...%...u .....u..
20200120 - 01 05 01 09 30 09 31 16  01 80 26 FF 7F 75 10 95  : ....0.1. ..&..u..
20200130 - 02 81 06 09 38 15 81 25  7F 75 08 95 01 81 06 05  : ....8..% .u......
20200140 - 0C 0A 38 02 95 01 81 06  C0 C0 05 0C 09 01 A1 01  : ..8..... ........
20200150 - 85 FF 05 06 95 01 75 02  19 24 29 26 81 02 75 06  : ......u. .$)&..u.
20200160 - 81 01 C0 36 00 00                                 : ...6..
{s: 355
  {s: 0 }
  {s: 346
    UINT: 518(206)
    {s: 340
      {s: 337
        UINT: 34(22)
        St: 
20200017 - 05 01 09 06 A1 01 85 01  75 01 95 08 05 07 19 E0  : ........ u.......
20200027 - 29 E7 15 00 25 01 81 02  95 01 75 08 81 03 95 05  : )...%... ..u.....
20200037 - 75 01 05 08 19 01 29 05  91 02 95 01 75 03 91 03  : u.....). ....u...
20200047 - 95 06 75 08 15 00 26 FF  00 05 07 19 00 29 FF 81  : ..u...&. .....)..
20200057 - 00 C0 05 0C 09 01 A1 01  85 02 15 00 25 01 75 01  : ........ ....%.u.
20200067 - 95 12 0A 23 02 0A 83 01  0A 0A 03 0A 0B 03 0A 05  : ...#.... ........
20200077 - 03 0A 8A 01 0A 21 02 09  B6 09 CD 09 B5 09 E2 09  : .....!.. ........
20200087 - EA 09 E9 09 B7 09 40 0A  83 01 0A 02 03 0A 07 03  : ......@. ........
20200097 - 81 02 95 01 75 06 81 03  C0 05 0C 09 01 A1 01 85  : ....u... ........
202000A7 - 03 05 01 09 06 A1 02 05  06 09 20 15 00 26 FF 00  : ........ .. ..&..
202000B7 - 75 08 95 01 81 02 C0 C0  05 01 09 80 A1 01 85 04  : u....... ........
202000C7 - 15 00 25 01 75 01 95 01  09 82 81 02 95 01 75 07  : ..%.u... ......u.
202000D7 - 81 03 C0 05 0C 09 01 A1  01 85 05 05 01 09 06 A1  : ........ ........
202000E7 - 02 06 00 FF 25 01 75 01  95 02 0A 03 FE 0A 04 FE  : ....%.u. ........
202000F7 - 81 02 95 06 81 03 C0 C0  05 01 09 02 A1 01 85 08  : ........ ........
20200107 - 09 01 A1 00 05 09 19 01  29 05 15 00 25 01 95 05  : ........ )...%...
20200117 - 75 01 81 02 95 01 75 03  81 01 05 01 09 30 09 31  : u.....u. .....0.1
20200127 - 16 01 80 26 FF 7F 75 10  95 02 81 06 09 38 15 81  : ...&..u. .....8..
20200137 - 25 7F 75 08 95 01 81 06  05 0C 0A 38 02 95 01 81  : %.u..... ...8....
20200147 - 06 C0 C0 05 0C 09 01 A1  01 85 FF 05 06 95 01 75  : ........ .......u
20200157 - 02 19 24 29 26 81 02 75  06 81 01 C0              : ..$)&..u ....
 } } }
  {s: 0 } }
I then passed the buffer extracted from this decoder to the HID Report dump code, that is a copy from our example Blueooth Hid sketch and now see

Code:
HID Report Descriptor (0x20200017) size: 332
  05 01 // Usage Page(1) - Generic Desktop
  09 06 // Usage(6) -(Keyboard)
  A1 01 // Collection(1) top Usage(10000)
    85 01 // Report ID(1)
    75 01 // Report Size(1)
    95 08 // Report Count(8)
    05 07 // Usage Page(7) - Keycode
    19 E0 // Usage Minimum(e0) - (Left Control)
    29 E7 // Usage Maximum(e7) - (Right GUI)
    15 00 // Logical Minimum(0)
    25 01 // Logical maximum(1)
    81 02 // Input(2) // (Data, Variable, Absolute)
    95 01 // Report Count(1)
    75 08 // Report Size(8)
    81 03 // Input(3) // (Constant, Variable, Absolute)
    95 05 // Report Count(5)
    75 01 // Report Size(1)
    05 08 // Usage Page(8) - LEDs
    19 01 // Usage Minimum(1) - 
    29 05 // Usage Maximum(5) - 
    91 02 // Output(2)  // (Data, Variable, Absolute)
    95 01 // Report Count(1)
    75 03 // Report Size(3)
    91 03 // Output(3)  // (Constant, Variable, Absolute)
    95 06 // Report Count(6)
    75 08 // Report Size(8)
    15 00 // Logical Minimum(0)
    26 FF 00  // Logical maximum(ff)
    05 07 // Usage Page(7) - Keycode
    19 00 // Usage Minimum(0) - (Keycode 0)
    29 FF // Usage Maximum(ff) - (Keycode 255)
    81 00 // Input(0) // (Data, Array, Absolute)
    C0  // End Collection
  05 0C // Usage Page(c) - Consumer
  09 01 // Usage(1) -(Consumer Controls)
  A1 01 // Collection(1) top Usage(c0000)
    85 02 // Report ID(2)
    15 00 // Logical Minimum(0)
    25 01 // Logical maximum(1)
    75 01 // Report Size(1)
    95 12 // Report Count(12)
    0A 23 02  // Usage(223) -(AC Home)
    0A 83 01  // Usage(183) -(AL Consumer Control Configuration)
    0A 0A 03  // Usage(30a) -(?)
    0A 0B 03  // Usage(30b) -(?)
    0A 05 03  // Usage(305) -(?)
    0A 8A 01  // Usage(18a) -(AL Email Reader)
    0A 21 02  // Usage(221) -(AC Search)
    09 B6 // Usage(b6) -(Scan Previous Track)
    09 CD // Usage(cd) -(Pause/Continue)
    09 B5 // Usage(b5) -(Scan Next Track)
    09 E2 // Usage(e2) -(Mute)
    09 EA // Usage(ea) -(Volume Down)
    09 E9 // Usage(e9) -(Volume Up)
    09 B7 // Usage(b7) -(Stop)
    09 40 // Usage(40) -(Menu)
    0A 83 01  // Usage(183) -(AL Consumer Control Configuration)
    0A 02 03  // Usage(302) -(?)
    0A 07 03  // Usage(307) -(?)
    81 02 // Input(2) // (Data, Variable, Absolute)
    95 01 // Report Count(1)
    75 06 // Report Size(6)
    81 03 // Input(3) // (Constant, Variable, Absolute)
    C0  // End Collection
  05 0C // Usage Page(c) - Consumer
  09 01 // Usage(1) -(Consumer Controls)
  A1 01 // Collection(1) top Usage(c0000)
    85 03 // Report ID(3)
    05 01 // Usage Page(1) - Generic Desktop
    09 06 // Usage(6) -(Keyboard)
    A1 02 // Collection(2)
    05 06 // Usage Page(6) - Other ?
    09 20 // Usage(20) -
    15 00 // Logical Minimum(0)
    26 FF 00  // Logical maximum(ff)
    75 08 // Report Size(8)
    95 01 // Report Count(1)
    81 02 // Input(2) // (Data, Variable, Absolute)
    C0  // End Collection
  C0  // End Collection
  05 01 // Usage Page(1) - Generic Desktop
  09 80 // Usage(80) -(?)
  A1 01 // Collection(1) top Usage(10080)
    85 04 // Report ID(4)
    15 00 // Logical Minimum(0)
    25 01 // Logical maximum(1)
    75 01 // Report Size(1)
    95 01 // Report Count(1)
    09 82 // Usage(82) -(System Sleep)
    81 02 // Input(2) // (Data, Variable, Absolute)
    95 01 // Report Count(1)
    75 07 // Report Size(7)
    81 03 // Input(3) // (Constant, Variable, Absolute)
    C0  // End Collection
  05 0C // Usage Page(c) - Consumer
  09 01 // Usage(1) -(Consumer Controls)
  A1 01 // Collection(1) top Usage(c0000)
    85 05 // Report ID(5)
    05 01 // Usage Page(1) - Generic Desktop
    09 06 // Usage(6) -(Keyboard)
    A1 02 // Collection(2)
    06 00 FF  // Usage Page(ff00) - Vendor Defined
    25 01 // Logical maximum(1)
    75 01 // Report Size(1)
    95 02 // Report Count(2)
    0A 03 FE  // Usage(fe03) -
    0A 04 FE  // Usage(fe04) -
    81 02 // Input(2) // (Data, Variable, Absolute)
    95 06 // Report Count(6)
    81 03 // Input(3) // (Constant, Variable, Absolute)
    C0  // End Collection
  C0  // End Collection
  05 01 // Usage Page(1) - Generic Desktop
  09 02 // Usage(2) -(Mouse)
  A1 01 // Collection(1) top Usage(10000)
    85 08 // Report ID(8)
    09 01 // Usage(1) -(?)
    A1 00 // Collection(0)
    05 09 // Usage Page(9) - Button
    19 01 // Usage Minimum(1) -  (BUTTON 1)
    29 05 // Usage Maximum(5) -  (BUTTON 5)
    15 00 // Logical Minimum(0)
    25 01 // Logical maximum(1)
    95 05 // Report Count(5)
    75 01 // Report Size(1)
    81 02 // Input(2) // (Data, Variable, Absolute)
    95 01 // Report Count(1)
    75 03 // Report Size(3)
    81 01 // Input(1) // (Constant, Array, Absolute)
    05 01 // Usage Page(1) - Generic Desktop
    09 30 // Usage(30) -(X)
    09 31 // Usage(31) -(Y)
    16 01 80  // Logical Minimum(8001)
    26 FF 7F  // Logical maximum(7fff)
    75 10 // Report Size(10)
    95 02 // Report Count(2)
    81 06 // Input(6) // (Data, Variable, Relative)
    09 38 // Usage(38) -(Wheel)
    15 81 // Logical Minimum(81)
    25 7F // Logical maximum(7f)
    75 08 // Report Size(8)
    95 01 // Report Count(1)
    81 06 // Input(6) // (Data, Variable, Relative)
    05 0C // Usage Page(c) - Consumer
    0A 38 02  // Usage(238) -(AC Pan)
    95 01 // Report Count(1)
    81 06 // Input(6) // (Data, Variable, Relative)
    C0  // End Collection
  C0  // End Collection
  05 0C // Usage Page(c) - Consumer
  09 01 // Usage(1) -(Consumer Controls)
  A1 01 // Collection(1) top Usage(c0000)
    85 FF // Report ID(ff)
    05 06 // Usage Page(6) - Other ?
    95 01 // Report Count(1)
    75 02 // Report Size(2)
    19 24 // Usage Minimum(24) - 
    29 26 // Usage Maximum(26) - 
    81 02 // Input(2) // (Data, Variable, Absolute)
    75 06 // Report Size(6)
    81 01 // Input(1) // (Constant, Array, Absolute)
    C0  // End Collection

Maybe next up is to migrate some of the sketch back into bluetooth.cpp, to more easily be able to query an attribute and parse it. And
And then the logical question is, should I then add more of the logical HID support (hidd.cpp) into Bluetooth), where the different BTHID clients can claim these different reports
and then add the hid parse code in to call off for each individual usage item?

Probably. But not sure how far I will take it.

If anyone is interested in this:
The WIP (experiments) is up on my USBHOST code in the branch BT_SDP_experiments.

Current test code included here.

Again I have idea how far I will take this!
(Random Rambling Complete) ;)
 

Attachments

  • USBBTDeviceInfo-220926a.zip
    15.4 KB · Views: 32
Quick update...

Pushed up simple thing but did some more hacking on Test sketch.

It is trying to parse the input lines now, using the Parser that I built into the test sketch class:

Keyboard:

Code:
=====================
<<(02):48 20 0E 00 0A 00 71 00 A1 01 00 00 1D 00 00 00 00 00 
HID HDR Data: len: 10, Type: 1 Con:0
(BTHID(0x2000788a, 9): 01 00 00 1D 00 00 00 00 00 
Begin topusage:10000 type:2 min:0 max:1
usage=700E0, value=0 (Left Control)
usage=700E1, value=0 (Left Shift)
usage=700E2, value=0 (Left Alt)
usage=700E3, value=0 (Left GUI)
usage=700E4, value=0 (Right Control)
usage=700E5, value=0 (Right Shift)
usage=700E6, value=0 (Right Alt)
usage=700E7, value=0 (Right GUI)
Begin topusage:10000 type:0 min:0 max:255
usage=7001D, value=1 (z and Z)
usage=70000, value=1 (Keycode 0)
usage=70000, value=1 (Keycode 0)
usage=70000, value=1 (Keycode 0)
usage=70000, value=1 (Keycode 0)
usage=70000, value=1 (Keycode 0)
END:
END:
END:
END:
END:
END:
END:

Trackpad in this case button
Code:
Begin topusage:10000 type:2 min:0 max:1
usage=90001, value=1  (BUTTON 1)
usage=90002, value=0  (BUTTON 2)
usage=90003, value=0  (BUTTON 3)
usage=90004, value=0  (BUTTON 4)
usage=90005, value=0  (BUTTON 5)
Begin topusage:10000 type:6 min:-32767 max:32767
usage=10030, value=0 (X)
usage=10031, value=0 (Y)
Begin topusage:10000 type:6 min:-127 max:127
usage=10038, value=0 (Wheel)
Begin topusage:10000 type:6 min:-127 max:127
usage=C0238, value=0 (AC Pan)
END:
END:
 

Attachments

  • USBBTDeviceInfo-220926a.zip
    18.8 KB · Views: 36
Another quick update: Fixed a few things in the test sketch, fixed a GP fault in BT...

But more fun, have a better viewing of the SDP data.

I figured the RAW version gave all of the info:
Code:
{s:941
  {s:142
    UINT: 0(0x0)
    UINT: 0(0x0)
    UINT: 1(0x1)
    {s:3
      UUID: 4096(0x1000) }
    UINT: 4(0x4)
    {s:13
      {s:6
        UUID: 256(0x100)
        UINT: 1(0x1) }
      {s:3
        UUID: 1(0x1) } }
    UINT: 5(0x5)
    {s:3
      UUID: 4098(0x1002) }
    UINT: 6(0x6)
    {s:9
      UINT: 25966(0x656E)
      UINT: 106(0x6A)
      UINT: 256(0x100) }
    UINT: 9(0x9)
    {s:8
      {s:6
        UUID: 256(0x100)
        UINT: 256(0x100) } }
    UINT: 256(0x100)
    St: 'Broadcom Bluetooth Wireless Keyboard SDP Server'
    UINT: 257(0x101)
    St: 'Keyboard'
    UINT: 512(0x200)
    {s:3
      UINT: 256(0x100) } }
  {s:629
    UINT: 0(0x0)
    UINT: 65536(0x10000)
    UINT: 1(0x1)
    {s:3
      UUID: 4388(0x1124) }
    UINT: 4(0x4)
    {s:13
      {s:6
        UUID: 256(0x100)
        UINT: 17(0x11) }
      {s:3
        UUID: 17(0x11) } }
    UINT: 5(0x5)
    {s:3
      UUID: 4098(0x1002) }
    UINT: 6(0x6)
    {s:9
      UINT: 25966(0x656E)
      UINT: 106(0x6A)
      UINT: 256(0x100) }
    UINT: 9(0x9)
    {s:8
      {s:6
        UUID: 4388(0x1124)
        UINT: 256(0x100) } }
    UINT: 13(0xD)
    {s:15
      {s:13
        {s:6
          UUID: 256(0x100)
          UINT: 19(0x13) }
        {s:3
          UUID: 17(0x11) } } }
    UINT: 256(0x100)
    St: 'Broadcom Bluetooth Wireless  Keyboard                        '
    UINT: 257(0x101)
    St: 'Keyboard'
    UINT: 258(0x102)
    St: 'Broadcom Corp.  '
    UINT: 512(0x200)
    UINT: 256(0x100)
    UINT: 513(0x201)
    UINT: 273(0x111)
    UINT: 514(0x202)
    UINT: 64(0x40)
    UINT: 515(0x203)
    UINT: 33(0x21)
    UINT: 516(0x204)
    Bool: 1(0x1)
    UINT: 517(0x205)
    Bool: 1(0x1)
    UINT: 518(0x206)
    {s:340
      {s:337
        UINT: 34(0x22)
        St:
20200182 - 05 01 09 06 A1 01 85 01  75 01 95 08 05 07 19 E0  : ........ u.......
20200192 - 29 E7 15 00 25 01 81 02  95 01 75 08 81 03 95 05  : )...%... ..u.....
202001A2 - 75 01 05 08 19 01 29 05  91 02 95 01 75 03 91 03  : u.....). ....u...
202001B2 - 95 06 75 08 15 00 26 FF  00 05 07 19 00 29 FF 81  : ..u...&. .....)..
202001C2 - 00 C0 05 0C 09 01 A1 01  85 02 15 00 25 01 75 01  : ........ ....%.u.
202001D2 - 95 12 0A 23 02 0A 83 01  0A 0A 03 0A 0B 03 0A 05  : ...#.... ........
202001E2 - 03 0A 8A 01 0A 21 02 09  B6 09 CD 09 B5 09 E2 09  : .....!.. ........
202001F2 - EA 09 E9 09 B7 09 40 0A  83 01 0A 02 03 0A 07 03  : ......@. ........
20200202 - 81 02 95 01 75 06 81 03  C0 05 0C 09 01 A1 01 85  : ....u... ........
20200212 - 03 05 01 09 06 A1 02 05  06 09 20 15 00 26 FF 00  : ........ .. ..&..
20200222 - 75 08 95 01 81 02 C0 C0  05 01 09 80 A1 01 85 04  : u....... ........
20200232 - 15 00 25 01 75 01 95 01  09 82 81 02 95 01 75 07  : ..%.u... ......u.
20200242 - 81 03 C0 05 0C 09 01 A1  01 85 05 05 01 09 06 A1  : ........ ........
20200252 - 02 06 00 FF 25 01 75 01  95 02 0A 03 FE 0A 04 FE  : ....%.u. ........
20200262 - 81 02 95 06 81 03 C0 C0  05 01 09 02 A1 01 85 08  : ........ ........
20200272 - 09 01 A1 00 05 09 19 01  29 05 15 00 25 01 95 05  : ........ )...%...
20200282 - 75 01 81 02 95 01 75 03  81 01 05 01 09 30 09 31  : u.....u. .....0.1
20200292 - 16 01 80 26 FF 7F 75 10  95 02 81 06 09 38 15 81  : ...&..u. .....8..
202002A2 - 25 7F 75 08 95 01 81 06  05 0C 0A 38 02 95 01 81  : %.u..... ...8....
202002B2 - 06 C0 C0 05 0C 09 01 A1  01 85 FF 05 06 95 01 75  : ........ .......u
202002C2 - 02 19 24 29 26 81 02 75  06 81 01 C0              : ..$)&..u ....
 } }
    UINT: 519(0x207)
    {s:8
      {s:6
        UINT: 1033(0x409)
        UINT: 256(0x100) } }
    UINT: 520(0x208)
    Bool: 0(0x0)
    UINT: 521(0x209)
    Bool: 1(0x1)
    UINT: 522(0x20A)
    Bool: 1(0x1)
    UINT: 523(0x20B)
    UINT: 256(0x100)
    UINT: 524(0x20C)
    UINT: 3200(0xC80)
    UINT: 525(0x20D)
    Bool: 0(0x0)
    UINT: 526(0x20E)
    Bool: 1(0x1)
    UINT: 527(0x20F)
    UINT: 792(0x318)
    UINT: 528(0x210)
    UINT: 0(0x0) }
  {s:161
    UINT: 0(0x0)
    UINT: 65537(0x10001)
    UINT: 1(0x1)
    {s:3
      UUID: 4608(0x1200) }
    UINT: 4(0x4)
    {s:13
      {s:6
        UUID: 256(0x100)
        UINT: 1(0x1) }
      {s:3
        UUID: 1(0x1) } }
    UINT: 6(0x6)
    {s:9
      UINT: 25966(0x656E)
      UINT: 106(0x6A)
      UINT: 256(0x100) }
    UINT: 9(0x9)
    {s:8
      {s:6
        UUID: 4608(0x1200)
        UINT: 256(0x100) } }
    UINT: 256(0x100)
    St: 'Broadcom Bluetooth Wireless Keyboard PnP Server'
    UINT: 257(0x101)
    St: 'Keyboard'
    UINT: 512(0x200)
    UINT: 259(0x103)
    UINT: 513(0x201)
    UINT: 1452(0x5AC)
    UINT: 514(0x202)
    UINT: 34050(0x8502)
    UINT: 515(0x203)
    UINT: 283(0x11B)
    UINT: 516(0x204)
    Bool: 1(0x1)
    UINT: 517(0x205)
    UINT: 2(0x2) } }

But I think this structured output, is a bit easier to understand:
Code:
SDP Data returned: 944 bytes
Attribute: 0(0x0)(ServiceRecordHandle) value: 0(0x0)
Attribute: 1(0x1)(ServiceClassIDList) value: {UUID: 4096(0x1000) }
Attribute: 4(0x4)(ProtocolDescriptorList) value: { {UUID: 256(0x100) 1(0x1) } {UUID: 1(0x1) } }
Attribute: 5(0x5)(BrowseGroupList) value: {UUID: 4098(0x1002) }
Attribute: 6(0x6)(LanguageBaseAttributeIDList) value: { 25966(0x656E) 106(0x6A) 256(0x100) }
Attribute: 9(0x9)(BluetoothProfileDescriptorList) value: { {UUID: 256(0x100) 256(0x100) } }
Attribute: 256(0x100)(ServiceName) value: 'Broadcom Bluetooth Wireless Keyboard SDP Server'
Attribute: 257(0x101)(ServiceDescription) value: 'Keyboard'
Attribute: 512(0x200)(HIDDeviceReleaseNumber (Deprecated)) value: { 256(0x100) } }
 {
Attribute: 0(0x0)(ServiceRecordHandle) value: 65536(0x10000)
Attribute: 1(0x1)(ServiceClassIDList) value: {UUID: 4388(0x1124) }
Attribute: 4(0x4)(ProtocolDescriptorList) value: { {UUID: 256(0x100) 17(0x11) } {UUID: 17(0x11) } }
Attribute: 5(0x5)(BrowseGroupList) value: {UUID: 4098(0x1002) }
Attribute: 6(0x6)(LanguageBaseAttributeIDList) value: { 25966(0x656E) 106(0x6A) 256(0x100) }
Attribute: 9(0x9)(BluetoothProfileDescriptorList) value: { {UUID: 4388(0x1124) 256(0x100) } }
Attribute: 13(0xD)(AdditionalProtocolDescriptorLists) value: { { {UUID: 256(0x100) 19(0x13) } {UUID: 17(0x11) } } }
Attribute: 256(0x100)(ServiceName) value: 'Broadcom Bluetooth Wireless  Keyboard                        '
Attribute: 257(0x101)(ServiceDescription) value: 'Keyboard'
Attribute: 258(0x102)(ProviderName) value: 'Broadcom Corp.  '
Attribute: 512(0x200)(HIDDeviceReleaseNumber (Deprecated)) value: 256(0x100)
Attribute: 513(0x201)(HIDParserVersion) value: 273(0x111)
Attribute: 514(0x202)(HIDDeviceSubclass) value: 64(0x40)
Attribute: 515(0x203)(HIDCountryCode) value: 33(0x21)
Attribute: 516(0x204)(HIDVirtualCable) value:Bool: 1(0x1)
Attribute: 517(0x205)(HIDReconnectInitiate) value:Bool: 1(0x1)
Attribute: 518(0x206)(HIDDescriptorList) value: { { 34(0x22) (332)< 05 01 09 06 A1 01 85 01 75 01 95 08 05 07 19 E0...> } }
Attribute: 519(0x207)(HIDLANGIDBaseList) value: { { 1033(0x409) 256(0x100) } }
Attribute: 520(0x208)(HIDSDPDisable (Deprecated)) value:Bool: 0(0x0)
Attribute: 521(0x209)(HIDBatteryPower) value:Bool: 1(0x1)
Attribute: 522(0x20A)(HIDRemoteWake) value:Bool: 1(0x1)
Attribute: 523(0x20B)(HIDProfileVersion) value: 256(0x100)
Attribute: 524(0x20C)(HIDSupervisionTimeout) value: 3200(0xC80)
Attribute: 525(0x20D)(HIDNormallyConnectable) value:Bool: 0(0x0)
Attribute: 526(0x20E) value:Bool: 1(0x1)
Attribute: 527(0x20F) value: 792(0x318)
Attribute: 528(0x210) value: 0(0x0) }
 {
Attribute: 0(0x0)(ServiceRecordHandle) value: 65537(0x10001)
Attribute: 1(0x1)(ServiceClassIDList) value: {UUID: 4608(0x1200) }
Attribute: 4(0x4)(ProtocolDescriptorList) value: { {UUID: 256(0x100) 1(0x1) } {UUID: 1(0x1) } }
Attribute: 6(0x6)(LanguageBaseAttributeIDList) value: { 25966(0x656E) 106(0x6A) 256(0x100) }
Attribute: 9(0x9)(BluetoothProfileDescriptorList) value: { {UUID: 4608(0x1200) 256(0x100) } }
Attribute: 256(0x100)(ServiceName) value: 'Broadcom Bluetooth Wireless Keyboard PnP Server'
Attribute: 257(0x101)(ServiceDescription) value: 'Keyboard'
Attribute: 512(0x200)(HIDDeviceReleaseNumber (Deprecated)) value: 259(0x103)
Attribute: 513(0x201)(HIDParserVersion) value: 1452(0x5AC)
Attribute: 514(0x202)(HIDDeviceSubclass) value: 34050(0x8502)
Attribute: 515(0x203)(HIDCountryCode) value: 283(0x11B)
Attribute: 516(0x204)(HIDVirtualCable) value:Bool: 1(0x1)
Attribute: 517(0x205)(HIDReconnectInitiate) value: 2(0x2) } }

Next up???

Probably should integrate most of the underlying stuff into the main Bluetooth class...

Alternatively, could convert it simply convert part of it into it's own class (already is) strip out some of the debug stuff and add in call outs to be used for sketches...
Sort of a combo mouse/keyboard...

Not sure yet what I will do.
 
Hopefully over the next few days, I am going to try to migrate some of the SDP Bluetooth code from the test sketch object into some part(s) of the USBHost Bluetooth code.

I am still not sure of the best way to factor/refactor the functionality the cleanest but compatible way.

Right now, mostly concentrating on the Keyboard support, but this can easily spill over into several other places.

Part one is to build in support for SDP protocol. I have some of that already in my fork/Branch, which can handle some of the query/responses. But the code to understand the data coming back is currently within my test sketches object. I will migrate some of that. But may start off with simplified version that can query for the SDP Report Descriptor.

I currently have 3 Bluetooth keyboards. I already know that with existing code base, we don't have any support in place to handle the Key state LEDS like (caps lock). Also we do not support Multi-media keys.


The best one is the Kenessis Freestyle 2 Blue: From my test sketch its descriptor looks like:
Code:
HID Report Descriptor (0x200059b0) size: 300
  05 01	// Usage Page(1) - Generic Desktop
  09 06	// Usage(6) -(Keyboard)
  A1 01	// Collection(1) top Usage(10000)
    85 01	// Report ID(1)
    75 01	// Report Size(1)
    95 08	// Report Count(8)
    05 07	// Usage Page(7) - Keycode
    19 E0	// Usage Minimum(e0) - (Left Control)
    29 E7	// Usage Maximum(e7) - (Right GUI)
    15 00	// Logical Minimum(0)
    25 01	// Logical maximum(1)
    81 02	// Input(2)	// (Data, Variable, Absolute)
    95 01	// Report Count(1)
    75 08	// Report Size(8)
    81 03	// Input(3)	// (Constant, Variable, Absolute)
    95 05	// Report Count(5)
    75 01	// Report Size(1)
    05 08	// Usage Page(8) - LEDs
    19 01	// Usage Minimum(1) - 
    29 05	// Usage Maximum(5) - 
    91 02	// Output(2)	// (Data, Variable, Absolute)
    95 01	// Report Count(1)
    75 03	// Report Size(3)
    91 03	// Output(3)	// (Constant, Variable, Absolute)
    95 06	// Report Count(6)
    75 08	// Report Size(8)
    15 00	// Logical Minimum(0)
    26 FF 00	// Logical maximum(ff)
    05 07	// Usage Page(7) - Keycode
    19 00	// Usage Minimum(0) - (Keycode 0)
    29 FF	// Usage Maximum(ff) - (Keycode 255)
    81 00	// Input(0)	// (Data, Array, Absolute)
    C0	// End Collection
  05 0C	// Usage Page(c) - Consumer
  09 01	// Usage(1) -(Consumer Controls)
  A1 01	// Collection(1) top Usage(c0000)
    85 02	// Report ID(2)
    15 00	// Logical Minimum(0)
    25 01	// Logical maximum(1)
    75 01	// Report Size(1)
    95 12	// Report Count(12)
    0A 23 02	// Usage(223) -(AC Home)
    0A 8A 01	// Usage(18a) -(AL Email Reader)
    0A 24 02	// Usage(224) -(AC Back)
    0A 25 02	// Usage(225) -(AC Forward)
    0A 21 02	// Usage(221) -(AC Search)
    09 CD	// Usage(cd) -(Pause/Continue)
    09 B7	// Usage(b7) -(Stop)
    09 B6	// Usage(b6) -(Scan Previous Track)
    09 B5	// Usage(b5) -(Scan Next Track)
    09 E9	// Usage(e9) -(Volume Up)
    09 EA	// Usage(ea) -(Volume Down)
    09 E2	// Usage(e2) -(Mute)
    0A 94 01	// Usage(194) -(AL Local Machine Browser)
    0A 92 01	// Usage(192) -(AL Calculator)
    0A 83 01	// Usage(183) -(AL Consumer Control Configuration)
    0A 2A 02	// Usage(22a) -(AC Bookmarks)
    0A 26 02	// Usage(226) -(AC Stop)
    0A 27 02	// Usage(227) -(AC Refresh)
    81 02	// Input(2)	// (Data, Variable, Absolute)
    95 01	// Report Count(1)
    75 06	// Report Size(6)
    81 03	// Input(3)	// (Constant, Variable, Absolute)
    C0	// End Collection
  05 0C	// Usage Page(c) - Consumer
  09 01	// Usage(1) -(Consumer Controls)
  A1 01	// Collection(1) top Usage(c0000)
    85 03	// Report ID(3)
    05 01	// Usage Page(1) - Generic Desktop
    09 06	// Usage(6) -(Keyboard)
    A1 02	// Collection(2)
    05 06	// Usage Page(6) - Generic Device Controls
    09 20	// Usage(20) -(Battery Strength)
    15 00	// Logical Minimum(0)
    26 FF 00	// Logical maximum(ff)
    75 08	// Report Size(8)
    95 01	// Report Count(1)
    81 02	// Input(2)	// (Data, Variable, Absolute)
    C0	// End Collection
  C0	// End Collection
  05 01	// Usage Page(1) - Generic Desktop
  09 80	// Usage(80) -(?)
  A1 01	// Collection(1) top Usage(10080)
    85 04	// Report ID(4)
    15 00	// Logical Minimum(0)
    25 01	// Logical maximum(1)
    75 01	// Report Size(1)
    95 01	// Report Count(1)
    09 82	// Usage(82) -(System Sleep)
    81 02	// Input(2)	// (Data, Variable, Absolute)
    95 01	// Report Count(1)
    75 07	// Report Size(7)
    81 03	// Input(3)	// (Constant, Variable, Absolute)
    C0	// End Collection
  05 0C	// Usage Page(c) - Consumer
  09 01	// Usage(1) -(Consumer Controls)
  A1 01	// Collection(1) top Usage(c0000)
    85 05	// Report ID(5)
    05 01	// Usage Page(1) - Generic Desktop
    09 06	// Usage(6) -(Keyboard)
    A1 02	// Collection(2)
    06 00 FF	// Usage Page(ff00) - Vendor Defined
    25 01	// Logical maximum(1)
    75 01	// Report Size(1)
    95 02	// Report Count(2)
    0A 03 FE	// Usage(fe03) -
    0A 04 FE	// Usage(fe04) -
    81 02	// Input(2)	// (Data, Variable, Absolute)
    95 06	// Report Count(6)
    81 03	// Input(3)	// (Constant, Variable, Absolute)
    C0	// End Collection
  C0	// End Collection
  05 0C	// Usage Page(c) - Consumer
  09 01	// Usage(1) -(Consumer Controls)
  A1 01	// Collection(1) top Usage(c0000)
    85 FF	// Report ID(ff)
    05 06	// Usage Page(6) - Generic Device Controls
    95 01	// Report Count(1)
    75 02	// Report Size(2)
    19 24	// Usage Minimum(24) - (Security Code Entered)
    29 26	// Usage Maximum(26) - (Security Code cleared)(?)
    81 02	// Input(2)	// (Data, Variable, Absolute)
    75 06	// Report Size(6)
    81 01	// Input(1)	// (Constant, Array, Absolute)
    C0	// End Collection
  05 0C	// Usage Page(c) - Consumer
  09 01	// Usage(1) -(Consumer Controls)
  A1 01	// Collection(1) top Usage(c0000)
    85 11	// Report ID(11)
    15 00	// Logical Minimum(0)
    25 01	// Logical maximum(1)
    75 01	// Report Size(1)
    95 03	// Report Count(3)
    81 01	// Input(1)	// (Constant, Array, Absolute)
    75 01	// Report Size(1)
    95 01	// Report Count(1)
    05 0C	// Usage Page(c) - Consumer
    09 B8	// Usage(b8) -(Eject)
    81 02	// Input(2)	// (Data, Variable, Absolute)
    06 FF 00	// Usage Page(ff) - Other ?
    09 03	// Usage(3) -
    81 02	// Input(2)	// (Data, Variable, Absolute)
    75 01	// Report Size(1)
    95 03	// Report Count(3)
    81 01	// Input(1)	// (Constant, Array, Absolute)
    C0	// End Collection

I also have the NyKO, that attaches to a PS4 controller. Nothing that interesting with that one.

The most interesting one to talk about is the Rii one which also has a small touchpad...
Code:
HID Report Descriptor (0x200059b0) size: 332
  05 01	// Usage Page(1) - Generic Desktop
  09 06	// Usage(6) -(Keyboard)
  A1 01	// Collection(1) top Usage(10000)
    85 01	// Report ID(1)
    75 01	// Report Size(1)
    95 08	// Report Count(8)
    05 07	// Usage Page(7) - Keycode
    19 E0	// Usage Minimum(e0) - (Left Control)
    29 E7	// Usage Maximum(e7) - (Right GUI)
    15 00	// Logical Minimum(0)
    25 01	// Logical maximum(1)
    81 02	// Input(2)	// (Data, Variable, Absolute)
    95 01	// Report Count(1)
    75 08	// Report Size(8)
    81 03	// Input(3)	// (Constant, Variable, Absolute)
    95 05	// Report Count(5)
    75 01	// Report Size(1)
    05 08	// Usage Page(8) - LEDs
    19 01	// Usage Minimum(1) - 
    29 05	// Usage Maximum(5) - 
    91 02	// Output(2)	// (Data, Variable, Absolute)
    95 01	// Report Count(1)
    75 03	// Report Size(3)
    91 03	// Output(3)	// (Constant, Variable, Absolute)
    95 06	// Report Count(6)
    75 08	// Report Size(8)
    15 00	// Logical Minimum(0)
    26 FF 00	// Logical maximum(ff)
    05 07	// Usage Page(7) - Keycode
    19 00	// Usage Minimum(0) - (Keycode 0)
    29 FF	// Usage Maximum(ff) - (Keycode 255)
    81 00	// Input(0)	// (Data, Array, Absolute)
    C0	// End Collection
  05 0C	// Usage Page(c) - Consumer
  09 01	// Usage(1) -(Consumer Controls)
  A1 01	// Collection(1) top Usage(c0000)
    85 02	// Report ID(2)
    15 00	// Logical Minimum(0)
    25 01	// Logical maximum(1)
    75 01	// Report Size(1)
    95 12	// Report Count(12)
    0A 23 02	// Usage(223) -(AC Home)
    0A 83 01	// Usage(183) -(AL Consumer Control Configuration)
    0A 0A 03	// Usage(30a) -(?)
    0A 0B 03	// Usage(30b) -(?)
    0A 05 03	// Usage(305) -(?)
    0A 8A 01	// Usage(18a) -(AL Email Reader)
    0A 21 02	// Usage(221) -(AC Search)
    09 B6	// Usage(b6) -(Scan Previous Track)
    09 CD	// Usage(cd) -(Pause/Continue)
    09 B5	// Usage(b5) -(Scan Next Track)
    09 E2	// Usage(e2) -(Mute)
    09 EA	// Usage(ea) -(Volume Down)
    09 E9	// Usage(e9) -(Volume Up)
    09 B7	// Usage(b7) -(Stop)
    09 40	// Usage(40) -(Menu)
    0A 83 01	// Usage(183) -(AL Consumer Control Configuration)
    0A 02 03	// Usage(302) -(?)
    0A 07 03	// Usage(307) -(?)
    81 02	// Input(2)	// (Data, Variable, Absolute)
    95 01	// Report Count(1)
    75 06	// Report Size(6)
    81 03	// Input(3)	// (Constant, Variable, Absolute)
    C0	// End Collection
  05 0C	// Usage Page(c) - Consumer
  09 01	// Usage(1) -(Consumer Controls)
  A1 01	// Collection(1) top Usage(c0000)
    85 03	// Report ID(3)
    05 01	// Usage Page(1) - Generic Desktop
    09 06	// Usage(6) -(Keyboard)
    A1 02	// Collection(2)
    05 06	// Usage Page(6) - Generic Device Controls
    09 20	// Usage(20) -(Battery Strength)
    15 00	// Logical Minimum(0)
    26 FF 00	// Logical maximum(ff)
    75 08	// Report Size(8)
    95 01	// Report Count(1)
    81 02	// Input(2)	// (Data, Variable, Absolute)
    C0	// End Collection
  C0	// End Collection
  05 01	// Usage Page(1) - Generic Desktop
  09 80	// Usage(80) -(?)
  A1 01	// Collection(1) top Usage(10080)
    85 04	// Report ID(4)
    15 00	// Logical Minimum(0)
    25 01	// Logical maximum(1)
    75 01	// Report Size(1)
    95 01	// Report Count(1)
    09 82	// Usage(82) -(System Sleep)
    81 02	// Input(2)	// (Data, Variable, Absolute)
    95 01	// Report Count(1)
    75 07	// Report Size(7)
    81 03	// Input(3)	// (Constant, Variable, Absolute)
    C0	// End Collection
  05 0C	// Usage Page(c) - Consumer
  09 01	// Usage(1) -(Consumer Controls)
  A1 01	// Collection(1) top Usage(c0000)
    85 05	// Report ID(5)
    05 01	// Usage Page(1) - Generic Desktop
    09 06	// Usage(6) -(Keyboard)
    A1 02	// Collection(2)
    06 00 FF	// Usage Page(ff00) - Vendor Defined
    25 01	// Logical maximum(1)
    75 01	// Report Size(1)
    95 02	// Report Count(2)
    0A 03 FE	// Usage(fe03) -
    0A 04 FE	// Usage(fe04) -
    81 02	// Input(2)	// (Data, Variable, Absolute)
    95 06	// Report Count(6)
    81 03	// Input(3)	// (Constant, Variable, Absolute)
    C0	// End Collection
  C0	// End Collection
  05 01	// Usage Page(1) - Generic Desktop
  09 02	// Usage(2) -(Mouse)
  A1 01	// Collection(1) top Usage(10000)
    85 08	// Report ID(8)
    09 01	// Usage(1) -(?)
    A1 00	// Collection(0)
    05 09	// Usage Page(9) - Button
    19 01	// Usage Minimum(1) -  (BUTTON 1)
    29 05	// Usage Maximum(5) -  (BUTTON 5)
    15 00	// Logical Minimum(0)
    25 01	// Logical maximum(1)
    95 05	// Report Count(5)
    75 01	// Report Size(1)
    81 02	// Input(2)	// (Data, Variable, Absolute)
    95 01	// Report Count(1)
    75 03	// Report Size(3)
    81 01	// Input(1)	// (Constant, Array, Absolute)
    05 01	// Usage Page(1) - Generic Desktop
    09 30	// Usage(30) -(X)
    09 31	// Usage(31) -(Y)
    16 01 80	// Logical Minimum(8001)
    26 FF 7F	// Logical maximum(7fff)
    75 10	// Report Size(10)
    95 02	// Report Count(2)
    81 06	// Input(6)	// (Data, Variable, Relative)
    09 38	// Usage(38) -(Wheel)
    15 81	// Logical Minimum(81)
    25 7F	// Logical maximum(7f)
    75 08	// Report Size(8)
    95 01	// Report Count(1)
    81 06	// Input(6)	// (Data, Variable, Relative)
    05 0C	// Usage Page(c) - Consumer
    0A 38 02	// Usage(238) -(AC Pan)
    95 01	// Report Count(1)
    81 06	// Input(6)	// (Data, Variable, Relative)
    C0	// End Collection
  C0	// End Collection
  05 0C	// Usage Page(c) - Consumer
  09 01	// Usage(1) -(Consumer Controls)
  A1 01	// Collection(1) top Usage(c0000)
    85 FF	// Report ID(ff)
    05 06	// Usage Page(6) - Generic Device Controls
    95 01	// Report Count(1)
    75 02	// Report Size(2)
    19 24	// Usage Minimum(24) - (Security Code Entered)
    29 26	// Usage Maximum(26) - (Security Code cleared)(?)
    81 02	// Input(2)	// (Data, Variable, Absolute)
    75 06	// Report Size(6)
    81 01	// Input(1)	// (Constant, Array, Absolute)
    C0	// End Collection

Note: all three of these will currently be claimed by the Keyboard object (assuming you have a Bluetooth object, and they are paired...)

However, with my test sketch they are claimed by my own BTHIDDumper class, which I added in a slightly stripped down version of the HID parser from HID.cpp.
Stripped down in that it does not ask others to claim top level reports. It assumes its own class will process the HID stuff.

Note, this object is seeing multiple different types of HID messages:

For example: Keyboard:

Like a Shift Z -
Code:
(BTHID(0x2000588a, 9): 01 02 00 1D 00 00 00 00 00 
Begin topusage:10000 type:2 min:0 max:1 indent:0
  usage=700E0, value=0 (Left Control)
  usage=700E1, value=1 (Left Shift)
  usage=700E2, value=0 (Left Alt)
  usage=700E3, value=0 (Left GUI)
  usage=700E4, value=0 (Right Control)
  usage=700E5, value=0 (Right Shift)
  usage=700E6, value=0 (Right Alt)
  usage=700E7, value=0 (Right GUI)
  Begin topusage:10000 type:0 min:0 max:255 indent:1
    usage=7001D, value=1 (z and Z)
    usage=70000, value=1 (Keycode 0)
    usage=70000, value=1 (Keycode 0)
    usage=70000, value=1 (Keycode 0)
    usage=70000, value=1 (Keycode 0)
    usage=70000, value=1 (Keycode 0)
  END:
END:

Battery Strength:
Code:
(BTHID(0x2000588a, 8): 03 74 CC C5 0A 23 22 79 
Begin topusage:c0000 type:2 min:0 max:255 indent:0
  usage=60020, value=116 :t(Battery Strength)
END:
Multi media key, in this case Mute:
Code:
(BTHID(0x2000588a, 9): 01 00 00 00 00 00 00 00 00 
Begin topusage:10000 type:2 min:0 max:1 indent:0
  usage=700E0, value=0 (Left Control)
  usage=700E1, value=0 (Left Shift)
  usage=700E2, value=0 (Left Alt)
  usage=700E3, value=0 (Left GUI)
  usage=700E4, value=0 (Right Control)
  usage=700E5, value=0 (Right Shift)
  usage=700E6, value=0 (Right Alt)
  usage=700E7, value=0 (Right GUI)
  Begin topusage:10000 type:0 min:0 max:255 indent:1
    usage=70000, value=1 (Keycode 0)
    usage=70000, value=1 (Keycode 0)
    usage=70000, value=1 (Keycode 0)
    usage=70000, value=1 (Keycode 0)
    usage=70000, value=1 (Keycode 0)
    usage=70000, value=1 (Keycode 0)
  END:
END:
(BTHID(0x2000588a, 5): 02 00 04 00 00 
Begin topusage:c0000 type:2 min:0 max:1 indent:0
  usage=C0223, value=0 (AC Home)
  usage=C0183, value=0 (AL Consumer Control Configuration)
  usage=C030A, value=0 (?)
  usage=C030B, value=0 (?)
  usage=C0305, value=0 (?)
  usage=C018A, value=0 (AL Email Reader)
  usage=C0221, value=0 (AC Search)
  usage=C00B6, value=0 (Scan Previous Track)
  usage=C00CD, value=0 (Pause/Continue)
  usage=C00B5, value=0 (Scan Next Track)
  usage=C00E2, value=1 (Mute)
  usage=C00EA, value=0 (Volume Down)
  usage=C00E9, value=0 (Volume Up)
  usage=C00B7, value=0 (Stop)
  usage=C0040, value=0 (Menu)
  usage=C0183, value=0 (AL Consumer Control Configuration)
  usage=C0302, value=0 (?)
  usage=C0307, value=0 (?)
END:

And trackpad/Mouse like messages, example pressing the left mouse button:
Code:
(BTHID(0x2000588a, 8): 08 01 00 00 00 00 00 00 
Begin topusage:10000 type:2 min:0 max:1 indent:0
  usage=90001, value=1  (BUTTON 1)
  usage=90002, value=0  (BUTTON 2)
  usage=90003, value=0  (BUTTON 3)
  usage=90004, value=0  (BUTTON 4)
  usage=90005, value=0  (BUTTON 5)
  Begin topusage:10000 type:6 min:-32767 max:32767 indent:1
    usage=10030, value=0 (X)
    usage=10031, value=0 (Y)
    Begin topusage:10000 type:6 min:-127 max:127 indent:2
    usage=10038, value=0 (Wheel)
    Begin topusage:10000 type:6 min:-127 max:127 indent:2
    usage=C0238, value=0 (AC Pan)
  END:
END:
And Touch pad
Code:
(BTHID(0x2000588a, 8): 08 00 FA FF F6 FF 00 00 
Begin topusage:10000 type:2 min:0 max:1 indent:0
  usage=90001, value=0  (BUTTON 1)
  usage=90002, value=0  (BUTTON 2)
  usage=90003, value=0  (BUTTON 3)
  usage=90004, value=0  (BUTTON 4)
  usage=90005, value=0  (BUTTON 5)
  Begin topusage:10000 type:6 min:-32767 max:32767 indent:1
    usage=10030, value=-6 (X)
    usage=10031, value=-10 (Y)
    Begin topusage:10000 type:6 min:-127 max:127 indent:2
    usage=10038, value=0 (Wheel)
    Begin topusage:10000 type:6 min:-127 max:127 indent:2
    usage=C0238, value=0 (AC Pan)
  END:
END:

------------------------------------------------------------------------

So real question again how to factor this.

Again all three are claimed by keyboard as their Bluetooth class is: BTHIDDumpController Controller::claim_bluetooth - Class 540
The 0x40 bit says keyboard. Note we are not check maybe 100% accurate as if it were 0x5c0 we would claim it or Mouse would claim it
as the 0x80 is is Mouse, but 0xc0 bottom byte means combined, although I have not seen this case.

But in theory there could be top level object that claims these objects, like the USBHIDParser, Which would then process the parsing of the report and asking all of the objects, derived from some class, like the current BTHIDInput.

So assume that BluetoothController object parses HID. Should all of the Top Level objects go to the one object that claims a BT object now, or should it work like HID and for each top level, it asks each of the BTHIDInput objects if they want this report and then remembers which ones...

Or should we completly refactor, and USBHIDParser should also Handle BTHID parsing...

But that might turn everything on their ear!

For now, thinking baby steps. Maybe like the Keyboard controller code, when it claims the BT, it can ask BT if this object has a HID Descriptor, if it does it saves it away, and then when BT calls it with an Input Record it says I have a HID REPORT, call off to the Parser... And have similar named callbacks to handle each input field...

Sorry I know sort of rambling.

Thoughts?
 
@KurtE

Hopefully over the next few days, I am going to try to migrate some of the SDP Bluetooth code from the test sketch object into some part(s) of the USBHost Bluetooth code.

I am still not sure of the best way to factor/refactor the functionality the cleanest but compatible way.

Right now, mostly concentrating on the Keyboard support, but this can easily spill over into several other places.

Part one is to build in support for SDP protocol. I have some of that already in my fork/Branch, which can handle some of the query/responses. But the code to understand the data coming back is currently within my test sketches object. I will migrate some of that. But may start off with simplified version that can query for the SDP Report Descriptor.

I currently have 3 Bluetooth keyboards. I already know that with existing code base, we don't have any support in place to handle the Key state LEDS like (caps lock). Also we do not support Multi-media keys.

Not sure the best way to go here either.

I can tell you that the one BT keyboard that I have the only way to get the multimedia keys and trackpad info is to put it into HID_RPT_MODE. If I use Boot mode I only can see the normal keys. So somewhere we need to incorporate that as well.

If SDP gets incorporated we will also have to deal with the impact to other devices as well such as Joystick and maybe mouse. Don't think I have a BT mouse only the Logitech 2.4 Ghz one.s
 
Thanks @mjs513 and all,

As I mentioned, I have started to play with some integration of the code in the test sketch into the actual Bluetooth and Keyboard code.

Right now, I have an object that is included in the keyboard object, that I have it hook the Bluetooth callbacks, and for example:
When it receives the Connection has completed, it calls back to Bluetooth to try to use SDP to read in the HID Descriptor (if it has one).

Note: in the test sketch I could loop waiting for all of the BT packets, but here I have it setup with new BT callback that tells me when the
SDP request has completed.

Then when a BT packet is received the Keyboard code calls into my new object, which then if there is a HID Descriptor it uses a copy of the Parse code from the USBHIDParser class,
to parse the fields and calls back to the Keyboard USB HID Input code that processes the individual fields. The checked in code has the code that asks if a HIDInput class wants to claim specific TOP Usage items or not, and it assumes that the class it is contained in does.

Yesterday was able to receive the data from all three of my BT keyboards. Added some code to force the BT into HID Report mode, in order to fix some issues with receiving Multimedia keys on two of them.

However, it does not properly handle some of the other reports generated. For example, two of them have another report which they keyboards tell you how much battery is left (0-255).
Would be good to handle this. And as I mentioned before one of these keyboards has a trackpad/mouse on it. And the keyboard does not know how to process.

What is next? I would like to now extract that object from begin included inside of the Keyboard. (Note it is not specific to Keyboard) and potentially make it it's own USBHost Object.
Or potentially integrate it into the USBHIDParser class.

The main differences between the USB HID Parser and this is, that some of our classes need to do callbacks to the devices, like to set the keyboard led settings, and how they do that is different between using USB code versus BT code.

The main callback methods, that I may want/need alternatives to are:
Code:
	virtual hidclaim_t claim_collection(USBHIDParser *driver, Device_t *dev, uint32_t topusage);
	virtual bool hid_process_in_data(const Transfer_t *transfer) {return false;}
	virtual bool hid_process_out_data(const Transfer_t *transfer) {return false;}
	virtual bool hid_process_control(const Transfer_t *transfer) {return false;}
Will probably need similar ones.
For example, the claim_collection,
Will need in overloaded one that contains BT information instead of the USB Oject.

Will probably need to be able to hook packets, but probably does not use the Transfer_t type object.

May need another claim like method to say yes we know it is a keyboard type, and then later if we do not have a Report Descriptor, to still allow lets say the Keyboard object to claim and know it will need to process the data using Boot format.

If this setup correctly than probably most of the BT HID devices may not need to be derived from BTHIDInput, but instead simply use HIDInput.... But still more details to figure out
 
Back
Top