T3.6 USB Host - Bluetooth

@KurtE
Was thinking this morning that maybe its time to push the WIP2-bluetooth branch to the master with the caveat that XBOX BT is still an open issue. Think its far enough along that maybe we can might be able to get some feedback on what's there already with the changes since its been only a few of us testing this?

@defragster - the ILI9488 is still on my todo list - I am still waiting for the one you and Paul has from China - argh.
 
@mjs513 - I agree, although I may wait a day or two longer on the off chance I figure out something about XBox

But if I see something like @Paul saying he is thinking of packaging up a new Beta, than I want to make sure we can hopefully have it all Pushed into the main library...
 
How to get started

Hi KurtE,mjs513,

Thanks for working on this project and sharing it with the community.

My goal is to connect a device that is using bluetooth Hid keyboard to Teeny 3.6. So I started with the JoystickBT example with a Rii Mini Bluetooth,and a Kinivo BTD-400 Bluetooth 4.0.


I uncommented #define USBHOST_PRINT_DEBUG in USBHost_t36.h and used USB Type: Serial with optimize for debug option when I run the JoystickBT code in Arduino IDE.

However, I am not able to pair the keyboard and this is all I get in serial monitor:

Code:
USB Host Testing
960
*** Device Bluet a5c:21e8 - connected ***
  manufacturer: Broadcom Corp
  product: BCM20702A0
  Serial: 5CF3708B497F
  BDADDR: 7f:49:8b:70:f3:5c

I Push the pairing button on the keyboard, enter 0000 and press enter key on the keyboard after I open serial monitor but I don't get any thing. Would you please help me figure out what is wrong with my setup?

Thanks
 
@milan7: That is the older version of the Rii I have - perhaps the same as KurtE has?

To see the explicit DEBUG you have to catch output from Serial1 port. It seems that is where the keypresses appear.

Also to Pair the first time the upper line [~ #18 ] has to have the three param version where ", true, "0000");" is used to allow pairing.
 
Thanks defragster! I think I forgot the Serial1 part. I will test it again and see if it works.

I just looked to find the cheapest Rii bluetooth keyboard I could find. Hopefully, it works.
 
@KurtE and @defragster

Working through the examples but found a couple of gotchas that I am working on - starting with joystick (wired) version. In so doing I am also making a key map that I am attaching for reference for the PS3/PS4/Xbox controller. Having a problem with PS3 wire rumble and LEDs but will figure that out tomorrow.View attachment Controller mapping.zip
 
@milan7 - suggest you run the KeyboardBT sketch instead of the JoystickBT sketch along with the pairing instructions that @defragster provided.
 
Thanks defragster! I think I forgot the Serial1 part. I will test it again and see if it works.

I just looked to find the cheapest Rii bluetooth keyboard I could find. Hopefully, it works.

No luck.

Should I change 0xffc90004 in the following line?
Code:
RawHIDController rawhid2(myusb, 0xffc90004);
 
@milan7 - suggest you run the KeyboardBT sketch instead of the JoystickBT sketch along with the pairing instructions that @defragster provided.


I tried KeyboardBT by adding Serial.begin(2000000); before while (!Serial) . Same issue. I don't see anything after BDADDR.
 
I'll get back to this in a couple hours and update my system and try with mine.

"To see the explicit DEBUG you have to catch output from Serial1 port. It seems that is where the keypresses appear."

Which function am I looking in KeyboardBT that need to be replaced with Serial1 ?

Thanks
 
Pulled zio from : /KurtE/USBHost_t36/tree/WIP2-Bluetooth and put it in :: Used: T:\tCode\libraries\USBHost_t36

For KeyboardBT I had to add Serial1.begin() to setup() and enabled :: #define USBHOST_PRINT_DEBUG

It gets my HUB and Bluet adapter - but never picks up the Rii mini i8+ ?

After it gives up trying to Pair the Rii is back paired to my computer. Tried the same with JoystickBT.ino and it didn't discover anything either.

Not sure what I'm doing differently - it connected before.

<edit>: Logitech mouse not seen by MouseBT.ino - neither is MSFT mouse - seems that worked but I didn't get that in p#1 table.

BTW: Nothing at all shows on Serial1 Debug - and Serial USB only shows Hub/Bluet - this is with T_3.6
This is with NEW IDE 1.8.9 and TD 1.46b10 tree.
 
Last edited:
Moved T:\tCode\libraries\USBHost_t36 to T:\tCode\NOTlibraries\USBHost_t36

Recompiled on the old IDE 1.8.8 copy with 1.46b9 :: T:\arduino-1.8.8T4_146\hardware\teensy\avr\libraries\USBHost_t36\examples\KeyboardBT\KeyboardBT.ino

Rii keyboard connects.

Here is a ZIP of that folder - perhaps form about 7 March in case it makes a 'DIFF' :) :: View attachment OLDer_USBHost_t36.zip

<edit>: I'll move that zip copy from cores\lib to my sketchbook and run with 1.8.9 on the other post #365 items and see if I can see it work as well to rule out outside changes or my setup.
 
Last edited:
@KurtE , @defragster and @milan7

I just tried BT mouse as well with 4 different dongles and couldn't get it to connect. One thing that you have to remember todo is press the connect button on the bottom of the mouse - that is how I got it working the first time. Didn't work this time. The output on Serial1 is:
Code:
�BluetoothController claim this=1fff3c60 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 11 71 da 7d 1a 0 
    Command Completed! 
   BD Addr:11:71:da:7d:1a:0
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
BT rx_data(16): 22 f 1 86 bd b4 26 2c dc 1 2 80 25 0 7e 37 
BT rx_data(1): cc 
BT rx_data(16): 22 f 1 86 bd b4 26 2c dc 1 2 80 25 0 a7 37 
BT rx_data(1): c9 
BT rx_data(16): 22 f 1 86 bd b4 26 2c dc 1 2 80 25 0 d0 37 
BT rx_data(1): d0 
BT rx_data(16): 22 f 1 86 bd b4 26 2c dc 1 2 80 25 0 e0 37 
BT rx_data(1): cf 
BT rx_data(16): 22 f 1 86 bd b4 26 2c dc 1 2 80 25 0 f0 37 
BT rx_data(1): d2 
BT rx_data(16): 22 f 1 86 bd b4 26 2c dc 1 2 80 25 0 f7 37 
BT rx_data(1): cd 
BT rx_data(16): 22 f 1 86 bd b4 26 2c dc 1 2 80 25 0 ff 37 
BT rx_data(1): d3 
BT rx_data(16): 22 f 1 86 bd b4 26 2c dc 1 2 80 25 0 38 38 
BT rx_data(1): d5 
BT rx_data(16): 22 f 1 86 bd b4 26 2c dc 1 2 80 25 0 7c 38 
BT rx_data(1): d5 
BT rx_data(16): 22 f 1 86 bd b4 26 2c dc 1 2 80 25 0 ac 38 
BT rx_data(1): ce 
BT rx_data(3): 1 1 0 
    Inquiry Complete - status: 0

<EDIT> wonder if has something to do with the extended inquiry mode?
 
As a test I installed the commit prior to @KurtE's XBOX changes: https://github.com/KurtE/USBHost_t36/tree/4e2a27a61c5d604bda67ed9671ac135a7f82bdfe and loaded and the mouse started working. So something in the latest set of commits (probably the extended inquiry) must be conflicting with other types of devices that don't use it. Just a guess here:
Code:
USB Host Testing
960
*** Device Bluet a12:1 - connected ***
  product: CSR8510 A10
Mouse: buttons = 0,  mouseX = -65,  mouseY = -6,  wheel = 0,  wheelH = 0
Mouse: buttons = 0,  mouseX = 0,  mouseY = 0,  wheel = 0,  wheelH = 0
Mouse: buttons = 16,  mouseX = 0,  mouseY = 0,  wheel = 0,  wheelH = 0
Mouse: buttons = 0,  mouseX = 0,  mouseY = 0,  wheel = 0,  wheelH = 0
 
@mjs513 @defragster, and @milan7, Looks like time to do some debugging..

Yes who knows maybe extended inquiry might have hit it or maybe???

I reproduced it with the RII...
@mjs513 - actually your data shows some of the issue: BT rx_data(16): 22 f 1 86 bd b4 26 2c dc 1 2 80 25 0 7e 37

It is returning message type 22 (if memory serves this is Response with RSSI), which I don't handle (will soon). I handled the old:
0x02 message (response) and the 2f(extended response)... Looks like some devices don't send full details.

Hopefully will push in change in the next hour or two.
 
@mjs513 @defragster, and @milan7 - Please try sinking up and see if this helps.

I pushed up change that now hopefully properly processes the event: EV_INQUIRY_RESULTS_WITH_RSSI

The data size is identical to EV_INQUIRY_RESULT (old version) except some of the fields got pushed around a little, and one reserved field in the middle got used for RSSI, but it was at the end...

My RII keyboard is working now. Could test mouse again (but I am using it on my desktop) as I like it better than the logitech one ;)
 
@mjs513 @defragster, and @milan7 - Please try sinking up and see if this helps.

I pushed up change that now hopefully properly processes the event: EV_INQUIRY_RESULTS_WITH_RSSI

The data size is identical to EV_INQUIRY_RESULT (old version) except some of the fields got pushed around a little, and one reserved field in the middle got used for RSSI, but it was at the end...

My RII keyboard is working now. Could test mouse again (but I am using it on my desktop) as I like it better than the logitech one ;)

Just loaded up the updated library and tested with my BT mouse (keyboard is in garage) and the fixes you put seem to do the trick - mouse is working again.
 
@KurtE

Can you do me a favor. The next time you hook up your PS3 wired can you check rumble and LEDS. Wired those functions don't seem to work. I am not getting any rumble.

This is an updated sketch I am using that I will push in once I know if its the sketch or something else - ps4 and xbox is now working correctly.

View attachment Joystick.zip

EDIT
I updated the led call to this:
Code:
      if (buttons != buttons_prev) {
        if (joysticks[joystick_index].joystickType() == JoystickController::PS3) {
          //joysticks[joystick_index].setLEDs((buttons >> 12) & 0xf); //  try to get to TRI/CIR/X/SQuare
          uint8_t leds = 0;
          if (buttons & 0x8000) leds = 1;   //Srq
          if (buttons & 0x2000) leds = 2;   //Cir
          if (buttons & 0x1000) leds = 3;   //Tri
          joysticks[joystick_index].setLEDs(leds);
        } else {
          uint8_t lr = (buttons & 1) ? 0xff : 0;
          uint8_t lg = (buttons & 2) ? 0xff : 0;
          uint8_t lb = (buttons & 4) ? 0xff : 0;
          joysticks[joystick_index].setLEDs(lr, lg, lb);
        }
          buttons_prev = buttons;
      }
but I think the problem is that when you have a wired connection all the LEDS are on and blinking?
 
Last edited:
@mjs513 - Would not surprise me, that PS3 wired (and maybe BT) have issues with LEDs... I think it was maybe fine when you press one of the buttons, although again maybe not right number. There is something like a multiply by 2 the LED number of the like, if I remember correctly, and I think when we then released all of the buttons we maybe set back to 0 or the like, which I think ended up with all LEDs blinking...

On Side note: As you may remember I had difficulties getting the Logi MX Anywhere 2S mouse to work with BT... I think it is trying to use LE, which we don't have support for. However the mouse also comes with a logitech unifying receiver, which I just tried on the T4, and then clicked to go to channel 2 on mouse and then held to pair, and it is working...
 
@mjs513 - Would not surprise me, that PS3 wired (and maybe BT) have issues with LEDs... I think it was maybe fine when you press one of the buttons, although again maybe not right number. There is something like a multiply by 2 the LED number of the like, if I remember correctly, and I think when we then released all of the buttons we maybe set back to 0 or the like, which I think ended up with all LEDs blinking...

On Side note: As you may remember I had difficulties getting the Logi MX Anywhere 2S mouse to work with BT... I think it is trying to use LE, which we don't have support for. However the mouse also comes with a logitech unifying receiver, which I just tried on the T4, and then clicked to go to channel 2 on mouse and then held to pair, and it is working...

Interesting though I tested the LEDs and it worked in BT mode but not with a wired connection. Guess something to add to the list to check - not sure why rumble doesn't work wired though.

I remember testing the Logitech unifying receiver before and it worked no problem for me either so that is good news that it works for you as well.
 
Good News. Got ZIP again - with 2 hours ago changes. Put in : T:\tCode\libraries\USBHost_T36 … yes bad "T" cap on directory.

Win 10 - IDE 1.8.9 - TD_1.46b10 - T_3.6 :: Edited source to enable DEBUG and added Serial1.Begin() and all are ",true" look for pairing.

It works Bt Mouse:: MSFT Mouse, Logitech Mouse
It works Bt Keyboard:: Rii keypad Keyboard, MSFT Mobile 6000 Keyboard, Logitech K480 (Tri-device keyboard)

Only Bt Joy I have it PS3 - I forget the magic SYNC PGM buttons, I hit them once somehow and it said ~'no Bt controller found' [that post might be a good Post#1 footnote for *Special Features]

Sometimes this last line appears - sometimes not?
Code:
*** Device Bluet a5c:21e8 - connected ***
  manufacturer: Broadcom Corp
  product: BCM20702A0
  Serial: 5CF37060D3E1
[COLOR="#B22222"]  BDADDR: 0:0:0:0:0:0[/COLOR]
 
Back
Top