I'm currently using this library.
I started with Android APP that works correctly. I could send and receive some data. But what I'm going to do is to make communication between Android and Microcontroller with BT module.
On Android to Android I send data like this:
String sequence = "1234";
bt.send(sequence.getBytes(), true);
//or just:
bt.send(sequence, true);
And on second device I receive data like this:
bt.setOnDataReceivedListener(new OnDataReceivedListener() {
public void onDataReceived(byte[] data, String message) {
...
}
});
So it seems that data I send is that message, but if I try do something like this:
String received_data = data.toString();
It looks like some random sequence, for example:
[B@1b1f21b4
And [B@
part is always the same. It would be actually no problem if I just want to do Android <-> Android APP, where I can just extract the data I need from message, but I need to read those data on Microcontroller. How can I properly receive those data?
EDIT: Thanks to Isaac, I know I needed to convert on Android bytes to string like that:
String str = new String(bytes, "UTF-8");
And both from message and data I can read my information. But if receiving data on Microcontroller would be correct?