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
New Developer
pacred
Posts: 6
Registered: ‎08-04-2008

Reading from Bluetooth weirdness -->"unknown(net_rim_cldc,80)"

When I read an input string from a Holux GPS puck the return value gets weird. BB JDE v4.3.0.1r

 

When I cast the byte to a char and convert to a String using String.valueOf() the end result is always: "unknown(net_rim_cldc,80)"

 

//Invoked when data has been received.
public void dataReceived(int length){

 

byte buf[] = new byte[256];

StringBuffer stringBuffer = new StringBuffer();

int len =0;

if((len = btPort.read(buf, 0, length == -1 ? buf.length : length)) != 0){ stringBuffer.setLength(0); for(int i=0; i<len; i++){ char ch = (char)buf[i]; String st = String.valueOf(ch); //here is where the value of st equals "unknown(net_rim_cldc,80)" if(st!=null && !st.equals("")) stringBuffer.append(st); }

 

String currentInfo = stringBuffer.toString();

//the value of currentInfo equals "unknown(net_rim_cldc,80)" }

 

}

The value of the byte array (buf) after the read =

"$GPGGA,143754.000,2501.6\u0000\u0000\u0000\u0000\u0000\u0000\u0000\u0000\u0000\u0000\u0000\u0000\u0000\u0000\u0000\u0000\u0000\u0000\u0000\u0000\u0000\u0000\u0000\u0000\u0000\u0000\u0000\u0000\u0000\u0000\u0000\u0000\u0000\u0000\u0000\u0000\u0000\u0000\u0000\u0000\u0000\u0000\u0000\u0000\u0000\u0000\u0000\u0000\u0000\u0000\u0000\u0000\u0000\u0000\u0000\u0000\u0000\u0000\u0000\u0000\u0000\u0000\u0000\u0000\u0000\u0000\u0000\u0000\u0000\u0000\u0000\u0000\u0000\u0000\u0000\u0000"

 

Has anyone seen this before?

 

I open the port like this:

btPort = new BluetoothSerialPort(btInfo, BluetoothSerialPort.BAUD_115200, BluetoothSerialPort.DATA_FORMAT_PARITY_NONE | BluetoothSerialPort.DATA_FORMAT_STOP_BITS_1 | BluetoothSerialPort.DATA_FORMAT_DATA_BITS_8, BluetoothSerialPort.FLOW_CONTROL_NONE, 256, 256, this);
       

 

 

Please use plain text.