USB Host Bluetooth Pairing Mode

hbtousa

Active member
Hello. I have a BT dongle. I've been looking throughout the forum and the many USBHost_t36 samples for the code that will allow the BT dongle to get in pairing mode. One of the samples, Digitizer, allowed me to verify the BT is connected. This is how far i got. BTConnected.JPG. I have a T3.6, and a Rev C audio board. My final goal is to send out Audio from a Cell Phone to the Teensy.. Can I please, get the help to get the dongle in pairing mode?


Thanks.
 
Most of the examples used here from the host thread where it developed had a line in the code to edit.

Run the first time with a command to go into pairing mode, then rebuild with that turned off after the device is paired.

see examples like: ...\hardware\teensy\avr\libraries\USBHost_t36\examples\Bluetooth\KeyboardBT\KeyboardBT.ino
Code:
...
BluetoothController bluet(myusb, true, "0000");   // Version does pairing to device
//BluetoothController bluet(myusb);   // version assumes it already was paired
...
 
Last edited:
Thanks very kindly. I wrote some code but i can't get pass a complete pairing. I modify the code below so many times that I am the point right now of guessing, which that's why I need some help. Also, when compiling the file do I need to change Tools>USB Type>Serial to Tools>USB Type (something else). ? Thanks again
Code:
// Simple test of USB Host Mouse/Keyboard
//


#include "USBHost_t36.h"
//#include "debug_tt.h"

USBHost myusb;
USBHub hub1(myusb);
BluetoothController bluet(myusb, true, "0000");   // Version does pairing to device
//BluetoothController bluet(myusb);   // version assumes it already was paired



USBDriver *drivers[] = {&hub1,  &bluet };

#define CNT_DEVICES (sizeof(drivers)/sizeof(drivers[0]))
const char * driver_names[CNT_DEVICES] = {"Hub1",   "Bluet"};

bool driver_active[CNT_DEVICES] = {false, false};
uint8_t last_bdaddr[6] = {0, 0, 0, 0, 0, 0};

void setup()
{
  Serial1.begin(2000000);
  while (!Serial) ; // wait for Arduino Serial Monitor

  Serial.println("\n\nUSB Host Testing");
  Serial.println(sizeof(USBHub), DEC);
  myusb.begin();
  delay(2000);

}


void loop()
{
  myusb.Task();
  // check to see if the device list has changed:
  UpdateActiveDeviceInfo();
}

//=============================================================================
// UpdateActiveDeviceInfo
//=============================================================================
void UpdateActiveDeviceInfo() {

  for (uint8_t i = 0; i < CNT_DEVICES; i++) {
    if (*drivers[i] != driver_active[i]) {
      if (driver_active[i]) {
        Serial.printf("*** Device %s - disconnected ***\n", driver_names[i]);
        driver_active[i] = false;
      } else {
        Serial.printf("*** Device %s %x:%x - connected ***\n", driver_names[i], drivers[i]->idVendor(), drivers[i]->idProduct());
        driver_active[i] = true;
        const uint8_t *psz = drivers[i]->manufacturer();
        if (psz && *psz) Serial.printf("  Vendor: %s\n", psz);
        psz = drivers[i]->product();
        if (psz && *psz) Serial.printf("  Item: %s\n", psz);
        psz = drivers[i]->serialNumber();
        if (psz && *psz) Serial.printf("  Serial number: %s\n", psz);

        if (drivers[i] == &bluet) {
          const uint8_t *bdaddr = bluet.myBDAddr();
          // remember it...
          Serial.printf("  Code BDADDR: %02X:%02X:%02X:%02X:%02X:%02X\n", bdaddr[5], bdaddr[4], bdaddr[3], bdaddr[2], bdaddr[1], bdaddr[0]);
          for (uint8_t i = 0; i < 6; i++) last_bdaddr[i] = bdaddr[i];
        }
      }
    }
  }




// See about maybe pair...

    // so far just try call temporary pair info call...

    //********************
       Serial.print("\n Pairing Request");
    if (!last_bdaddr[0] && !last_bdaddr[1] && !last_bdaddr[2] && !last_bdaddr[3] && !last_bdaddr[4] && !last_bdaddr[5]) {
     Serial.println(" - failed - no Bluetooth adapter has been plugged in");
    } else if (!drivers[0]) {  // Kludge see if we are connected as HID?
      Serial.println(" - failed - PS3 device not plugged into USB");
    } else {
      Serial.printf(" - Attempt pair to: %02X:%02X:%02X:%02X:%02X:%02X\n", last_bdaddr[5], last_bdaddr[4], last_bdaddr[3], last_bdaddr[2], last_bdaddr[1], last_bdaddr[0]);

     // if (!bluet.PS3Pair(last_bdaddr)) {
     //   Serial.println("  Pairing call Failed");
    //  } else {
     //   Serial.println("  Pairing complete (I hope), make sure Bluetooth adapter is plugged in and try PS3 without USB");
     // }
    }
 }
 
Only a few known Bluetooth dongles tested to work well - there is a thread listing the ones used and found good.

There is a DEBUG #define commented out in the main file, enabling that will provide some feedback on the actions in progress.

Try it with a Bluetooth Keyboard or Mouse to see the Dongle work with a simple device to see base function is good.

USBHost works with just 'Serial' or other as it is separate from that device type.

<edit>: This Thread forum.pjrc.com/threads/49358-T3-6-USB-Host-Bluetooth
 
Last edited:
Only a few known Bluetooth dongles tested to work well - there is a thread listing the ones used and found good.
I bought three different dongles from the suggested ones from that particular thread. All three dongles showed connected.

After uncommenting Debug Line, message appeared "ResolveLibrary(debug_tt.h)rduino\BTPairing\BTPairing.ino:7:22: fatal error: debug_tt.h: No such file or directory"

I didn't mention it on my previous reply that after uncommenting the last IF on my code, the message "'class BluetoothController' has no member named 'PS3Pair'" showed up


Thanks so much.
 
debug_tt.h looks like something written here ... it can be commented out (as in p#3) or removed.

It is not something included anywhere or that generally evolved to anything useful across the evolving MCU's in use.
 
Back
Top