Forums - CSR8510 Bluetooth Dongle - libusb

3 posts / 0 new
Last post
CSR8510 Bluetooth Dongle - libusb
brendan.gowen
Join Date: 5 Dec 16
Posts: 1
Posted: Mon, 2016-12-05 05:16

Hi, I have a CSR8510 Bluetooth Dongle.

I need to develope some desktop applications but I dont want to use the SDK kit to cummunicate to it. 

I would like to be able to talk directly to this dongle ( using VB.net or C#) through the libusb driver  ( I assume using the HCI commands)

Is there somewhere I could see some examples in VB or C# that show how this is done. ?

I can see there are several linux examples , even some in JS on windows ... but cant seem to find any in .net windows 7 ( which is why I'm going to try the libusb method)

Is there anyione there who could help me with this ? I assume  I need to start writing packest to the device endpoints but I dont know which and where.

 

A simple would example of getting the device to do a scan and return back the data it found would be a great start for me .. if any one know how to do this ?

 

Below is some code I got using the libusbdotnet (VB.net) and it can find my CSR dongle ... but I'm noty sure what to do after that.

(all help and suggestions would be greatfully appreciated . )

Private Sub Button2_Click(sender As Object, e As EventArgs) Handles Button2.Click
        Dim ec As ErrorCode = ErrorCode.None
        Try
            ' Find and open the usb device.
            MyUsbDevice = UsbDevice.OpenUsbDevice(MyUsbFinder)
            ' If the device is open and ready
            If MyUsbDevice Is Nothing Then
                Throw New Exception("Device Not Found.")
            End If
            ' If this is a "whole" usb device (libusb-win32, linux libusb-1.0)
            ' it exposes an IUsbDevice interface. If not (WinUSB) the 
            ' 'wholeUsbDevice' variable will be null indicating this is 
            ' an interface of a device; it does not require or support 
            ' configuration and interface selection.
            Dim wholeUsbDevice As IUsbDevice = TryCast(MyUsbDevice, IUsbDevice)
            If Not ReferenceEquals(wholeUsbDevice, Nothing) Then
                ' This is a "whole" USB device. Before it can be used, 
                ' the desired configuration and interface must be selected.
                ' Select config #1
                wholeUsbDevice.SetConfiguration(1)
                ' Claim interface #0.
                wholeUsbDevice.ClaimInterface(0)
            End If
            ' open read endpoint 1.
            Dim reader As UsbEndpointReader = MyUsbDevice.OpenEndpointReader(ReadEndpointID.Ep01                                                                 )
            Dim readBuffer As Byte() = New Byte(1023) {}
            While ec = ErrorCode.None
                Dim bytesRead As Integer
                ' If the device hasn't sent data in the last 5 seconds,
                ' a timeout error (ec = IoTimedOut) will occur. 
                ec = reader.Read(readBuffer, 5000, bytesRead)
                If bytesRead = 0 Then
                    Throw New Exception(String.Format("{0}:No more bytes!", ec))
                End If
                Console.WriteLine("{0} bytes read", bytesRead)
                ' Write that output to the console.
                TextBox2.Text = TextBox2.Text & Encoding.[Default].GetString(readBuffer, 0, bytesRead) & vbCrLf
                Console.Write(Encoding.[Default].GetString(readBuffer, 0, bytesRead))
            End While
            TextBox2.Text = TextBox2.Text & vbCr & vbLf & "Done!" & vbCr & vbLf
            Console.WriteLine(vbCr & vbLf & "Done!" & vbCr & vbLf)
        Catch ex As Exception
            TextBox2.Text = TextBox2.Text & vbCr
            Console.WriteLine()
            TextBox2.Text = TextBox2.Text & vbCr & ((If(ec <> ErrorCode.None, ec & ":", [String].Empty)) & ex.Message) & vbCrLf
            Console.WriteLine((If(ec <> ErrorCode.None, ec & ":", [String].Empty)) & ex.Message)
        Finally
            If MyUsbDevice IsNot Nothing Then
                If MyUsbDevice.IsOpen Then
                    ' If this is a "whole" usb device (libusb-win32, linux libusb-1.0)
                    ' it exposes an IUsbDevice interface. If not (WinUSB) the 
                    ' 'wholeUsbDevice' variable will be null indicating this is 
                    ' an interface of a device; it does not require or support 
                    ' configuration and interface selection.
                    Dim wholeUsbDevice As IUsbDevice = TryCast(MyUsbDevice, IUsbDevice)
                    If Not ReferenceEquals(wholeUsbDevice, Nothing) Then
                        ' Release interface #0.
                        wholeUsbDevice.ReleaseInterface(0)
                    End If
 
                    MyUsbDevice.Close()
                End If
                MyUsbDevice = Nothing
 
                ' Free usb resources
                UsbDevice.[Exit]()
            End If
        End Try

 

    End Sub

 

***********************Below is the output of this code :************************************

 

Length:18
DescriptorType:Device
BcdUsb:0x0200
Class:224
SubClass:0x01
Protocol:0x01
MaxPacketSize0:64
VendorID:0x0A12
ProductID:0x0001
BcdDevice:0x8891
ManufacturerStringIndex:0
ProductStringIndex:2
SerialStringIndex:0
ConfigurationCount:1
ManufacturerString:
ProductString:CSR8510 A10
SerialString:
 
Length:9
DescriptorType:Interface
InterfaceID:0
AlternateID:0
EndpointCount:3
Class:224
SubClass:0x01
Protocol:0x01
StringIndex:0
InterfaceString:
 
Length:7
DescriptorType:Endpoint
EndpointID:0x81
Attributes:0x03
MaxPacketSize:16
Interval:1
Refresh:0
SynchAddress:0x00
 
Length:7
DescriptorType:Endpoint
EndpointID:0x02
Attributes:0x02
MaxPacketSize:64
Interval:1
Refresh:0
SynchAddress:0x00
 
Length:7
DescriptorType:Endpoint
EndpointID:0x82
Attributes:0x02
MaxPacketSize:64
Interval:1
Refresh:0
SynchAddress:0x00
 
Length:9
DescriptorType:Interface
InterfaceID:1
AlternateID:0
EndpointCount:2
Class:224
SubClass:0x01
Protocol:0x01
StringIndex:0
InterfaceString:
 
Length:7
DescriptorType:Endpoint
EndpointID:0x03
Attributes:0x01
MaxPacketSize:0
Interval:1
Refresh:0
SynchAddress:0x00
 
Length:7
DescriptorType:Endpoint
EndpointID:0x83
Attributes:0x01
MaxPacketSize:0
Interval:1
Refresh:0
SynchAddress:0x00
 
Length:9
DescriptorType:Interface
InterfaceID:1
AlternateID:1
EndpointCount:2
Class:224
SubClass:0x01
Protocol:0x01
StringIndex:0
InterfaceString:
 
Length:7
DescriptorType:Endpoint
EndpointID:0x03
Attributes:0x01
MaxPacketSize:9
Interval:1
Refresh:0
SynchAddress:0x00
 
Length:7
DescriptorType:Endpoint
EndpointID:0x83
Attributes:0x01
MaxPacketSize:9
Interval:1
Refresh:0
SynchAddress:0x00
 
Length:9
DescriptorType:Interface
InterfaceID:1
AlternateID:2
EndpointCount:2
Class:224
SubClass:0x01
Protocol:0x01
StringIndex:0
InterfaceString:
 
Length:7
DescriptorType:Endpoint
EndpointID:0x03
Attributes:0x01
MaxPacketSize:17
Interval:1
Refresh:0
SynchAddress:0x00
 
Length:7
DescriptorType:Endpoint
EndpointID:0x83
Attributes:0x01
MaxPacketSize:17
Interval:1
Refresh:0
SynchAddress:0x00
 
Length:9
DescriptorType:Interface
InterfaceID:1
AlternateID:3
EndpointCount:2
Class:224
SubClass:0x01
Protocol:0x01
StringIndex:0
InterfaceString:
 
Length:7
DescriptorType:Endpoint
EndpointID:0x03
Attributes:0x01
MaxPacketSize:25
Interval:1
Refresh:0
SynchAddress:0x00
 
Length:7
DescriptorType:Endpoint
EndpointID:0x83
Attributes:0x01
MaxPacketSize:25
Interval:1
Refresh:0
SynchAddress:0x00
 
Length:9
DescriptorType:Interface
InterfaceID:1
AlternateID:4
EndpointCount:2
Class:224
SubClass:0x01
Protocol:0x01
StringIndex:0
InterfaceString:
 
Length:7
DescriptorType:Endpoint
EndpointID:0x03
Attributes:0x01
MaxPacketSize:33
Interval:1
Refresh:0
SynchAddress:0x00
 
Length:7
DescriptorType:Endpoint
EndpointID:0x83
Attributes:0x01
MaxPacketSize:33
Interval:1
Refresh:0
SynchAddress:0x00
 
Length:9
DescriptorType:Interface
InterfaceID:1
AlternateID:5
EndpointCount:2
Class:224
SubClass:0x01
Protocol:0x01
StringIndex:0
InterfaceString:
 
Length:7
DescriptorType:Endpoint
EndpointID:0x03
Attributes:0x01
MaxPacketSize:49
Interval:1
Refresh:0
SynchAddress:0x00
 
Length:7
DescriptorType:Endpoint
EndpointID:0x83
Attributes:0x01
MaxPacketSize:49
Interval:1
Refresh:0
SynchAddress:0x00

 

 

 

 

Length:18

DescriptorType:Device
BcdUsb:0x0200
Class:224
SubClass:0x01
Protocol:0x01
MaxPacketSize0:64
VendorID:0x0A12
ProductID:0x0001
BcdDevice:0x8891
ManufacturerStringIndex:0
ProductStringIndex:2
SerialStringIndex:0
ConfigurationCount:1
ManufacturerString:
ProductString:CSR8510 A10
SerialString:
 
Length:9
DescriptorType:Interface
InterfaceID:0
AlternateID:0
EndpointCount:3
Class:224
SubClass:0x01
Protocol:0x01
StringIndex:0
InterfaceString:
 
Length:7
DescriptorType:Endpoint
EndpointID:0x81
Attributes:0x03
MaxPacketSize:16
Interval:1
Refresh:0
SynchAddress:0x00
 
Length:7
DescriptorType:Endpoint
EndpointID:0x02
Attributes:0x02
MaxPacketSize:64
Interval:1
Refresh:0
SynchAddress:0x00
 
Length:7
DescriptorType:Endpoint
EndpointID:0x82
Attributes:0x02
MaxPacketSize:64
Interval:1
Refresh:0
SynchAddress:0x00
 
Length:9
DescriptorType:Interface
InterfaceID:1
AlternateID:0
EndpointCount:2
Class:224
SubClass:0x01
Protocol:0x01
StringIndex:0
InterfaceString:
 
Length:7
DescriptorType:Endpoint
EndpointID:0x03
Attributes:0x01
MaxPacketSize:0
Interval:1
Refresh:0
SynchAddress:0x00
 
Length:7
DescriptorType:Endpoint
EndpointID:0x83
Attributes:0x01
MaxPacketSize:0
Interval:1
Refresh:0
SynchAddress:0x00
 
Length:9
DescriptorType:Interface
InterfaceID:1
AlternateID:1
EndpointCount:2
Class:224
SubClass:0x01
Protocol:0x01
StringIndex:0
InterfaceString:
 
Length:7
DescriptorType:Endpoint
EndpointID:0x03
Attributes:0x01
MaxPacketSize:9
Interval:1
Refresh:0
SynchAddress:0x00
 
Length:7
DescriptorType:Endpoint
EndpointID:0x83
Attributes:0x01
MaxPacketSize:9
Interval:1
Refresh:0
SynchAddress:0x00
 
Length:9
DescriptorType:Interface
InterfaceID:1
AlternateID:2
EndpointCount:2
Class:224
SubClass:0x01
Protocol:0x01
StringIndex:0
InterfaceString:
 
Length:7
DescriptorType:Endpoint
EndpointID:0x03
Attributes:0x01
MaxPacketSize:17
Interval:1
Refresh:0
SynchAddress:0x00
 
Length:7
DescriptorType:Endpoint
EndpointID:0x83
Attributes:0x01
MaxPacketSize:17
Interval:1
Refresh:0
SynchAddress:0x00
 
Length:9
DescriptorType:Interface
InterfaceID:1
AlternateID:3
EndpointCount:2
Class:224
SubClass:0x01
Protocol:0x01
StringIndex:0
InterfaceString:
 
Length:7
DescriptorType:Endpoint
EndpointID:0x03
Attributes:0x01
MaxPacketSize:25
Interval:1
Refresh:0
SynchAddress:0x00
 
Length:7
DescriptorType:Endpoint
EndpointID:0x83
Attributes:0x01
MaxPacketSize:25
Interval:1
Refresh:0
SynchAddress:0x00
 
Length:9
DescriptorType:Interface
InterfaceID:1
AlternateID:4
EndpointCount:2
Class:224
SubClass:0x01
Protocol:0x01
StringIndex:0
InterfaceString:
 
Length:7
DescriptorType:Endpoint
EndpointID:0x03
Attributes:0x01
MaxPacketSize:33
Interval:1
Refresh:0
SynchAddress:0x00
 
Length:7
DescriptorType:Endpoint
EndpointID:0x83
Attributes:0x01
MaxPacketSize:33
Interval:1
Refresh:0
SynchAddress:0x00
 
Length:9
DescriptorType:Interface
InterfaceID:1
AlternateID:5
EndpointCount:2
Class:224
SubClass:0x01
Protocol:0x01
StringIndex:0
InterfaceString:
 
Length:7
DescriptorType:Endpoint
EndpointID:0x03
Attributes:0x01
MaxPacketSize:49
Interval:1
Refresh:0
SynchAddress:0x00
 
Length:7
DescriptorType:Endpoint
EndpointID:0x83
Attributes:0x01
MaxPacketSize:49
Interval:1
Refresh:0
SynchAddress:0x00

 

 

 

  • Up0
  • Down0
pradprad
Join Date: 2 Mar 17
Posts: 2
Posted: Thu, 2017-03-02 03:43

Hi, 

I stumbled upon your post as I am working on a similar project as yours and going to use LibUsbDotNet.

Reading the bluetooth spec for USB transport, I find that bluetooth sig recommends Endpoint ID =0x00 for sending HCI commands and Endpoint ID=0x81 for receiving HCI events, and it is recommended that endpoint 0x81 be interrupt end point. I am not sure if all the vendors follow this. 

The starting point to test whether your BT controller is reponsive would be sending HCI reset command over the above end points. Which would be in hex.

03 0C 00.

You should receive 

0E 04 01 03 0C 00 which is basically command complete event for HCI reset command. 
 
I haven't tested it myself and I am going to do that now. Assuming the above works, it would open doors for you to send other HCI commands such as set device name, or address or issue inquiry command. 
 
Try that and let me know if it works!

 

  • Up0
  • Down0
manojshakti619
Join Date: 15 Mar 17
Posts: 1
Posted: Wed, 2017-03-15 03:00

Hi

   I was also trying the similar activity of sending the commands to usbbluetooth controller. I have written my own bluetooth usb module & loaded into the linux kernel. I was able to detect the bt controller,send HCI reset,event filter command.But for the RESET command I should recieve an event of size bytes.I was receving the 6 bytes immediately but in the data which I received is 0x00 0x00 0x00 0x00 0x00 0x00. For event filter also I am receving the same data.

 I was reading from the 0x81(interrupt port) of the bluetooth usb controller.The bluetooth controller which I was using intel & I have read the the end point for the interrupt controller is 0x81 for the controller. 

 

It would be greaful if anyone who has answer can respond

 

Thanks in advance...;)

 

  • Up0
  • Down0
or Register

Opinions expressed in the content posted here are the personal opinions of the original authors, and do not necessarily reflect those of Qualcomm Incorporated or its subsidiaries (“Qualcomm”). The content is provided for informational purposes only and is not meant to be an endorsement or representation by Qualcomm or any other party. This site may also provide links or references to non-Qualcomm sites and resources. Qualcomm makes no representations, warranties, or other commitments whatsoever about any non-Qualcomm sites or third-party resources that may be referenced, accessible from, or linked to this site.