Vipul Rahane created MYNEWT-669:
-----------------------------------

             Summary: SensorAPI: Change UNUSED_DATA indicator
                 Key: MYNEWT-669
                 URL: https://issues.apache.org/jira/browse/MYNEWT-669
             Project: Mynewt
          Issue Type: Improvement
            Reporter: Vipul Rahane
            Assignee: Vipul Rahane
             Fix For: v1_0_0_rel


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.



--
This message was sent by Atlassian JIRA
(v6.3.15#6346)

Reply via email to