Bluetooth SAP Client into oFono and BlueZ

During the last weeks I’ve worked in adding Bluetooth Sim Access Profile (SAP)   Client Side support to oFono and BlueZ. This work was done by me at ProFUSION and  sponsored by Linux Foundation.

The Bluetooth Sim Access Profile enables a device to use a remote SIM card as its own SIM card. Between the benefits are ability to user others features than phone calls, like data connections, SMS, etc.  This is an advantage over the Handsfree Profile, that only supports phone calls. It also uses less power due to audio part, that is not streamed over the Bluetooth link like in the Handsfree Profile but instead is handled locally.

In the development I used the Telit UC864-G module. This module has built-in SAP Client support and other features that a common modem has to have.

The Telit modem has no Bluetooth support, then the main work was to modify oFono in order to connect a Bluetooth RFCOMM socket coming from BlueZ to a Serial port coming from Telit module. This Serial port give/receive SAP protocol messages.  So anything we got from it can be passed without changes to the RFCOMM socket and vice-versa.

The work was divided in two parts, in BlueZ fd-passing support was added to the Serial API through a method called Serial.ConnectFD(). This was an already planned change by BlueZ developers for the upcoming BlueZ 5.0 release. This a generic method to get a RFCOMM socket, it can be used for any purpose or by any profile.

On the oFono side, the Bluetooth infrastructure plugin was used to create a new SAP plugin that is aware of any remote device with Bluetooth SAP Server support that we paired, it also tracks if any SAP Client enabled modem is available. If the two conditions holds true a new oFono modem instance is created to connect the paired device with the SAP enabled hardware. Of course, this modem works like any other oFono modem and one can do the usual phone operations with it.

The implementation inside oFono is modular enough to easily support any other SAP enabled modem that comes to the market in the future.

It’s important to note that all the work related to the SAP Client implementation is already upstream in both BlueZ and oFono repositories.

Finally, I would like to thank Denis Kenzior, oFono maintainer, by the help on reviewing and improving the SAP code.

A little report of MeeGo Conference

In the end of the last month I attended MeeGo Conference in San Francisco, CA. The conference venue was very nice, and they managed to create a quite nice hacker lounge, with comfortable couches and free beer! :-)

There I attended some talks, as long as the opening keynote. The keynote was not that good, much more focused in the Linux success on mobile than MeeGo itself. But the talks were all about MeeGo, of course.

And like any other conference it was a nice time to assign faces to nick and meet people who you talk everyday in the internet.

Brazilians at MeeGo Conference - by gustavoboiko

Brazilians at MeeGo Conference - by Gustavo Boiko

As it was my first time in San Francisco, I also managed to do some sightseeing, so I visited the Golden Gate Bridge among other places

See you around!

Google Summer of Code has come. Again!

For the second year I got accepted on the Google Summer of Code project to work with the BlueZ organization. My project this year is to work on the DUN Client. DUN is the Dial-up Network Profile, it provides access to the Internet and other dial-up services via Bluetooth.  My project intends to do the DUN client only, but if I have time at the end of the project I’ll work on the DUN Server too.

The implementation will make changes in BlueZ, ConnMan and oFono. Most of the changes will be inside oFono. There, we need to use the AT command parser and the  PPP stack (recently added to the oFono repo). The work consist on integrate everything and implement the missing parts of the AT command parser and the PPP stack, and the DUN agent.

On the BlueZ part the work will be the service export for DUN Data Terminal role and and the DUN Agent server to register agents and pass the RFCOMM file descriptor. For testing purposes we can use the Serial API in the beginning. That work is very similar to what we did for the HFP this year.

The ConnMan integration: ConnMan will setup the NAT and the  Internet connection. The DUN integration on ConnMan is similar to the PAN integration(still a work in progress) , so we can reuse part of that implementation.

That’s it.  I’ll post updates here during the development of the project. Now let me code. ;-)

Also, congratulation to the others Unicamp (University of Campinas) students that were accepted on GSoC too. :-)

Handsfree Profile into BlueZ and oFono

I’m proud to announce that BlueZ and oFono now support the Handsfree role of the Bluetooth Handsfree profile. This means that your Desktop now can now act like a headset bluetooth and handle calls from your cell phone.  The work was done during the last 2 months here at ProFUSION.

On the BlueZ side a new API was designed using the fd-passing feature of DBus 1.3.  This new API uses the concept of Agents where oFono plays the Agent role.  In the HFP case the Agent role is to handle the AT engine stuff while BlueZ will only take care of the RFCOMM and SCO connections.

The RFCOMM socket is passed to the Agent in oFono via DBus, then oFono uses it to send and receive the AT commands to establish a Service Level Connection, i. e., make the handshake procedure. If it succeeds oFono will be ready to make and answers calls. Your HFP enabled phone will show up as a  modem in oFono, like any other oFono modem.

The work was initially based on patches from Zhenhua Zhang(from Intel) and the audio interaction to handle the SCO data inside Pulseaudio was done by João Paulo Rechi Vita(from ProFUSION too). He also did the demo video below.

After pairing the devices using some BlueZ agent like kbluetooth or gnome-bluetooth, you’ll be able to see the modem in oFono and you can enable it ( i. e., make the handshake procedure to establish an HFP Service Level Connection) using the enable-modem script from the test directory on oFono source.

In order to test this you need the Audio Gateway interface enabled in BlueZ. For that, edit your /etc/bluetooth/audio.conf  and add “Enable=Gateway” to it.

HFP code is already merged upstream on the BlueZ and oFono trees. The API is described in doc/hfp-api.txt in BlueZ source.