Welcome!

Welcome to the official BlackBerry Support Community Forums.

This is your resource to discuss support topics with your peers, and learn from each other.

inside custom component

Java Development

Reply
Developer
Posts: 21
Registered: ‎07-31-2011
My Device: developer
My Carrier: student
Accepted Solution

BluetoothDemo sample - BtSppWrite failed

[ Edited ]

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.

Highlighted
Developer
Posts: 21
Registered: ‎07-31-2011
My Device: developer
My Carrier: student

Re: BluetoothDemo sample - BtSppWrite failed