Search code examples
cbluetoothlibusb-1.0bluetooth-hci

Writing HCI command to USB BT Dongle


My small project is to write HCI commands to Bluetooth USB dongle and get response for HCI commands.

I could print all endpoints address of my USB Bluetooth dongle as below (using libusb). According to specification of the Bluetooth system Host Control Interface [Transport Layer], (section 2.1) endpoint address 0x00 is used for writing HCI commands. But I could not find endpoint address 0x00 in my Bluetooth dongle.

config[0]->interface[0]->altsetting[0]->endpoint[0]->bEndpointAddress=0x81 packetsize=16
config[0]->interface[0]->altsetting[0]->endpoint[1]->bEndpointAddress=0x02 packetsize=64
config[0]->interface[0]->altsetting[0]->endpoint[2]->bEndpointAddress=0x82 packetsize=64
config[0]->interface[1]->altsetting[0]->endpoint[0]->bEndpointAddress=0x03 packetsize=0
config[0]->interface[1]->altsetting[0]->endpoint[1]->bEndpointAddress=0x83 packetsize=0
config[0]->interface[1]->altsetting[1]->endpoint[0]->bEndpointAddress=0x03 packetsize=9
config[0]->interface[1]->altsetting[1]->endpoint[1]->bEndpointAddress=0x83 packetsize=9
config[0]->interface[1]->altsetting[2]->endpoint[0]->bEndpointAddress=0x03 packetsize=17
config[0]->interface[1]->altsetting[2]->endpoint[1]->bEndpointAddress=0x83 packetsize=17
config[0]->interface[1]->altsetting[3]->endpoint[0]->bEndpointAddress=0x03 packetsize=25
config[0]->interface[1]->altsetting[3]->endpoint[1]->bEndpointAddress=0x83 packetsize=25
config[0]->interface[1]->altsetting[4]->endpoint[0]->bEndpointAddress=0x03 packetsize=33
config[0]->interface[1]->altsetting[4]->endpoint[1]->bEndpointAddress=0x83 packetsize=33
config[0]->interface[1]->altsetting[5]->endpoint[0]->bEndpointAddress=0x03 packetsize=49
config[0]->interface[1]->altsetting[5]->endpoint[1]->bEndpointAddress=0x83 packetsize=49
  1. Does this mean that, my Bluetooth dongle does not support sending HCI commands
  2. If yes, is there any alternative way to send HCI commands to my Bluetooth dongle

Solution

  • Endpoint 0x00 is "reserved" for control transfer between host and device and as of the fact, that every device has to have this endpoint it has no endpoint descriptor. Althrough your host is using this endpoint to enumerate and configure your device you still have the possibility to use it for your communication. All you have to do is start a control transfer on the endpoint 0x00. You don't have to configure the device or claim an interface to do that but I recommend you do it anyway (may have certain advantages for speed and such).