10-14-2011 09:30 AM - edited 10-14-2011 10:30 AM
Hi,
i use Blackberry bold 9000, os 5, and i have problems making BluetoothDemo sample work, in particular i have problems making two paired devices communicate.
I changed the constructor of the AppScreen class, because it was not able to find any device which port has "Hi there" as service name, then i have:
public final class AppScreen extends MainScreen
{
private BluetoothSerialPortInfo[] _portInfo;
/**
* Default constructor
*/
public AppScreen()
{
setTitle("Bluetooth Sample");
// Determine if this BlackBerry model or simulator supports Bluetooth
if (BluetoothSerialPort.isSupported())
{
// Get the BluetoothSerialPortInfo. Retrieves serial port information for
// the currently paired devices.
_portInfo = BluetoothSerialPort.getSerialPortInfo();
int numServices = _portInfo.length;
// Create a MenuItem for each Bluetooth device we can connect to.
for (int count = numServices - 1; count >= 0; --count)
{
//String serviceName = _portInfo[count].getServiceName();
// A single device can provide multiple serial port connections (or services).
// Add a menu item only to the service that corresponds to the "Hi there" connection,
// or the "COM X" connection (if we are pairing with a PC).
// if (serviceName.equals("Hi there") || serviceName.equals("COM X"))
{
DeviceMenuItem deviceMenuItem = new DeviceMenuItem("Connect to: " + _portInfo[count].getDeviceName(), _portInfo[count]);
addMenuItem(deviceMenuItem);
}
}
addMenuItem(_listenItem);
}
else
{
add(new LabelField("Bluetooth is not supported on this device."));
}
}
now it's able to find two services, Desktop service and Bypass service, on both devices.
Then on device 'A' i select "listen for connections", on device 'B' i select "connect to device A" (there are two menu items, one for Desktop service and the other for Bypass service, i guess).
When I accept the connection request from one of the two services, I have either "connecting to the computer..." or the screen still says "connect external device and then type something..." on device A.
If I try to write something on device B(client), it doesn't appear on device A(server) but it doesn't launch any exception, while if I try to write something on the server, i have "Failed to write data:java.io.IOException: BtSppWrite failed".
I don't know where is the problem, especially because it worked twice, and then i have never been able to make it works more.
Solved! Go to Solution.
10-16-2011 01:51 PM