06-07-2012 09:40 AM
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.
12-20-2012 09:34 AM
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,