I am creating an app that receives Bluetooth data. The data is then stored in an byte array in which will need to be converted to float but not all the data.
Here is an example of the byte array after it is converted to Hex:
36 32 35 2e 30 30 20 00 4e 52 33 31 34 2e 30 30 20 00 cb b7
and that is 625.00 NR314.00 E
The values I need is 625.00 and 314.00
So basically 0 to 5th bytes, and 11 to 15th bytes since the array has a length of 20.
How am I able to traverse the byte array to grab the necessary bytes and then convert them to float?
*** Update1
This is the code I have so far, successfully able to convert the data and traverse the loop but now need to convert the data to float.
byte[] value = characteristic.getValue();
String decoded = new String(value, StandardCharsets.UTF_8);
char[] chars = decoded.toCharArray();
String numberString = "";
String numberString2 = "";
for(int i = 0; i < 6; i++){
numberString += chars[i];
}
Float(numberString);
for(int i = 10; i < 16; i++){
numberString2 += chars[i];
}
Float(numberString2);