Master/slave roles

For every Bluetooth link between two devices, one device is defined as the master of the connection and the other as the slave. These terms are defined by the Bluetooth specifications.

Frequency hopping is used on Bluetooth links for reasons such as security, avoiding interference, etc. The Bluetooth specification defines that the master’s clock and Bluetooth device (BD) address are used to calculate the frequency hopping sequence, and that slaves for Asynchronous Connectionless (ACL) links are allowed to start sending in odd slots of the clock when they have been addressed by the master in a previous slot. Thus, the master BD address and clock define the hopping sequence, and the master’s transmission defines which slave is allowed to send in which time slot.

Some devices may support a feature referred to as “master/slave switching.” For example, a device that is currently a slave may request to become the master. However not all devices support this feature. (See the local device property “bluetooth.master.switch” defined in JSR-82.)

If you are using a Bluetooth connection between just two devices, it doesn’t matter which is the Bluetooth master or slave. However if you wish to connect more than two devices together in the same session (for example, a multiplayer game with more than two players), then it is likely that you will have to consider how the Bluetooth master/slave roles impact connection setup between networked peers.

Bluetooth Clients and Servers

It is important to remember that the master defines the access and timing of a Bluetooth piconet. This is especially important when more than two Bluetooth devices are going to be interconnected.

In many traditional client/server architectures, the server starts running first and waits indefinitely to accept new client connection requests from remote clients.

In a Bluetooth piconet, the master adds each slave into the piconet. A common result of this is that client applications will be slaves and the server application will be the master. From the user’s point of view, the server (master) "initiates" connections to the clients (slaves). This is important to keep in mind.

For a good overview of some general steps that are useful in creating a connection between client/server applications in Bluetooth, see Games Over Bluetooth: Recommendations To Game Developers.