I am trying to develop an Android application in which I want to communicate with thermometer using bluetooth. Right now I am already able to pair my phone with the device and I know that the device is acting as a slave, waiting for incoming request from phone in order to send measured data to the phone. Even though I have a communication protocol, I am facing difficulties following it so I am looking for help here:)
public void write(byte[] bytes) {
String text = new String(bytes, Charset.defaultCharset());
Log.d(TAG, "write: Writing to outputstream: " + text);
try {
mmOutStream.write(bytes);
} catch (IOException e) {
Log.e(TAG, "write: Error writing to output stream. " + e.getMessage());
}
}
Here you can see snippet of method in which I am trying to write the data to OutputStream mmOutStream
. And now lets get to the question, I dont really know what I should put as an argument when I am calling this method. These are necessary images of communication protocol:
I would be really grateful if you can help me read and understand this communication protocol and direct me in order to be able to send valid data to the device - what should byte[] bytes
variable contains.