Decoding raw data op from the sensor

Hi All,

I have just got hold of my sensor and been trying to explore the mbient C sensor.
On exploring the Android API and the sample apps , I have been able to get the raw byte[] stream into meaningful data such as
in the below snippet getting Celcius Temp by Float celsius = msg.getData(Float.class); 
but I wanted to understand the raw data encoding , how they are packed and how do we read them to understand what format will be saved for Temp data and what will be for other Sensors such as Humidity and Accelerometer.
Is there any guide/documentation for this?
@Override
public void process(Message msg) {
final Float celsius = msg.getData(Float.class);
byte[] tempPayload= msg.getData();
int length= tempPayload.length;
System.out.println(Arrays.toString(tempPayload));
Log.i("tutorial","Temp in Cel: "+celsius);
Log.i("tutorial","Length of raw data: "+length);
String rawString=new String(tempPayload);
Log.i("tutorial",rawString);

for(int i=0;i<length;i++){
char a=(char)tempPayload[i];
System.out.println("Char: "+i+"\t"+a);
}
}

The logs I am getting for these are like:
[-52, 0]
Temp in Cel: 25.5
Length of raw data: 2
���
Char: 0	ᅩ
Char: 1	��

Hoping someone can help me understand this,
Thanks and Regards,
Dush..

Comments

  • No, there is no guide to interpreting the bytes, that is what the API is for.  If you really want to know the inner details, you can look through the API source code.
  • Hi @Eric, is source code available for iOS API ?
  • iOS source code is not available atm
This discussion has been closed.