Home > Articles > Networking > Wireless/High Speed/Optical

  • Print
  • + Share This
This chapter is from the book

1.7 Using Bluetooth

Bluetooth is unlike any wired network, as there is no need to physically attach a cable to the devices you are communicating with; indeed, you may not know exactly what devices you are talking to and what their capabilities are. To cope with this, Bluetooth provides inquiry and paging mechanisms and a Service Discovery Protocol (SDP).

This section examines how these mechanisms are used to allow Bluetooth devices to link up and use one another's services.

1.7.1 Discovering Bluetooth Devices

Imagine two Bluetooth enabled devices, say, a cell phone and a laptop computer. The cell phone is capable of acting as a modem using the dial up networking profile, and it periodically scans to see if anyone wants to use it.

The user of the laptop opens up an application that needs a Bluetooth dial up networking connection. To use this application, the laptop knows it needs to establish a Bluetooth link to a device supporting the dial up networking profile. The first stage in establishing such a connection is finding out what Bluetooth enabled devices are in the area, so the laptop performs an inquiry to look for devices in the neighbourhood.

To do this the laptop transmits a series of inquiry packets, and eventually the cell phone replies with a Frequency Hop Synchronisation (FHS) packet. The FHS packet contains all the information that the laptop needs to create a connection to the cell phone. It also contains the device class of the cell phone, which consists of major and minor parts. The major device class tells the laptop that it has found a phone; the minor part says that the type of phone is a cellular phone. This exchange of messages is illustrated in Figure 1–7.

Figure 1-7Figure 1–7 Discovering a Bluetooth device.

In the same way, every Bluetooth-enabled device in the area that is scanning for inquiries will respond with an FHS packet, so the laptop accumulates a list of devices.

What happens next is up to the designer of the application. The laptop could present the user with a list of all the devices it has found and let the user choose what to do next; but if it did that at this stage, all it could do is tell the user about the types of devices it has found. Instead of telling the user about the devices it has found, the application could automatically go on to the next stage and find out which devices in the area support the dial up networking profile.

1.7.2 Connecting to a Service Discovery Database

To find out whether a device supports a particular service, the application needs to connect to the device and use the service discovery protocol (SDP). Figure 1–8 illustrates how this is done. First the laptop pages the cellular phone, using the information it gathered during inquiry. If the phone is scanning for pages, it responds, and an ACL baseband connection can be set up to transfer data between the two devices.

Figure 1-8Figure 1–8 Retrieving information on services.

Once an ACL connection has been established, a Logical Link Control and Adaptation Protocol (L2CAP) connection can be set up across it. An L2CAP connection is used whenever data has to be transferred between Bluetooth devices. L2CAP allows many protocols and services to use one baseband ACL link. L2CAP distinguishes between different protocols and services using an ACL connection by adding a Protocol and Service Multiplexor (PSM) to every L2CAP packet. The PSM is different for every protocol or service that uses the link. Since this connection will be used for service discovery, its PSM = 0x0001, a special value that is always used for service discovery.

The laptop uses the L2CAP channel to set up a connection to the service discovery server on the cellular phone. The laptop's service discovery client can then ask the cellular phone's service discovery server to send it all the information it has relating to the dial up networking profile. The service discovery server on the cellular phone searches through its database and returns the attributes (characteristics) relating to dial up networking.

Once the service discovery information has been retrieved, the laptop may decide to shut down the connection to the cellular phone. If the laptop wants to collect service discovery information from many devices in the area, then it makes sense to shut down the links after using them, since one device can only use a limited number of links at a time, and keeping the links alive will consume battery power unnecessarily.

After the laptop has collected service discovery information from devices in the area, what happens next is again up to the application. It could display the information on all devices it has found which support the dial up networking profile and let the user decide which one to connect to. Alternatively, the application could decide for itself which device to use without bothering the user.

Either way, the service discovery information tells the laptop everything it needs to know to connect to the dial up networking service on the cellular phone.

1.7.3 Connecting to a Bluetooth Service

The process of actually making a connection is shown in Figure 1–9. The paging process which establishes a baseband ACL link is the same as was used when connecting for service discovery.

Figure 1-9Figure 1–9 Connecting to a Dial Up Networking service.

This time the link is being set up for a protocol which may have particular quality of service requirements, so the application running on the laptop may wish to configure the link to meet its requirements. This is done by the application sending its requirements to the Bluetooth module using the Host Controller Interface. Next, the module's link manager configures the link using the link management protocol.

Once the ACL connection is set up to the laptop's satisfaction, an L2CAP connection is set up. The dial up networking profile uses RFCOMM, an RS-232 emulation layer, so the L2CAP connection uses the Protocol Stack Multiplexor for RFCOMM (PSM = 0x0003).

After the L2CAP link has been set up, an RFCOMM connection can be set up across it. RFCOMM, like L2CAP, can multiplex several protocols or services across one connection. Each protocol or service is given its own channel number. The cellular phone's channel number for Dial Up Networking was sent to the laptop in the service discovery information, so the laptop knows which channel number it should use when setting up the RFCOMM connection.

Finally, the Dial Up Networking (DUN) connection is set up using the RFCOMM connection, and the laptop can start to use the dial up networking services of the cellular phone.

Now, the laptop can use the cellular phone to make connections across the phone network without the two needing to be joined together by a data cable.

If the cellular phone is picked up and taken out of the range of the laptop, the laptop will have to repeat the procedure and find another device to connect to. Meanwhile, the cellular phone is still scanning and might be connected to another device elsewhere. The process of connecting is ad hoc and arbitrary with Bluetooth connections, possibly only lasting for a short period of time as devices move around.

1.7.4 Discoverability and Connectability Modes

It is important to realise that for a connection to be established using Bluetooth wireless technology, both ends of the link have to be willing to connect.

Some devices may be set so that they will not scan for inquiries; in this case, other devices cannot discover them, and they will effectively be invisible. Similarly, some devices may be set so that they do not perform page scans. In these cases, they can still initiate connections, but they will not hear other devices trying to connect to them.

Applications can choose whether to make devices connectable or discoverable. A connection cannot be forced on a device which is not in the correct mode to accept it.

  • + Share This
  • 🔖 Save To Your Account