Hello,

For unused data, UNUSED_DATA constant was being used which would be set to a 
value which is not used by the sensor data. Downside to this is: 
Eg: If it is defined to be -1 and for some reason sensor data is exactly -1, 
the data would get ignored by the SensorAPI. 

There are two ways to deal with this:

1. Use bit fields: 
Use bit fields for ensuring validity of the data. I use it for color sensor 
data. As compared to flags and the earlier constant data approach, this is very 
specific and can be used flexibly.

2. Use flags:
Using flags is the same as using bit fields, the only downside is the bitwise 
comparison in if statements. 


My preferred approach:
1. Use bit fields.
This is because of the advantages it has over flags and the constant data 
approach.

Disadvantage: 
Over the air using bit fields might be a bit problematic, but the sensors data 
structures are internal and over the air we would not send the data structure 
itself(hopefully) but it would most probably be mapped to some other resource 
in an application protocol. 

Any suggestions/comments are welcome.

Regards,
Vipul Rahane

Reply via email to