Hi all, I need your help, please.
I am trying to read some data from a bluetooth chip, but i can't get a good reading. I have reviewed my code a lot and I can not find the mistake. I Post my code, any ideas?
Code:
// ////////////////////////////////////////////////////////////////////////
// Implementacion de BluetoothSerialPortListener
// ////////////////////////////////////////////////////////////////////////
public void dataReceived(int length) {
char[] buffer = new char[8];
int idx = 0;
try {
char c = (char) puertoBT.read();
while (c != '#') {
buffer[idx] = c;
idx++;
c = (char) puertoBT.read();
}
Dialog.inform(new String(buffer, 0, idx));
ADCs[0].setText(new String(buffer, 0, idx));
} catch (IOException e) {
e.printStackTrace();
}
} As you can see, I use a "#" like a stop caracter. I fact, the last char that the bluetooth chip send is "#". For example, if this send 1.23#, i read in the blackberry app: "23" or ".23" and somethimes "1.23". Why?
Thank you in advance!!