Where to start with HFP and dialing.

Topics: Bluetooth - Microsoft, Bluetooth - Other
May 8, 2012 at 5:58 AM
Edited May 8, 2012 at 5:59 AM

Hi, I've been developing .Net applications for about 10 years now and have a fair amount of experience w/ embedded development and serial communications but I've hit a brick wall with bluetooth development. I'm just not sure which piece of the puzzle I'm missing.

Background:  My goal is to ,from managed code on a desktop, connect to a Konftel conference phone via bluetooth and dial, answer, and hangup. I really don't care about the audio side of the equation. My development laptop is Windows 7 and I'm using Visual Studio 2010 to develop a framework 4 app. I have an Asus USB bluetooth adapter that appears to recoginze the phone. In the bluetooth setup the phone advertises that it supports the headset profile and hands free telephony. According to the manufacturer the phone is capable of dialing, answering and hanging up over bluetooth.

Current Status: I've succesfully connected to the radio and I can see the phone when I run discover devices. Quering the radio revealse that the manufacturer is AtherosCommunications and the software manufacturer is Microsoft. I've exhausted my google search abilites and I'm fairly sure that I need to connect and issue AT commands. Which is cool since I'm old enough to have a fair amount of experience with modems and AT commands. Who remembers external modem :) ? I've noticed from screen shots that I've seen online that some adapters advertise the serial list for the HFP. FYI: I have disabled/disconnected the services before trying to connect to the phone so windows isn't holding the "port". 

So, here are my questions.

1) Am I using the microsoft bluetooth stack or something from Atheros?

2) Do I need a different bluetooth adapter? Would buying one that supports Widcom make all of this easy? If so which adapter do I buy? It's not like they advertise the chipset they are using.

3)Where can I find the AT command list? I'm assuming that it's a standard or there wouldn't be any real interoperablity?

4) I found some sample code for dialing. Is it even close? (see below)

5) Is there any better sample code available?

6) Is there something else completely obvious that I'm missing?

7) Where can I find some good documentation/tutorials/books on the subject to get started?

 

 

 

Dim deviceAddr As [String] = "00:11::22:33:44" 
        Dim addr As BluetoothAddress = BluetoothAddress.Parse(deviceAddr)
        Dim rep As New BluetoothEndPoint(addr, Bluetooth.BluetoothService.Handsfree)

        Dim cli As New BluetoothClient()
        cli.Connect(rep)
        Dim peerStream As IO.Stream = cli.GetStream()

        Dim dialCmd1 As [String] = "AT+CMER" & vbCr
        Dim dialCmd2 As [String] = "AT+CIND=?" & vbCr
        Dim dialCmd3 As [String] = "AT+BRSF=" & vbCr
        Dim dialCmd4 As [String] = "ATD 0000000000;" & vbCr

        Dim dcB As [Byte]() = System.Text.Encoding.ASCII.GetBytes(dialCmd1)
        peerStream.Write(dcB, 0, dcB.Length)

        Dim sRes As [Byte]() = New [Byte](199) {}
        peerStream.Read(sRes, 0, 199)
        textBox1.Text = textBox1.Text + vbLf & vbCr & "----------" & vbLf & vbCr & System.Text.Encoding.ASCII.GetString(sRes)

        dcB = System.Text.Encoding.ASCII.GetBytes(dialCmd2)
        peerStream.Write(dcB, 0, dcB.Length)

        peerStream.Read(sRes, 0, 199)
        textBox1.Text = textBox1.Text + vbLf & vbCr & "----------" & vbLf & vbCr & System.Text.Encoding.ASCII.GetString(sRes)

        dcB = System.Text.Encoding.ASCII.GetBytes(dialCmd3)
        peerStream.Write(dcB, 0, dcB.Length)

        peerStream.Read(sRes, 0, 199)
        textBox1.Text = textBox1.Text + vbLf & vbCr & "----------" & vbLf & vbCr & System.Text.Encoding.ASCII.GetString(sRes)

        dcB = System.Text.Encoding.ASCII.GetBytes(dialCmd4)
        peerStream.Write(dcB, 0, dcB.Length)

        peerStream.Read(sRes, 0, 199)
        textBox1.Text = textBox1.Text + vbLf & vbCr & "----------" & vbLf & vbCr & System.Text.Encoding.ASCII.GetString(sRes)

        peerStream.Close()
        cli.Close()

Developer
May 9, 2012 at 11:48 AM

Just a short one for now.  I presume the code you've show fails at Connect?  If so change the Service Class Id to HandsfreeAudioGateway.  Id Handsfree is for the headset end.