Hello all!
I am trying to figure out how to process data from sensors, particularly with the field "timestamp" on Samsung Gear S2.
The doc says that this field in nanosecond, but by my experiments it is looks like this field measured in microseconds and it is not realtime value (does'n increment while sleeping and so on). Most similar value have CLOCK_MONOTONIC. After all I ended up with this code to get event time in ms:
static void accelerometer_cb(sensor_h sensor, sensor_event_s *event, void *data) { struct timespec spec; clock_gettime(CLOCK_REALTIME, &spec); unsigned long long current_time_ms = spec.tv_sec * 1000LL + spec.tv_nsec / 1000000LL; clock_gettime(CLOCK_MONOTONIC, &spec); unsigned long long monotonic_time_ms = spec.tv_sec * 1000LL + spec.tv_nsec / 1000000LL; unsigned long long event_time_ms = current_time_ms - monotonic_time_ms + event->timestamp / 1000LL;
Is this correct way to do this, or I missed something?