Java Reference
In-Depth Information
over Bluetooth'. The main changes we have introduced are the use of an
observer class and simplification of the code to support only two players.
If you wish to learn about Bluetooth technologies in detail, these articles
are required reading as we cannot cover everything here.
Selecting the Multi option from the main game menu (see Figure 8.6)
displays the multiplayer menu shown in Figure 8.10. In this game, if you
choose Player1 you are the 'Master' (or game server, if you like). If you
choose Player2, you are the 'Slave'.
Figure 8.10 Selecting the role
Before connections can be established between Bluetooth devices, the
Bluetooth stack must be initialized, devices must be found (known as the
inquiry phase) and then the available services on each device must be
queried (known as the discovery phase).
In the inquiry phase, the master device detects other devices in
the area in order to determine their types and Bluetooth addresses.
The type of device is referred to as the class of device (CoD). The
CoD is simply a number that indicates whether the remote device is
a computer, an audio headset, or a mobile phone. In JSR-82, this is
represented by the DeviceClass class. You retrieve the CoD by calling
the getMajorDeviceClass() method, which returns an integer. These
integers are well-known, centrally assigned fixed numbers - for example,
mobile phones have the value 0x0200.
There are two modes commonly used to find other devices - the
General Inquiry Access Code (GIAC) and the Limited Inquiry Access
Code (LIAC). The Symbian OS Bluetooth stack does not support the use
of the LIAC so we won't discuss it any further here.
Search WWH ::




Custom Search