T3.6 USB Host - Bluetooth

Soon may be playing some more with PS4 controllers as maybe several people up on the RobotShop/Lynxmotion Hexapod stuff may be wanting to start off using PS4 controllers.
Which I will start playing some more with again.

But I am not sure my PS4 is holding much of a charge and also wondered if any of us have tried any of the clones yet...

So I just ordered two different clones:

https://www.amazon.com/gp/product/B08L7TX3QR
https://www.amazon.com/gp/product/B08ZHFM4B5

Will be interesting to see how compatible these are and if our code, especially the binding code works or not...
 
Soon may be playing some more with PS4 controllers as maybe several people up on the RobotShop/Lynxmotion Hexapod stuff may be wanting to start off using PS4 controllers.
Which I will start playing some more with again.

But I am not sure my PS4 is holding much of a charge and also wondered if any of us have tried any of the clones yet...

So I just ordered two different clones:

https://www.amazon.com/gp/product/B08L7TX3QR
https://www.amazon.com/gp/product/B08ZHFM4B5

Will be interesting to see how compatible these are and if our code, especially the binding code works or not...

Afternoon now for me but just got the blue controller and as expected didn't work BT out of the box - but did when wired. Seems to hang when trying to connect:
Code:
*** Device Bluet a5c:21e8 - connected ***
  manufacturer: Broadcom Corp
  product: BCM20702A0
  Serial: 5CF3707752FD
  BDADDR: fd:52:77:70:f3:5c
BT rx_data(12): 4 a df 40 7e e9 b6 98 8 25 0 1 
    Event: Incoming Connect -  df:40:7e:e9:b6:98 CL:2508 LT:1
      Peripheral device
        Gamepad
BluetoothController::find_driver  driver 20005978
    *** Claimed ***
HCI_OP_REMOTE_NAME_REQ called (19 04 0a df 40 7e e9 b6 98 01 00 00 00 )
*** BTHID Device Joystick1 0:0 - connected ***
  Serial:  
BT rx_data(6): f 4 0 1 19 4 
BT rx_data(16): 7 ff 0 df 40 7e e9 b6 98 57 69 72 65 6c 65 73 
BT rx_data(16): 73 20 43 6f 6e 74 72 6f 6c 6c 65 72 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 
    Event: handle_hci_remote_name_complete(0)
    Remote Name: Wireless Controller
HCI_OP_ACCEPT_CONN_REQ called (09 04 07 df 40 7e e9 b6 98 00 )
BT rx_data(6): f 4 0 1 9 4 
BT rx_data(10): 12 8 0 df 40 7e e9 b6 98 0 
BT rx_data(13): 3 b 0 b 0 df 40 7e e9 b6 98 1 0 
    Connection Complete - ST:0 LH:b
   Needs connect to device(PS4?)
ConnectionRequest called(0b 20 0c 00 08 00 01 00 02 00 04 00 11 00 70 00 )
BT rx_data(5): 1b 3 b 0 5 

=====================
BT rx2_data(16): b 20 c 0 8 0 1 0 2 1 4 0 1 0 23 1 
    L2CAP Connection Request: ID: 1, PSM: 1, SCID: 123
BT rx_data(7): 13 5 1 b 0 1 0
BT rx_data(6): 5 4 0 b 0 8 
    Event: HCI Disconnect complete(0): handle: b, reason:8
*** BTHID Device Joystick1 - disconnected ***
Haven't done much else besides this and checking the PID/VID. For some reason that SCID seems strange.

EDIT: Yep that SCID is strange on a real PS4 I get:
Code:
BT rx2_data(16): b 20 c 0 8 0 1 0 2 2 4 0 1 0 41 0 
    [COLOR="#FF0000"]L2CAP Connection Request: ID: 2, PSM: 1, SCID: 41[/COLOR]
 
Mine are scheduled to arrive Wednesday... You sure get quicker shipments!

Will take a look then. I have to remember how we did the paring on these... Some of the clones talked about pairing the device by plugging them into the PS unit... So may have to detect message sequence and see if we can figure out what they need.
 
Mine are scheduled to arrive Wednesday... You sure get quicker shipments!

Will take a look then. I have to remember how we did the paring on these... Some of the clones talked about pairing the device by plugging them into the PS unit... So may have to detect message sequence and see if we can figure out what they need.

Think that's because I am in NY and I think Amazon has a warehouse in NJ - think I read that someplace.

Was reading and saw the same thing that some of these want to paired via wire first then can connect via BT. For the PS4 think we had a special pairing setup? Been too long :)

EDIT: you picked a good one - doesn't even work with USB host v2 library. It says pairing was successful then dies :)
 
Last edited:
Think that's because I am in NY and I think Amazon has a warehouse in NJ - think I read that someplace.

Was reading and saw the same thing that some of these want to paired via wire first then can connect via BT. For the PS4 think we had a special pairing setup? Been too long :)

With PS3, we have a simple pairing, that if you first plug in BT adapter, then joystick and then press the PS3 with either L1 or R1, it will write out the binding to the PS3...

PS4, I think we had the stuff that if you held down the Share button long enough it would then do the stuff to do the binding...

As you said it has been awhile!
 
@KurtE
Think you may have picked the wrong PS4 clone. Just dump the HCI log from connecting to my android and not really like what I am seeing
Capture.jpg

Reading the specs a bit more it says it Bluetooth 4.2.

Are Bluetooth 4.2 Devices Backward Compatible With Current Bluetooth Devices?
Devices that implement the low energy feature in Bluetooth Smart 4.2 will be backward compatible with Bluetooth 4.0 ad 4.1 devices, which also have the low energy feature.
Ref: https://skillfulblue.com/bluetooth-4-2/

You ready to implement BLE hehe.
 
Are there any guides for communicating over Bluetooth serial ports with a PC? Windows has COM Ports in Bluetooth Settings and I have a USB Bluetooth dongle connected to a Teensy 4.1. Would I have to implement SPP in bluetooth.cpp?
 
@KurtE
Think you may have picked the wrong PS4 clone. Just dump the HCI log from connecting to my android and not really like what I am seeing
View attachment 24762

Reading the specs a bit more it says it Bluetooth 4.2.



You ready to implement BLE hehe.

Actually I picked two :D Won't know much until they arrive.

But bright side is maybe it will get it to the point were it also works with the Switch and ...

But we both know that it is a pretty big rabbit hole :D
 
Actually I picked two :D Won't know much until they arrive.

But bright side is maybe it will get it to the point were it also works with the Switch and ...

But we both know that it is a pretty big rabbit hole :D

We do like our rabbit holes don't we. But, at least USB host libv2 has the SDP stuff incorporarted. But not - I can't get it to connect with that lib either so something else up with it as well.
 
Is there anything implemented in USBHost_t36 bluetooth.cpp that lets a PC application send commands to a Teensy without getting into driver/kernel stuff?
 
As I mentioned I don't think there is anything on the Bluetooth side yet.

We have really only scratched the surface on some of this.
Like some Mice, Keyboards, Joysticks...

Alternatively I think there are something like Serial to bluetooth adapter you can get. But that may not be sufficient for what you want.
 
Are there any guides for communicating over Bluetooth serial ports with a PC? Windows has COM Ports in Bluetooth Settings and I have a USB Bluetooth dongle connected to a Teensy 4.1. Would I have to implement SPP in bluetooth.cpp?

Adafruit sells some breakout boards that connects a Serial UART, SPI, or USB Serial stream to BLE. Usually Adafruit is is pretty good at writing tutorials on how to use the boards, but you might need to modify things somewhat for the Teensy..


I bought the first, but so far it has been sitting in my someday bin.

I glanced at the Serial Support and it wants hardware flow control (CTS/RTS). Unfortunately on the Teensy 4.0/4.1, the only Serial UART that supports CTS is Serial3, and the CTS pin is pin 19. If you don't use I2C (which uses pins 18 and 19) you could use that. Alternatively the SPI /USB Serial interfaces might work better on the 4.1.
 
Unfortunately on the Teensy 4.0/4.1, the only Serial UART that supports CTS is Serial3, and the CTS pin is pin 19. If you don't use I2C (which uses pins 18 and 19) you could use that. Alternatively the SPI /USB Serial interfaces might work better on the 4.1.

Actually for all of the Serial ports for a CTS pin you can use any pin that is an XBAR pin
The attachCts method knows about this and sets up the XBar plus the Hardware Serial.

This is also true for RX pin for serial ports. However on any Serial port you can only use an XBar for either CTS or RX but not both...
 
Actually for all of the Serial ports for a CTS pin you can use any pin that is an XBAR pin
The attachCts method knows about this and sets up the XBar plus the Hardware Serial.

This is also true for RX pin for serial ports. However on any Serial port you can only use an XBar for either CTS or RX but not both...

Yeah, I think I knew that, but I didn't recall it. It looks like pins 0-5, 7-8, and 30-33 are the Xbar pins. It would be helpful if the Serial library page mentioned this.
 
Yeah, I think I knew that, but I didn't recall it. It looks like pins 0-5, 7-8, and 30-33 are the Xbar pins. It would be helpful if the Serial library page mentioned this.

I put a comment in the thread about the website could use a few updates...
 
We do like our rabbit holes don't we. But, at least USB host libv2 has the SDP stuff incorporarted. But not - I can't get it to connect with that lib either so something else up with it as well.

Today I picked up the two clones from our mailbox. You can see them along with my actual PS4.
screenshot.jpg

All three of them work plugged directly into the USB Host port. They all have the same VID:pID ...
Here is the Voyee plugged in
Code:
  manufacturer: Sony Computer Entertainment
  product: Wireless Controller
*** HID Device Joystick1 54c:5c4 - connected ***
  manufacturer: Sony Computer Entertainment
  product: Wireless Controller
  Joystick type: 2
*** First Joystick message 54c:5c4 ***
  manufacturer: Sony Computer Entertainment
  product: Wireless Controller
LX: 128, LY: 128, RX: 128, RY: 128 
L-Trig: 0, R-Trig: 0
Buttons: 0
Battery Status: 90
Accel-g's: 1.114868, -0.630859, 0.037598
Gyro-deg/sec: -495.742767, -13.260839, -281.219330
Pitch/Roll: 93.410652, 268.068512

LX: 128, LY: 128, RX: 128, RY: 128 
L-Trig: 0, R-Trig: 0
Buttons: 0
Battery Status: 90
Accel-g's: 0.019897, 0.059204, 1.007690
Gyro-deg/sec: -0.055953, 0.000000, 0.000000
Pitch/Roll: 183.362396, 181.131195

Not having much luck yet to get them to bind via Bluetooth... Not sure how much more will get done today.
 
@KurtE
Yeah that's exactly what I found as well with Blue one that I tried. The real PS4 DualShock and Teiros PS4 both work now issue wired. Issue is with BT. I did try it with USBHost Shield and it did seem to pair, at least it said it did but no data was dumped to the serial monitor.
 
@KurtE
Yeah that's exactly what I found as well with Blue one that I tried. The real PS4 DualShock and Teiros PS4 both work now issue wired. Issue is with BT. I did try it with USBHost Shield and it did seem to pair, at least it said it did but no data was dumped to the serial monitor.

It will be curious about differences in binding using USB cable versus through bluetooth.
Was looking around some and found a site that appears to have a lot of information on PS4: https://www.psdevwiki.com/ps4/DS4-BT
 
Yep. Found that site as well the other day but forgot to post believe it or not. Too many distractions.
 
@KurtE

You are right, something strange going on with USBHost_t36 with 1.8.15beta9. Axes were messed up and not reading correctly. So I went back to 1.8.14beta8 and PS4BT is working as it should. Something happened between beta8 and beta9 that broke it. Haven't really check to see the deltas but wanted to give you a heads up.

EDIT: Am seeing some strange warnings in 1.8.14b8 if I use the latest version of USBHost_t36 bundled with beta9
Code:
F:\arduino-1.8.14\hardware\teensy\avr\libraries\USBHost_t36\MassStorageDriver.cpp: In member function 'virtual void msController::disconnect()':
F:\arduino-1.8.14\hardware\teensy\avr\libraries\USBHost_t36\MassStorageDriver.cpp:134:47: warning: 'void* memset(void*, int, size_t)' clearing an object of non-trivial type 'struct msDriveInfo_t'; use assignment or value-initialization instead [-Wclass-memaccess]
  134 |  memset(&msDriveInfo, 0, sizeof(msDriveInfo_t));
      |                                               ^
In file included from F:\arduino-1.8.14\hardware\teensy\avr\libraries\USBHost_t36\USBHost_t36.h:33,
                 from F:\arduino-1.8.14\hardware\teensy\avr\libraries\USBHost_t36\MassStorageDriver.cpp:28:
F:\arduino-1.8.14\hardware\teensy\avr\libraries\USBHost_t36\utility/msc.h:155:16: note: 'struct msDriveInfo_t' declared here
  155 | typedef struct {
      |                ^
Memory Usage on Teensy 4.1:
  FLASH: code:66908, data:10868, headers:7212   free for files:8041476
   RAM1: variables:37600, code:64360, padding:1176   free for local variables:421152
   RAM2: variables:12384  free for malloc/new:511904

Now if I take the beta8 usbhost and paste it in beta9 it works fine again. So guess more work to do :)
 
Last edited:
Something feels a bit strange with this? That PR only changed msController class (MSC) so not sure why it would impact the PS4?

I also remember testing it with your branch before it merged and thought it worked? Ok going back through the core changes decided to test on a T4.0 and guess what it worked as expected.

EDIT: Ok reloaded beta9 and reloaded BTjosystick and now its working? even stranger.

UPDATE: forgot to mention before I reran it I did a 15s restore first. ????
 
Back
Top