I am new to coding but anxious to learn. I have been struggling for a while now trying to receive messages from an arduino board connected to a bluesmirf. The arduino board is simply outputting a byte over bluetooth and I'm trying to read it in the debug.
Here is my android code:
I know I am connecting to the device fine because the green light on the board lights up. The debug message that I am getting though is garbage:
But I know it is connected because the "Message is: ..." Dialog inputs every time a message should be coming.
What is going on here? Does anyone have an idea? I might not be giving you enough code, let me know, I just don't want to overwhelm you.
PS I have also tried transmitting "hello world" to the arduino board with success. It is receiving messages that I cannot do yet.
Here is my android code:
Code:
Log.i(TAG, "BEGIN run and receive message");
byte[] buffer = new byte[1024];
int bytes;
Log.i(TAG, "The original buffer string is " + buffer);
//Keep listening to the Input Stream while connected
while(true){
try{
//Read from the InputStream
bytes = inStream.read(buffer);
Log.i(TAG, "Message is: " + buffer);
}
catch(IOException e){
Log.e(TAG, "disconnected", e);
break;
}
}
So as you can see, the buffer string isn't even changing (even though I have tried multiple types of strings from arduino code).04-19 15:58:26.264: ERROR/BluetoothChat(8558): ON RESUME: BT connection established, data transfer link open.
04-19 15:58:26.264: ERROR/BluetoothChat(8558): + ABOUT TO SAY SOMETHING TO SERVER +
04-19 15:58:26.264: INFO/BluetoothChat(8558): BEGIN run and receive message
04-19 15:58:26.264: INFO/BluetoothChat(8558): The original buffer string is [B@4471f770
04-19 15:58:26.408: INFO/BluetoothChat(8558): Message is: [B@4471f770
04-19 15:58:27.406: INFO/BluetoothChat(8558): Message is: [B@4471f770
04-19 15:58:27.406: INFO/BluetoothChat(8558): Message is: [B@4471f770
04-19 15:58:28.411: INFO/BluetoothChat(8558): Message is: [B@4471f770
But I know it is connected because the "Message is: ..." Dialog inputs every time a message should be coming.
What is going on here? Does anyone have an idea? I might not be giving you enough code, let me know, I just don't want to overwhelm you.
PS I have also tried transmitting "hello world" to the arduino board with success. It is receiving messages that I cannot do yet.