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
Contributor
shashi_29
Posts: 21
Registered: ‎10-18-2011
My Device: Blackberry Bold 9900
My Carrier: T Mobile

"How to check BluetoothSerialPort is open or not !!!!!!"

hi,

 

 

I am developing a bluetooth application in that i have to check BluetoothSerialPort,

Wether it is open or not for reconnection to device ie (I have to avoid re searching of devices)

I am using below line of code to open a BluetoothSerialPort for making connection with device.

 

"_port = new BluetoothSerialPort(info, BluetoothSerialPort.BAUD_19200, BluetoothSerialPort.DATA_FORMAT_PARITY_NONE | BluetoothSerialPort.DATA_FORMAT_STOP_BITS_1 | BluetoothSerialPort.DATA_FORMAT_DATA_BITS_8, BluetoothSerialPort.FLOW_CONTROL_NONE, 1024, 1024, this);"

 

Plz help !! 

 

thanx.

 

 

 

Please use plain text.
Super Contributor
lyon819
Posts: 253
Registered: ‎08-19-2010
My Device: BB10, Playbook, 9900, 9800, 9700, 9550, 9530, 9500, 8700.
My Carrier: TT

Re: "How to check BluetoothSerialPort is open or not !!!!!!"

BluetoothDemo is my solution.

I import BB example/BluetoothDemo.

And then, change Hi There to the device name. 

 

Only change APP Screen. 

 

int numServices = _portInfo.length;

// Create a MenuItem for each Bluetooth device we can connect to.
if (numServices>0)
_rtf = new RichTextField(String.valueOf(numServices)+" device, Name: "+_portInfo[0].getDeviceName(), RichTextField.NON_FOCUSABLE);
else
_rtf = new RichTextField("No devices in pairing list", RichTextField.NON_FOCUSABLE);
add(_rtf);
//Create a MenuItem for each Bluetooth device we can connect to.
DeviceMenuItem deviceItems[] = new DeviceMenuItem[numServices];
for (int count = 0; count < numServices; count++) {
deviceItems[count] = new DeviceMenuItem("Connect to: " + _portInfo[count].getDeviceName(), _portInfo[count]);
addMenuItem(deviceItems[count]);
}

 

You can also download my sample code, which bases on bluetoothDemo, from sourceforge.

https://sourceforge.net/projects/blackberry71blu/

 

I can begin to develop coding with the BT sensor.

 

Cheers,

-Fight with BB10
Please use plain text.