|
|
|
|
|
|
|
|
|
|
|
|
|
|
////////////// |
|
|
////////////// |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
// Setup some states for the TX pipe where we need to chain messages |
|
|
// 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}; |
|
|
enum {STATE_TX_SEND_CONNECT_INT=200, STATE_TX_SEND_CONECT_RSP_SUCCESS, STATE_TX_SEND_CONFIG_REQ}; |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
} |
|
|
} |
|
|
return NULL; |
|
|
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 |
|
|
// Initialization and claiming of devices & interfaces |
|
|
|
|
|
|
|
|
// only claim at device level |
|
|
// only claim at device level |
|
|
println("BluetoothController claim this=", (uint32_t)this, HEX); |
|
|
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... |
|
|
// Lets try to support the main USB Bluetooth class... |
|
|
// http://www.usb.org/developers/defined_class/#BaseClassE0h |
|
|
// 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 ((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); |
|
|
DBGPrintf("BluetoothController claim this=%x vid:pid=%x:%x\n ", (uint32_t)this, dev->idVendor, dev->idProduct); |
|
|
if (len > 512) { |
|
|
if (len > 512) { |
|
|
|
|
|
|
|
|
for (uint8_t *psz = &rxbuf_[9]; *psz; psz++) DBGPrintf("%c", *psz); |
|
|
for (uint8_t *psz = &rxbuf_[9]; *psz; psz++) DBGPrintf("%c", *psz); |
|
|
DBGPrintf("\n"); |
|
|
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. |
|
|
// Lets now try to accept the connection. |
|
|
sendHCIAcceptConnectionRequest(); |
|
|
sendHCIAcceptConnectionRequest(); |