Bluetooth Follow-Me

Manmohan Voniyadka
Columbia University
New York
mv2147@cs.columbia.edu

Abstract

The goal of this project is to use SIP or the Session Initiation protocol to automatically forward calls to Bluetooth users based on their presence information. This project succeeded in the creation of a Bluetooth-SIP user agent which is capable of registering and publishing the availability of users who allow themselves to be discovered by the Bluetooth protocol when they are in the vicinity of a PC Basestation. The agent polls for Bluetooth devices using the HCI Inquire function of the Bluetooth protocol, generates SIP requests for mapping the device identifiers to the users' SIP AOR and generates SIP messages for registration and conveying user presence for each associated user discovered.

Introduction

The main component of the application is a Bluetooth-SIP agent which maintains a list of devices that are discoverable by the agent. When a user with a headset needs to register himself with basestation running the agent as his contact, he enters into pairing mode with the basestation. The Bluetooth-SIP agent discovers that the list of discoverable devices has changed and issues a SIP request to retreive the mapping of the undiscovered device. When this request is answered by a mapping server with the user's SIP AOR, the user agent registers the user with SIPD and publishes the user's availability to a presence server. When the user leaves the pairing mode, the change in status is published to the presence server.

Background

The Bluetooth/SIP agent makes use of the Bluez implementation of the Bluetooth stack on Linux. The HCI (Host controller interface) layer of Bluetooth provides a interface to communicate, access and control the hardware layer. L2CAP provides connection-oriented and connectionless services to upper layers. The BNEP layer lies on top of the L2CAP layer and provides support for IP.

The basic data structure used to specify a Bluetooth device address is the bdaddr_t. All Bluetooth addresses in BlueZ are stored and manipulated as bdaddr_t structures. Local Bluetooth adapters are assigned identifying numbers starting with 0, and a program must specify which adapter to use when allocating system resources. hci_get_route will retrieve the resource number of the first available Bluetooth adapter. After choosing the local Bluetooth adapter to use and allocating system resources, the program can scan for nearby Bluetooth devices. hci_inquiry performs a Bluetooth device discovery and returns a list of detected devices and some basic information about them in a inquiry_info structure. The timeperiod of the inquiry and the maximum number of responders can be varied.

Architecture

A key component of the user agent is a BTManageAgent (BTM) object which handles bluetooth related functions. On startup of the useragent the handle_bluetooth function is called which creates the BTM object. The BTM object maintains a list of device identifiers which it updates after every polling period as it discovers new devices.

                                                              
           Base-station                    Presence Server    | SIPD |
              -------          Mapping server  |______|       |______|
     >>>>>>>> |     |     MAP        | |       |______|          ^
     >>>>>>>> |     |----------------> |           ^             | 
     >>>>>>>> |  |  |<---------------|_|           |             |
   DISCOVER   |--|--|------------------------REGISTER-------------
                     |                             |
                     |______PUBLISH________________|

On the discovery of a new device a devices added handler which sends a PUBLISH request to the mapping server. The From and To fields in the header of this message contain the device address in sip format. (e.g. sip:00-0A-3A-06-CA-78@cs.columbia.edu). The mapping server then responds with the AOR mapped to the bluetooth address received and sends a SIP 302 response with the AOR contained in the Contact Header. On successful mapping the Bluetooth-SIP agent calls the mapping successful handler, which sends a PUBLISH message to the presence server to update the presence status of the person with the basestation as his contact, and a pidf content showing him to be in pairing mode. The agent also generates a REGISTER message to SIPD with the basestation as his contact in the Contact header.

Modules

Client (SIPUA)

1. bluetooth.cpp - Maintains list of discovered devices. Tracks devices entering or leaving pairing mode. Sets HCI Inquiry parameters.

2. main.cpp - Starts the bluetooth handler. Queries the mapping server for new devices. Maintains hash of mapped devices. Contains the mapping response handler and mapping succesul handler and publish and register request handling functions.

Program Documentation

Hardware Requirements

Software Requirements

Installation

Running the Application

Download Source

Future Enhancements

Acknowledgements

I would like to thank Kundan Singh for taking the time to help me out on debugging my many SIPUA problems.

I would like to thank Vishal Singh for helping me understand SIP presence message flow.

References

  1. Bluez site
  2. Bluez programming in C
  3. Bluetooth ALSA