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

BlackBerry® OS Smartphones

Reply
b_b
New Contributor
Posts: 2
Registered: ‎02-24-2009
My Device: Not Specified

Concurrent Bluetooth serial port profile connections

I would like to know if it is possible to connect to with multiple Bluetooth Serial Port Profile devices at the same time.  For example, could the Storm be connected to a bar code reader at the same time as it is connected to a printer?  What is the maximum number of simultaneous serial port connections that can be established?
New Member
Posts: 1
Registered: ‎05-25-2009
My Device: Not Specified

Re: Concurrent Bluetooth serial port profile connections

[ Edited ]

Hi,

 

I ask the same question.

I use the BlackBerry Storm (9500).

Here is my code sample (from a MIDlet) to test BTSPP (compiled with JDE 4.7 and signed)

 

private BluetoothSerialPort createBTSPP(String service) {
        BluetoothSerialPort m_port = null;
       
        if (BluetoothSerialPort.isSupported())
        {
                try
                {
                        // Open a port to listen for incoming connections.
                        m_port = new BluetoothSerialPort(
                                        service,
                                        BluetoothSerialPort.BAUD_115200,
                                        BluetoothSerialPort.DATA_FORMAT_PARITY_NONE
                                                        | BluetoothSerialPort.DATA_FORMAT_STOP_BITS_1
                                                        | BluetoothSerialPort.DATA_FORMAT_DATA_BITS_8,
                                        BluetoothSerialPort.FLOW_CONTROL_NONE,
                                        BUFFER_SIZE,
                                        BUFFER_SIZE,
                                        this);
                        form.append( new StringItem("BTCom service " + service + " started",
                                        null));
                }
                catch (IOException ex)
                {
                    form.append( new StringItem("IOException: " + service + " NOT started",
                                        null));
                    m_port = null;
                }
        }
        else
        {
                form.append( new StringItem("Bluetooth is not supported on this BlackBerry or simulator.",
                    null));
        }
        //end
        return m_port;
    }

 

 ...

 

/**
     * <p>Signals the MIDlet that it has entered the Active state.
     */
    public void startApp()
    {
        BluetoothSerialPort spp1 = createBTSPP("spp1");
        BluetoothSerialPort spp2 = createBTSPP("spp2");
    }

 

 I get a IOException when creating spp2.

the getMessage() of this IOexception is Smiley FrustratedppOpen failed: 1

could someone answer me ?

Thanks a lot.

 

NOTE : I compiled the same midlet with JDE4.2 (and is also signed)

I also installed it on a Blackberry 8100 and this code works fine.

I suspect something changed from OS 4.2/4.5 to 4.7.

Message Edited by JoeCoco on 05-25-2009 11:49 AM
Message Edited by JoeCoco on 05-25-2009 03:50 PM
New Developer
Posts: 13
Registered: ‎06-17-2009
My Device: Not Specified

Re: Concurrent Bluetooth serial port profile connections

Basically I have the same question as the previous two people mentioned.

 

To state that question more clearly: Is it possible for a Blackberry device to function as a Bluetooth Master in a Bluetooth PAN/piconet? In other words, can it open multiple serial ports to accept/send data from/to multiple Bluetooth devices simultaneously (of course it is not simultaneous, there is time interleaving in the receiving/transmission processes effectively lowering the bandwidth for every link).

 

I am interested in having a BB device get continuous data from two Bluetooth-enabled sensors which continuously stream data via SPP/RFCOMM. Could a BB device support such a scenario? I tried to test that scenario with the Blackberry Simulator but the simulator does not support Bluetooth. I don't currently have a BB device to test that on, but I do not want to purchase one and then find out that what I wanna do is not implementable.

 

I have not been able to find any relevant answer to this question and I am guessing there are a few developers who would be very pleased if they could have an answer on this. As a result I would greatly appreciate any help/clarification from any of the senior developers or from the forum's administrators that could shed any light on this...;-)

 

Alex

New Developer
Posts: 13
Registered: ‎06-17-2009
My Device: Not Specified

Re: Concurrent Bluetooth serial port profile connections

[ Edited ]

Since noone appears to know what the answer to the above issue is, could someone who actually owns a BB device try getting the following property which returns "The maximum number of connected devices supported":

LocalDevice.getProperty("bluetooth.connected.devices.max");

 

you would just need to: import javax.bluetooth.LocalDevice;

 

In case this returns something greater than 0 or 1, then I can safely assume that multiple (up to 7 normally) simultaneous Bluetooth connections can be supported, whereby the available bandwidth would be divided among the connected clients to the BB phone, enabling them all to function & communicate concurrently.

I would be much obliged to anyone that could try this for me... (the above statement always results in a NullPointerException in the Simulator)

Message Edited by Alekos83 on 06-18-2009 05:35 PM
Message Edited by Alekos83 on 06-19-2009 11:06 AM
New Developer
Posts: 13
Registered: ‎06-17-2009
My Device: Not Specified

Re: Concurrent Bluetooth serial port profile connections

[ Edited ]

In the Bluetooth Demo found at http://na.blackberry.com/eng/developers/resources/developer_labs.jsp#tab_tab_jde at the bottom of the screen, there is a class named AppScreen.

Within that class, in the loop for every Bluetooth device that the BB can connect to there is a comment that says:

 

// A single device can provide multiple serial port connections (or services).

 

I am guessing this comment does indeed imply that a single BB device is capable of connecting to multiple BT devices simultanesously, e.g. it can open several virtual COM ports (up to 7 as the BT-standard states?) to communicate with more than one BT-enabled peripheral and thus set-up a PAN-piconet.

 

If only someone had tested this and could let us know...

Message Edited by Alekos83 on 06-25-2009 12:18 PM
New Developer
Posts: 4
Registered: ‎07-06-2009
My Device: Not Specified

Re: Concurrent Bluetooth serial port profile connections

Did this and I got result as "5" on my BB Curve 8310
New Developer
Posts: 13
Registered: ‎06-17-2009
My Device: Not Specified

Re: Concurrent Bluetooth serial port profile connections

calvin464 I seriously appreciate that very much. Your result is very encouraging for what I wanna do and it most probably verifies that your BB Curve can indeed communicate concurrently with multiple Bluetooth peripherals (5 devices is more than enough).

Thanks a lot!

New Developer
Posts: 13
Registered: ‎06-17-2009
My Device: Not Specified

Re: Concurrent Bluetooth serial port profile connections

Just tried this on a BlackBerry Bold 9000 and I got the same result, e.g. "5", for the "bluetooth.connected.devices.max" property.

 

The only thing left now is to prove the assumption that it can communicate with up to 5 bluetooth peripherals simultaneously. I will post again as soon as I try to implement something like this and succeed or fail in doing so... hopefully and most probably succeed of course ;-)

Highlighted
New Developer
Posts: 13
Registered: ‎06-17-2009
My Device: Not Specified

Re: Concurrent Bluetooth serial port profile connections

I have indeed confirmed that with a BlackBerry Bold I can talk simultaneously to two Bluetooth peripherals, each one of which sending data concurrently to my BB device.

The only thing that is needed to achieve that is to start a separate thread to "monitor" every serial connection/port.

 

I am guessing that should also be possible with up to 5 Bluetooth peripherals, as the BB's "bluetooth.connected.devices.max" property suggests.