Today we will see how to make a simple Bluetooth hands-free. In this article I won’t into the audio part, I will focus on the display part of the device i.e. when we engage in a call on our mobile, we can show the caller’s number on an external display which is connected via Bluetooth to the mobile. If we the telephone number is associated with someone in our contacts list in our mobile phone, it also shows us the name of this person.

To do this we need to use a Bluegiga Bluetooth module that has iWrap v4 firmware which makes life a lot easier by running the application quickly and effectively.  Truthfully for what I am going to do we could use any of the WT12, WT11WT41 or WT32 modules. Even if you later want audio, it will work with any of these modules. I would choose the WT32 which is based on CSR‘s BlueCore5 as it is more suitable for multimedia applications (audio stereo).

So let’s assume that our “Bluetooth incoming call indicator” mainly relies on a single microphone (with 2 UARTs), a display and a Bluegiga WT12 Bluetooth module. Both the display and the WT12 have to be connected to the micro via a UART.

bluetooth-manos-libres

 

WT12 Configuration

The first thing to do is configure the WT12 Bluetooth module from our microphone. To do this we send the following commands to the Bluegiga module from the micro’s UART:

SET PROFILE HFP ON
SET PROFILE PBAP ON
RESET

With this we activate the Bluetooth HFP (Hands Free Profile) and the PBAP (Phone Book Access Profile– in order to control the contacts list) in the WT12 module. You only need to do this once, once it’s done it stays in the WT12’s non-volatile memory.

Bluetooth Association/ Connection 

Now we are going to connect the Bluetooth module with our mobile phone. Normally you would get your mobile phone and search for the WT12 module in the Bluetooth section and press “connect”. I’ve tried it and this works but I would like to do the reverse, I would like to select my mobile phone in my Bluetooth display and make a connection from the Bluetooth display to my mobile phone.

In order to do this, the following command is sent from the micro to the WT12 module:

INQUIRY 10 NAME
With this, the WT12 will search for nearby Bluetooth devices for 10 seconds and it will return a list of found devices to the MICRO, including the friendly name of each device if it has one. As soon as it is completed the micro will receive a response like this:
INQUIRY_PARTIAL 78:47:1d:ab:78:e1 5a020c
INQUIRY_PARTIAL 00:02:c7:f8:60:e3 1300404
INQUIRY_PARTIAL f4:0b:93:0b:5f:cc 7a020c
INQUIRY 3
INQUIRY 78:47:1d:ab:78:e1 5a020c
INQUIRY 00:02:c7:f8:60:e3 300404
INQUIRY f4:0b:93:0b:5f:cc 7a020c
NAME 78:47:1d:ab:78:e1 “josegg”

As for me, my mobile phone has  MAC 78:47:1d:ab:78:e1 and it has the name ”josegg” associated with it. At this point, the display that is connected to the micro would show us a list of names that it has found so that the user could select the one that corresponds with their mobile phone. As soon as it is selected, the micro can save it onto its flash memory. Now that our micro already has MAC Bluetooth from our mobile phone, it can connect to it. In fact whenever we turn on the display we can do this periodically so that our mobile will connect to it whenever we are near to the Bluetooth display.

You should send the following command to the WT12 Bluetooth module so that the micro can connect to the mobile via Bluetooth:

CALL 78:47:1d:ab:78:e1 111F HFP

This way the WT12 will connect to the mobile phone using the hands-free profile. I assumed that we would configure the same PIN number in the mobile phone and the WT12 module (with the command: SET BT AUTH *). If the connection is successful the micro will receive a response from the WT12 like this:

CALL 1

CONNECT 1 HFP 2
HFP 1 BSRF 103
HFP 1 STATUS “service” 1
HFP 1 STATUS “call” 0
HFP 1 STATUS “callsetup” 0
HFP 1 STATUS “callheld” 0
HFP 1 STATUS “signal” 4
HFP 1 STATUS “roam” 0
HFP 1 STATUS “battchg” 2
HFP 1 READY
HFP 1 NETWORK “YOIGO”
In this instance our “Bluetooth display” is already working with hands-free from our mobile phone. For example if we receive an incoming call, the WT12 will send the following data to the micro:

HFP 0 RING
HFP 0 CALLERID “681319891″ “” 81
HFP 0 RING
HFP 0 CALLERID “681319891″ “” 81

Obviously we need to program our micro so that when we receive a caller ID from the WT12 via the UART, it picks up the phone and shows it on the display, simple as that. At this point we have a Bluetooth call indicator implemented.

Very good, but you said that the display would show the caller’s name if it was in the contacts list. Will it be displayed after doing what we have done? 

No, if you want to show data from the mobile’s contact list you have to establish another Bluetooth connection, using the PBAP profile. This will allow you to obtain data from the mobile’s contact list. To do this, similar to what we did with the HFP profile, we need to send the following command from the micro to the WT12 Bluetooth module:

CALL 78:47:1d:ab:78:e1 112F PBAP
Once the PBAP connection is established, we can get data from the contacts list by using the PBAP command. For example to get all of your contacts from the list (name, telephone etc.), we would send this command:
PBAP 00 FFFF 1

I recommend reading about the PBAP command in iWrap’s manual because there are a lot of combinations. In the previous case, it didn’t send a series of XML with the data from the contacts list. Using this data, when there is an incoming call and we have the telephone number, we can search for the name associated with this number and display it. As you can see it’s a very simple application to run with Bluegiga modules that have iWrap.

 Applications?

The applications are obvious. After adding audio (managing a few more iWrap commands that we can look at another day) we will have a complete Bluetooth hands-free that we can use with any application. As for me for example, from time to time I go out with the dune buggy and I can’t hear anything over the engine. My girl tells me off all the time for not answering my mobile (because I can’t physically hear it). With an indicator like this in the dashboard I would be able to see incoming calls. Also when I’m riding the buggy you can locate me easily… Hmm, although thinking about it a bit more… maybe not! :)

I’ll be back with more another day!

 

 



Post relacionados:

  1. How to make a Bluetooth hands-free GSM device with PCM audio In order to make the most of the fact that...
  2. Bluetooth-GPRS Gateway I have wanted to write a post about this for...
  3. (Español) Nuevo módulo bluetooth WT41 de Bluegiga. Sorry, this entry is only available in Español. FacebookTwitter...
  4. Bluetooth Low Energy For those who are looking for new development ideas to...
  5. (Español) Utilizando el AS como concentrador bluetooth. Sorry, this entry is only available in Español. FacebookTwitter...








Tags:
2 Responses to “How to make a Bluetooth Hands-free with caller ID”
  1. Jose Luis says:

    muy buen artículo como siempre. una pregunta, indicas que la agenda puede descargarse mediante pbap y luego asi buscar el numero de telefono que llama para averiguar si está el nombre de quien llama. Si el micro es pequeño en memoria y la agenda es muy grande es complicado descargarla.

    ¿no hay una función en los bluegiga que permita enviar como parametro el número de telefono y que devuelva el nombre si existe????

    muchas gracias.

  2. blogElectronica says:

    Hola Jose Luis,

    me alegra que te guste el post. Respecto a lo que dices, no, no es posible hacer lo que indicas mediante protocolo PBAP (no tienes un motor de BBDD en el lado del teléfono que te ejecute consultas tipo SQL sobre la agenda).

    Si tienes problemas de memoria, lo que puedes hacer es ir descargando por partes la agenda, no tienes por qué descargarla toda de golpe. U otra forma, quizás la más rápida y eficiente en cuanto a memoria, es descargarla toda e ir procesando los datos en tiempo real según entran por la uart del micro.

    Salu2!!!

  3.  
Leave a Reply

Puedes publicar un comentario aquí si quieres, pero te recomiendo que uses el nuevo foroElectronica.com para introducir comentarios. Te contestaré más rápido. Recuerda que debes registrarte si no lo estás para publicar un comentario.