USBHost Bluetooth -> BLE -> ArduinoBLE?

KurtE

Senior Member+
I thought I would mention, that @mjs513 and myself, have been working on updating the Bluetooth support within the USBHost library.
Hopefully soon we will have setup to do a Pull request into the master branch. We will discuss these changes over in the main USBHost Bluetooth thread: https://forum.pjrc.com/threads/49358-T3-6-USB-Host-Bluetooth

But this includes things like we now have some of the XBox One controllers working as well as some of the Nintendo Switch controllers working and cleaned up a bunch of different things, added SDP support and the like.
We will post an update in the other thread about this soon.

But One thing I have been running into, is so far the USBHost Bluetooth library is we do not have any support in it for Bluetooth Low Energy (BLE). And we are running into devices that use BLE.

For example, I have a Microsoft Mouse that we do not see at all. And as I mentioned our current WIP Bluetooth code is working with Some XBOX one controllers. But the latest Firmware release for these controllers
has now converted the device to run BLE...

So I started investigating how to add BLE support into our USB Host support, which has been pretty interesting, as it relies on several more Bluetooth sub-systems. So, I started off with adding some real basic stuff, where I was able to enable the BLE scan and could see that some devices exist out there. But to go to the next step would require implementing things like GATT and ...

So I was curious and found that Arduino has a library arduinoBLE, which implements a lot of this. Which they have running on several boards like: Arduino Nano 33 IOT, Arduino Nano 33 BLE, plus RPI2040, ESP32... So was wondering how hard it would be to get it running on the Teensy 3.6, 4.x...

So I started hacking. Their code appears to be geared to work using the Uart Transport Layer (BT Core 5.3 spec - Vol 4, part A)... We are not using that transport layer, but most of our USB Dongles, are geared around the USB Transport layer (same volume but Part B)...

The ArduinoBLE code has some classes for different implementations of the Transport class. And I created one for USBHost. I actually have the code add one of our USB Host object, plus a HUB, plus a new class that I hacke up out of our BluetoothController class.

And it is now talking. I ran through several of the examples, but have had:

I started off with an Arduino Nano33 IOT running LedControl.ino talking to a Nano 33 BLE (Led) so you can change state of pin 2 of the IOT and it changes the state of the LED on the BLE.

Then through several steps have the LEDControl sketch running on a MicroMod talking to the BLE
And now have a Teensy 4.1 running LED


So I now have a version of this library up in the fork/branch: https://github.com/kurte/ArduinoBLE/tree/Teensy_USBHost

Will be fun to try out a few more things, like their battery monitor example, to see how well it talks to my iPhone or iPad.
Plus see how well this library talks to the Microsoft Mouse or an updated XBox controller.

Not sure, what I will do with this in the end. Options include: Punt, or see about creating a Pull Request back to Arduino. Or trying to integrate more of this functionality back into USBHost_t36.

But now back to playing
 
Quick update. Trying to see if I can use this to talk to some other Bluetooth hardware. SO far, no luck with XBOX One controller.

However, the Micrsoft Mouse:

Code:
Bluetooth® Low Energy Central - Peripheral Explorer
Found e1:59:47:7a:f2:be 'Surface Arc Mouse' 1812
Connecting ...
Connected
Discovering attributes ...
Attributes discovered

Device name: Surface Arc Mouse
Appearance: 0x0

Service 1800
	Characteristic 2a00, properties 0xA, value 0x5375726661636520417263204D6F757365
		Descriptor 2803, value 0x020500012A
		Descriptor 2a01, value 0xC203
	Characteristic 2a01, properties 0x2, value 0xC203
		Descriptor 2803, value 0x020700042A
		Descriptor 2a04, value 0x060006003C002C01
	Characteristic 2a04, properties 0x2, value 0x060006003C002C01
Service 1801
Service 180a
	Characteristic 2a29, properties 0x2
		Descriptor 2803, value 0x020D00502A
		Descriptor 2a50, value 0x
	Characteristic 2a50, properties 0x2
Service 180f
	Characteristic 2a19, properties 0x12
		Descriptor 2902, value 0x0000
Service 1812
	Characteristic 2a4e, properties 0x6
		Descriptor 2803, value 0x1A16004D2A
		Descriptor 2a4d, value 0x
	Characteristic 2a4d, properties 0x1A
		Descriptor 2902, value 0x0000
		Descriptor 2908, value 0x
		Descriptor 2803, value 0x1A1A004D2A
		Descriptor 2a4d, value 0x
	Characteristic 2a4d, properties 0x1A
		Descriptor 2902, value 0x0000
		Descriptor 2908, value 0x
		Descriptor 2803, value 0x1A1E004D2A
		Descriptor 2a4d, value 0x
	Characteristic 2a4d, properties 0x1A
		Descriptor 2902, value 0x0000
		Descriptor 2908, value 0x
		Descriptor 2803, value 0x1A22004D2A
		Descriptor 2a4d, value 0x
	Characteristic 2a4d, properties 0x1A
		Descriptor 2902, value 0x0000
		Descriptor 2908, value 0x
		Descriptor 2803, value 0x1A26004D2A
		Descriptor 2a4d, value 0x
	Characteristic 2a4d, properties 0x1A
		Descriptor 2902, value 0x0000
		Descriptor 2908, value 0x
		Descriptor 2803, value 0x1A2A004D2A
		Descriptor 2a4d, value 0x
	Characteristic 2a4d, properties 0x1A
		Descriptor 2902, value 0x0000
		Descriptor 2908, value 0x
		Descriptor 2803, value 0x1A2E004D2A
		Descriptor 2a4d, value 0x
	Characteristic 2a4d, properties 0x1A
		Descriptor 2902, value 0x0000
		Descriptor 2908, value 0x
		Descriptor 2803, value 0x1A32004D2A
		Descriptor 2a4d, value 0x
	Characteristic 2a4d, properties 0x1A
		Descriptor 2902, value 0x0000
		Descriptor 2908, value 0x
		Descriptor 2803, value 0x1A36004D2A
		Descriptor 2a4d, value 0x
	Characteristic 2a4d, properties 0x1A
		Descriptor 2902, value 0x0000
		Descriptor 2908, value 0x
		Descriptor 2803, value 0x1A3A004D2A
		Descriptor 2a4d, value 0x
	Characteristic 2a4d, properties 0x1A
		Descriptor 2902, value 0x0000
		Descriptor 2908, value 0x
		Descriptor 2803, value 0x0E3E004D2A
		Descriptor 2a4d, value 0x
	Characteristic 2a4d, properties 0xE
		Descriptor 2908, value 0x
		Descriptor 2803, value 0x0E41004D2A
		Descriptor 2a4d, value 0x
	Characteristic 2a4d, properties 0xE
		Descriptor 2908, value 0x
		Descriptor 2803, value 0x0A44004D2A
		Descriptor 2a4d, value 0x
	Characteristic 2a4d, properties 0xA
		Descriptor 2908, value 0x
		Descriptor 2803, value 0x0A47004D2A
		Descriptor 2a4d, value 0x
	Characteristic 2a4d, properties 0xA
		Descriptor 2908, value 0x
		Descriptor 2803, value 0x0A4A004D2A
		Descriptor 2a4d, value 0x
	Characteristic 2a4d, properties 0xA
		Descriptor 2908, value 0x
		Descriptor 2803, value 0x0A4D004D2A
		Descriptor 2a4d, value 0x
	Characteristic 2a4d, properties 0xA
		Descriptor 2908, value 0x
		Descriptor 2803, value 0x0250004B2A
		Descriptor 2a4b, value 0x
	Characteristic 2a4b, properties 0x2
		Descriptor 2803, value 0x1A5200332A
		Descriptor 2a33, value 0x
	Characteristic 2a33, properties 0x1A
		Descriptor 2902, value 0x0000
		Descriptor 2803, value 0x0255004A2A
		Descriptor 2a4a, value 0x
	Characteristic 2a4a, properties 0x2
		Descriptor 2803, value 0x
		Descriptor 2a4c, value 0x
	Characteristic 2a4c, properties 0x4

Disconnecting ...
Disconnected
Needed to first setup the mouse into pairing mode and then it found this information.

Now to see in the library how to do the pairing...

EDIT: I hacked up their sketch to show the standard names for many of the standard 16 bit UUIDs
So now looks like:
Code:
Device name: Surface Arc Mouse
Appearance: 0x0

Service 1800	//Generic Access service
	Characteristic 2a00, properties 0xA, value 0x5375726661636520417263204D6F757365	//Device Name
		Descriptor 2803, value 0x020500012A	//Characteristic
		Descriptor 2a01, value 0xC203	//Appearance
	Characteristic 2a01, properties 0x2, value 0xC203	//Appearance
		Descriptor 2803, value 0x020700042A	//Characteristic
		Descriptor 2a04, value 0x060006003C002C01	//Peripheral Preferred Connection Parameters
	Characteristic 2a04, properties 0x2, value 0x060006003C002C01	//Peripheral Preferred Connection Parameters
Service 1801	//Generic Attribute service
Service 180a	//Device Information service
	Characteristic 2a29, properties 0x2	//Manufacturer Name String
		Descriptor 2803, value 0x020D00502A	//Characteristic
		Descriptor 2a50, value 0x	//PnP ID
	Characteristic 2a50, properties 0x2	//PnP ID
Service 180f	//Battery service
	Characteristic 2a19, properties 0x12	//Battery Level
		Descriptor 2902, value 0x0000	//Client Characteristic Configuration
Service 1812	//Human Interface Device service
	Characteristic 2a4e, properties 0x6	//Protocol Mode
		Descriptor 2803, value 0x1A16004D2A	//Characteristic
		Descriptor 2a4d, value 0x	//Report
	Characteristic 2a4d, properties 0x1A	//Report
		Descriptor 2902, value 0x0000	//Client Characteristic Configuration
		Descriptor 2908, value 0x	//Report Reference
		Descriptor 2803, value 0x1A1A004D2A	//Characteristic
		Descriptor 2a4d, value 0x	//Report
	Characteristic 2a4d, properties 0x1A	//Report
		Descriptor 2902, value 0x0000	//Client Characteristic Configuration
		Descriptor 2908, value 0x	//Report Reference
		Descriptor 2803, value 0x1A1E004D2A	//Characteristic
		Descriptor 2a4d, value 0x	//Report
	Characteristic 2a4d, properties 0x1A	//Report
		Descriptor 2902, value 0x0000	//Client Characteristic Configuration
		Descriptor 2908, value 0x	//Report Reference
		Descriptor 2803, value 0x1A22004D2A	//Characteristic
		Descriptor 2a4d, value 0x	//Report
	Characteristic 2a4d, properties 0x1A	//Report
		Descriptor 2902, value 0x0000	//Client Characteristic Configuration
		Descriptor 2908, value 0x	//Report Reference
		Descriptor 2803, value 0x1A26004D2A	//Characteristic
		Descriptor 2a4d, value 0x	//Report
	Characteristic 2a4d, properties 0x1A	//Report
		Descriptor 2902, value 0x0000	//Client Characteristic Configuration
		Descriptor 2908, value 0x	//Report Reference
		Descriptor 2803, value 0x1A2A004D2A	//Characteristic
		Descriptor 2a4d, value 0x	//Report
	Characteristic 2a4d, properties 0x1A	//Report
		Descriptor 2902, value 0x0000	//Client Characteristic Configuration
		Descriptor 2908, value 0x	//Report Reference
		Descriptor 2803, value 0x1A2E004D2A	//Characteristic
		Descriptor 2a4d, value 0x	//Report
	Characteristic 2a4d, properties 0x1A	//Report
		Descriptor 2902, value 0x0000	//Client Characteristic Configuration
		Descriptor 2908, value 0x	//Report Reference
		Descriptor 2803, value 0x1A32004D2A	//Characteristic
		Descriptor 2a4d, value 0x	//Report
	Characteristic 2a4d, properties 0x1A	//Report
		Descriptor 2902, value 0x0000	//Client Characteristic Configuration
		Descriptor 2908, value 0x	//Report Reference
		Descriptor 2803, value 0x1A36004D2A	//Characteristic
		Descriptor 2a4d, value 0x	//Report
	Characteristic 2a4d, properties 0x1A	//Report
		Descriptor 2902, value 0x0000	//Client Characteristic Configuration
		Descriptor 2908, value 0x	//Report Reference
		Descriptor 2803, value 0x1A3A004D2A	//Characteristic
		Descriptor 2a4d, value 0x	//Report
	Characteristic 2a4d, properties 0x1A	//Report
		Descriptor 2902, value 0x0000	//Client Characteristic Configuration
		Descriptor 2908, value 0x	//Report Reference
		Descriptor 2803, value 0x0E3E004D2A	//Characteristic
		Descriptor 2a4d, value 0x	//Report
	Characteristic 2a4d, properties 0xE	//Report
		Descriptor 2908, value 0x	//Report Reference
		Descriptor 2803, value 0x0E41004D2A	//Characteristic
		Descriptor 2a4d, value 0x	//Report
	Characteristic 2a4d, properties 0xE	//Report
		Descriptor 2908, value 0x	//Report Reference
		Descriptor 2803, value 0x0A44004D2A	//Characteristic
		Descriptor 2a4d, value 0x	//Report
	Characteristic 2a4d, properties 0xA	//Report
		Descriptor 2908, value 0x	//Report Reference
		Descriptor 2803, value 0x0A47004D2A	//Characteristic
		Descriptor 2a4d, value 0x	//Report
	Characteristic 2a4d, properties 0xA	//Report
		Descriptor 2908, value 0x	//Report Reference
		Descriptor 2803, value 0x0A4A004D2A	//Characteristic
		Descriptor 2a4d, value 0x	//Report
	Characteristic 2a4d, properties 0xA	//Report
		Descriptor 2908, value 0x	//Report Reference
		Descriptor 2803, value 0x0A4D004D2A	//Characteristic
		Descriptor 2a4d, value 0x	//Report
	Characteristic 2a4d, properties 0xA	//Report
		Descriptor 2908, value 0x	//Report Reference
		Descriptor 2803, value 0x0250004B2A	//Characteristic
		Descriptor 2a4b, value 0x	//Report Map
	Characteristic 2a4b, properties 0x2	//Report Map
		Descriptor 2803, value 0x1A5200332A	//Characteristic
		Descriptor 2a33, value 0x	//Boot Mouse Input Report
	Characteristic 2a33, properties 0x1A	//Boot Mouse Input Report
		Descriptor 2902, value 0x0000	//Client Characteristic Configuration
		Descriptor 2803, value 0x0255004A2A	//Characteristic
		Descriptor 2a4a, value 0x	//HID Information
	Characteristic 2a4a, properties 0x2	//HID Information
		Descriptor 2803, value 0x0457004C2A	//Characteristic
		Descriptor 2a4c, value 0x	//HID Control Point
	Characteristic 2a4c, properties 0x4	//HID Control Point

Disconnecting ...
Disconnected
 
Last edited:
Over the past week or so I wanted to try out the changes made to ArduinoBLE to make it work with Teensy. Since I don't particularly care for BLE for telemetry data wanted to see what it could do. I came across an Arduino tutorial "Displaying on-Board Sensor Values on a WebBLE Dashboard" for the Arduino Nicla Sense ME board which shows how to read sensor data from the board and display it in a Dashboard using googles webBLE api. Following the link to source code: https://github.com/arduino/ArduinoAI there was a similar example for the arduino nano BLE Sens board.

So as an experiment I hooked up a Sparkfun ICM-20948 and modified the sketch to just send acceleration/gyro/magnetometer data as well as Yaw/Pitch/Roll using the Madgwick filter over BLE. Then modified the dashboard which I put on a github.io page just to display accel/mag/gyro and YPR data. And it worked. Unfortunately never could get 3d vis working. Think the issue is timing since the Teensy so fast - had to add a bunch of delays. Here is what I was able to get:
Capture.jpg

if you want to check it out for yourself with a Teensy: https://github.com/mjs513/mjs513.github.io. It has the sketch and the link you click on to display the dashboard in the browser - I use Edge.
 
Greate stuff @mjs513. I ran this stuff earlier today. I used the qwiic connector on my MMOD board and connected up the same chip and output the data to Edge as well!

Still wondering the best way to integrate the BLE stuff into the Teensy!
As you mentioned I have the fork/branch of the ArduinoBLE library that we are using here.

Which I now have seen and played with some examples of it, which allow me to pair/bond a Teensy to a host like PC or iPad. Which is great. What I still need to fully understand is the steps needed to for example bond an external device, like an XBox One to the Teensy.

The good news is, that there is an example that I have tried that works for ESP32:
Which is located up at: https://github.com/asukiaaa/arduino-XboxSeriesXControllerESP32
Yesterday I did pair up my updated XBox One controller (now uses BLE), to talk to an ESP32. I tried it with the Sparkfun ESP32 Thing Plus. I turned on lots of debug output, so now need to walk through to see what all they needed to do. Note: They use a completely different BLE library: NimBLE-Arduino

I have also played with a few different Adafruit products, that use another different setup and library BlueFruit. The most recent one I picked up was an
ItsyBitsy nRF52840 Express - Bluetooth LE
4481-04.jpg


Which is sort of fun. It is the same size as the Teensy 3.2/4.0 and has bluetooth built in. So far, I have only tried out a few of their examples, like one that again registers/bonds with the PC and outputs a standard battery level feature, that I was able to see on the PC, using a few different apps/systems.

It might be fun if there was a version of Teensy, with something like this built in.

Now back to ...
 
Back
Top