I'm trying to create a BLE app where i want to catch the value of the temperature from a device. I'm using Temp Sitter device.
I have this UUID=0000ffe1-0000-1000-8000-00805f9b34fb. From here I get an array of bytes.
// For all other profiles, writes the data formatted in HEX.
final byte[] data = characteristic.getValue();
if (data != null && data.length > 0) {
final StringBuilder stringBuilder = new
StringBuilder(data.length);
for(byte byteChar : data)
stringBuilder.append(String.format("%02X ", byteChar));
intent.putExtra(EXTRA_DATA, new String(data) + "\n" +
stringBuilder.toString());
}
Here are some hex results:
AA 06 11 00 3E 0D 00 62 ---
AA 06 11 00 43 0D 00 67 ---
AA 06 11 00 49 0D 00 6D
Can any one help me how to read the exact value of this array?
After reverse-engineering the IRULU / Guangdong Biolight Meditech Temp Sitter app, it looks as if the message has this format:
0 1 2 3 4 5 6 7
+------+------+------+------+------+------+------+------+
|Marker|Length|Type |Subtyp|Low |High |Unused|Chksum|
+------+------+------+------+------+------+------+------+
Example AA 06 11 00 3E 0D 00 62
The fields are:
The temperature value is stored in 0.01 degree (probably degree Celsius). So to extract it, you compute:
double temperature = ((message[5] & 0xff) * 256 + (message[4] & 0xff)) * 0.01;
In the above example, the result would be 33.90 °C.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With