Parcourir la source

Allow BTDongle with type of 255

There are some of the BT dongles that have a device type of 0xff instead of the correct one, so added table of VID:PID to check against, currently only one in list.  If it is this pair the Bluetooth system will claim it.
main
Kurt Eckhardt il y a 5 ans
Parent
révision
11814d9f02
2 fichiers modifiés avec 40 ajouts et 4 suppressions
  1. +11
    -0
      USBHost_t36.h
  2. +29
    -4
      bluetooth.cpp

+ 11
- 0
USBHost_t36.h Voir le fichier

@@ -61,6 +61,11 @@
#define USBHDBGSerial Serial1


#ifndef USBHDBGSerial
#define USBHDBGSerial Serial
#endif


/************************************************/
/* Data Types */
/************************************************/
@@ -1733,6 +1738,12 @@ private:
uint16_t remote_man_;
uint8_t remote_subv_;

typedef struct {
uint16_t idVendor;
uint16_t idProduct;
} product_vendor_mapping_t;
static product_vendor_mapping_t pid_vid_mapping[];

};

#endif

+ 29
- 4
bluetooth.cpp Voir le fichier

@@ -147,6 +147,7 @@ enum {PC_RESET = 1, PC_WRITE_CLASS_DEVICE, PC_READ_BDADDR, PC_READ_LOCAL_VERSION

//////////////


// Setup some states for the TX pipe where we need to chain messages
enum {STATE_TX_SEND_CONNECT_INT=200, STATE_TX_SEND_CONECT_RSP_SUCCESS, STATE_TX_SEND_CONFIG_REQ};

@@ -184,7 +185,11 @@ BTHIDInput * BluetoothController::find_driver(uint32_t device_type)
}
return NULL;
}

//12 01 00 02 FF 01 01 40 5C 0A E8 21 12 01 01 02 03 01
//VendorID = 0A5C, ProductID = 21E8, Version = 0112
//Class/Subclass/Protocol = 255 / 1 / 1
BluetoothController::product_vendor_mapping_t BluetoothController::pid_vid_mapping[] = {
{ 0xA5C, 0x21E8 }};

/************************************************************/
// Initialization and claiming of devices & interfaces
@@ -203,11 +208,21 @@ bool BluetoothController::claim(Device_t *dev, int type, const uint8_t *descript
// only claim at device level
println("BluetoothController claim this=", (uint32_t)this, HEX);

if (type != 0) return false; // claim at the device level

// Lets try to support the main USB Bluetooth class...
// http://www.usb.org/developers/defined_class/#BaseClassE0h
if (dev->bDeviceClass != 0xe0) return false; // not base class wireless controller
if (dev->bDeviceClass != 0xe0) {
bool special_case_device = false;
for (uint8_t i=0; i < (sizeof(pid_vid_mapping)/sizeof(pid_vid_mapping[0])); i++) {
if ((pid_vid_mapping[i].idVendor == dev->idVendor) && (pid_vid_mapping[i].idProduct == dev->idProduct)) {
special_case_device = true;
break;
}
}
if (!special_case_device) return false;
}
if ((dev->bDeviceSubClass != 1) || (dev->bDeviceProtocol != 1)) return false; // Bluetooth Programming Interface
if (type != 0) return false;

DBGPrintf("BluetoothController claim this=%x vid:pid=%x:%x\n ", (uint32_t)this, dev->idVendor, dev->idProduct);
if (len > 512) {
@@ -784,7 +799,17 @@ void BluetoothController::handle_hci_remote_name_complete() {
for (uint8_t *psz = &rxbuf_[9]; *psz; psz++) DBGPrintf("%c", *psz);
DBGPrintf("\n");
}
if (device_driver_) device_driver_->remoteNameComplete(&rxbuf_[9]);
/*
if (device_driver_) {
if (!device_driver_->btstrbuf) {
device_driver_->btstrbuf = USBHost::allocate_string_buffer();
if (device_driver_->btstrbuf) {

}
}
device_driver_->remoteNameComplete(&rxbuf_[9]);
}
*/

// Lets now try to accept the connection.
sendHCIAcceptConnectionRequest();

Chargement…
Annuler
Enregistrer