T3.6 USB Host - Bluetooth

Another quick Bluetooth update:

I have been tearing apart some of this code and probably screwing up everything ;)

In particular, I have now broken up bluetooth.cpp into two files. More specifically the BluetoothController object used to have an array of structures, where each record in the array corresponds to one connection to a BT device. I have now converted that struct into a class and moved a lot of the code associated with a connection, to be methods on the new class. The new class was moved to a new file BluetoothConnection.cpp. Also, a new header file, was created with a lot of the defines that are used in the two files.

The new file now has the code to talk to SDP (and L2CAP). The BLuetooth Claim code now asks each of the BTHID objects if they wish to claim the connection directly. If no one claims it, it thentries to connect up to SDP and if so, tries to retrieve the HID Descriptor. If that succeeds, then it has a copy of parse() that it then walks through the descriptor and again asks each of the BTHID objecs if they
wish to claim a collection or not... (like HID except I added BT_ to the start of the HID methods). If a report descriptor is not found, it calls again to each of the BTHID objects with a different value for option and sees if anyone wishes to claim it now.

UPdated Keyboard and Mouse so far.

I now have the Rii mini-keyboard working with this. And now if the sketch has both Mouse and Keyboard, they will both claim topusage reports from this object.
Tested some with a couple of others.

Still lots more testing to go. Also have not gone through the Paring code path. yet so probably busted. I am hoping as part of this, will be able to add a Paring method, such that you won't need to necessarily change the code and rebuild to support pairing a new device.

Also need other cleanup and extension. Like I know I have a name for the device, but don't think we save it anywhere.

I am also seeing if I can get rid of a few HACKS in the code. For example, we know the PS4, expects us to send the L2CAP commands to make connections, where most all other devices initiate the connection calls.

The code currently detects that it is a PS4 and special cases it by VID/PID.

But now thinking I can do it by some standard BT mechanism.

That is: When we send the HCI_ACCEPT_CONNECT, we receive back the event: Connection Complete.

Now if at that point I send out the request: HCI_ROLE_DISCOVERY,
We should get the event Command Complete, with some additional information:

Which in the PS4: case I see:
Code:
<<(01):0E 07 01 09 08 00 47 00 01 
    Command Completed!
For some other device like a BT Mouse I see something like:
Code:
<<(01):0E 07 01 09 08 00 48 00 00 
    Command Completed!
So for this command (the 09 08) there are 4 returned bytes:
00 Succeeded
(next two are connection handle)

The last byte is the interesting one:
00 for Mouse (and keyboard...) - 0x00 Current Role is Master for this Connection_Handle.
01 for PS4 - 0x01 Current Role is Slave for this Connection_Handle.

PS3 - <<(01):0E 07 01 09 08 00 48 00 00 (again shows as master)

Lots more experimenting!

But tomorrow is another day.
 
Hello, I'm encountering an issue when trying to connect a Bluetooth dongle to a mobile device, and I'm wondering if this is supported by the library. I've attempted to pair the dongle with my mobile device using the DeviceInfo example. So far, I've tried two different dongles: one from Asus and the recommended CSR 4.0 model. While both dongles initially connect, the connection crashes as soon as I try to pair them with my mobile device. Here's what appears in the serial monitor:


1723789695332.png



All help is kindly appreciated. :)
 
Sorry, all I can tell you so far is something crashed.

@PaulStoffregen recently put up a page on PJRC about Crashreports,

Although looks like it is still missing one very important part, which is how to run addr2line.
Sorry, I don't know if you are using Windows/Mac/Ubuntu, on which IDE and which version of it likewise which version of Teensy code...

What I typically do, is find where the code was built and open up a command window at that location. You can find the directory in the
command lines that are executed during builds. At least when you run the build in verbose mode (option in the Arduino preferences dialog)
Or what I typically do on windows: Is open up a browser window. I then navigate to where the temporary files are generated on Arduino:
In my case I to to: %temp%\arduino\sketches
I look at the different directories there, which have names like:
1723808659611.png

And in my case, there was only one. I get into that directory.
I then open up a terminal window: I have the windows Terminal app installed from the Windows store.
So I just right click in the window and open up Terminal and search for the .elf file for the sketch you built.
Code:
 Directory of C:\Users\kurte\AppData\Local\Temp\arduino\sketches\5D50F9914F75299380EFCB4BAF8187B9

08/16/2024  04:40 AM    <DIR>          .
08/16/2024  04:39 AM    <DIR>          ..
08/16/2024  04:39 AM                 0 .last-used
08/16/2024  04:39 AM               600 build.options.json
08/16/2024  04:40 AM                34 Compare_565_888_color_ranges.ino.eep
08/16/2024  04:40 AM         1,196,124 Compare_565_888_color_ranges.ino.elf
08/16/2024  04:40 AM           852,651 Compare_565_888_color_ranges.ino.hex
08/16/2024  04:40 AM         1,576,947 Compare_565_888_color_ranges.ino.lst
08/16/2024  04:40 AM            34,666 Compare_565_888_color_ranges.ino.sym

In my case I have the above: If I use the command line:
Code:
C:\Users\kurte\AppData\Local\Temp\arduino\sketches\5D50F9914F75299380EFCB4BAF8187B9>addr2line -e Compare_565_888_color_ranges.ino.elf 0x8104
C:\Users\kurte\AppData\Local\Arduino15\packages\teensy\hardware\avr\1.59.0\cores\teensy4/usb.c:506

In the case of the sketch I just built that address is into usb.c line 506.
It almost for sure would be some different file and line in your sketch.

However I cheated. I have a copy of the addr2line in a directory on my search path.
The Current version of the addr2line is installed where the Arduino tools for the Teensy are installed. And in my case on Windows,
using IDE2 with current stuff, it is located at:

Code:
C:\Users\kurte\AppData\Local\Arduino15\packages\teensy\tools\teensy-compile\11.3.1\arm\bin\arm-none-eabi-addr2line.exe

So the command line might instead be:

Code:
C:\Users\kurte\AppData\Local\Temp\arduino\sketches\5D50F9914F75299380EFCB4BAF8187B9>C:\Users\kurte\AppData\Local\Arduino15\packages\teensy\tools\teensy-compile\11.3.1\arm\bin\arm-none-eabi-addr2line.exe -e Compare_565_888_color_ranges.ino.elf 0x8104
C:\Users\kurte\AppData\Local\Arduino15\packages\teensy\hardware\avr\1.59.0\cores\teensy4/usb.c:506

Alternative be in the directory where the addr2line is and use the long path name to where the .elf file is.

Hopefully - this will work and will point you to where the code crashed.


Edit: Probably best to continue this in your new thread which has more information:
 
Last edited:
Back
Top