Search code examples
androidandroid-sensorsbatching

How I receive sensors data in batching mode?


I didn't program sensors apps yet, but I read about batching (in KitKat) and I wonder how should I get the data.

I found in sensors header file (line 1083):

All events since the previous batch are recorded and returned all at once

but according this API I have only one X, Y, Z to receive the data (and not a list or an array).

From the API:

/**
 * sensor event data
 */
typedef struct {
    union {
        float v[3];
        struct {
            float x;
            float y;
            float z;
        };
        struct {
            float azimuth;
            float pitch;
            float roll;
        };
    };
    int8_t status;
    uint8_t reserved[3];
} sensors_vec_t;

So I didn't understand if I really should receive all data at once or it's refers to HW layer and I, in the SW layer should receive the data one by one (by way with events) – if yes what is the latency, and what is the delay between the events ?


Solution

  • After reading batch section again I think I hava a answer: All sensors data in batching mode saves in FW FIFO. It's meaning sensors samples done. Now only left to transfer the data to SW. It's performs by events, probablly without delay (one by one). (So not delay should be between the events and the latency depnded the FW..)

    If anyone think I wrong please let me know, Thank you