This article applies to the BlackBerry® wireless devices based on Java™.
The BlackBerry application programming interface 4.0 has a new package (net.rim.device.api.Bluetooth) that contains classes used to communicate via Bluetooth® wireless technology using the Bluetooth Serial Port Profile. The classes are BluetoothSerialPort, BluetoothSerialPortListener, and BluetoothSerialPortInfo.
Note: Bluetooth communication can also be implemented through the use of the Connector class and input and output stream classes. A sample application of this implementation is included with the BlackBerry Java Development Environment 4.0 or higher.
Run the Bluetooth Sample Application
Please download the bluetoothsample.zip sample application that uses the classes to communicate via Bluetooth. Before you run the sample application, you must first pair another Bluetooth device that supports Bluetooth Serial Port Profile with your BlackBerry device. You can then use Hyperterminal, or any other terminal application to send and receive data to and from this sample.
On your device, select Options > Bluetooth.
Pair the device with a personal computer.
Build and sign the application.
Download the application on a device with Bluetooth wireless technology.
On your BlackBerry device, open the BluetoothSample.
Perform one of the following procedures:
If using a server-side connection
From the BluetoothSample menu, select Listen for connections.
Initiate a Bluetooth serial port profile connection from your personal computer to the device. The Bluetooth sample appears as Hi there.
On the device, accept the Bluetooth connection. Characters typed on the device should appear in Hyperterminal, and characters typed in Hyperterminal should appear on the device. You can also select various options in the menu to change the serial port state.
If using a client-side connection
From the Bluetooth Sample menu, select Connect to: xxxx, where xxxx is the name of the Bluetooth device on the personal computer.
On the personal computer, in the Bluetooth serial port profile, accept the connection request as required by the Bluetooth software installed on the personal computer.
Open Hyperterminal, and specify the COM port that the Bluetooth connection is using. Characters typed on the device should appear in Hyperterminal, and characters typed in Hyperterminal should appear on the device. You can also select various options in the menu to change the serial port state.