Sensor recorder time period doesn’t follow query settings
Sensor recorder time period doesn’t follow query settings
BY 06 Feb 2021Native Application Development
I am trying to use the PEDOMETER on Tizen wearable 5.5. I can get the listener to work and return the data. But the data is aggregated to something I can’t find documentation about.
I found that I need to do the calculation myself (and found a few samples in here and github) but the behaviour I am expecting when using the recorder is quite weird. Here is my code:
void get_initial_pedometer_data() {
bool recorderSupported;
sensor_recorder_is_supported(SENSOR_HUMAN_PEDOMETER, &recorderSupported);
if (!recorderSupported) {
dlog_print(DLOG_WARN, LOG_TAG, "Recorder not supported.");
return;
}
sensor_recorder_create_option(&option);
sensor_recorder_option_set_int(option, SENSOR_RECORDER_OPTION_RETENTION_PERIOD, 24);
sensor_recorder_start(SENSOR_HUMAN_PEDOMETER, option);
sensor_recorder_query_h query;
if (sensor_recorder_create_query(&query) != SENSOR_ERROR_NONE) {
dlog_print(DLOG_WARN, LOG_TAG, "Cannot create query");
return;
}
time_t nowTimeStamp, midnightTimestamp;
nowTimeStamp = time(NULL);
struct tm *tmNow = localtime(&nowTimeStamp);
midnightTimestamp = nowTimeStamp - (tmNow->tm_hour * 3600) - (tmNow->tm_min * 60) - (tmNow->tm_sec);
// Here I have checked I have time period from 00h00m to current time
if (sensor_recorder_query_set_time(query, SENSOR_RECORDER_QUERY_START_TIME,
(time_t) (time(NULL) - (7 * 24 * 3600))) != SENSOR_ERROR_NONE) {
dlog_print(DLOG_WARN, LOG_TAG, "Cannot set query START option: %ld.",
midnightTimestamp);
return;
}
if (sensor_recorder_query_set_time(query, SENSOR_RECORDER_QUERY_END_TIME,
time(NULL)) != SENSOR_ERROR_NONE) {
dlog_print(DLOG_WARN, LOG_TAG, "Cannot set query END option: %ld.",
nowTimeStamp);
return;
}
if (sensor_recorder_query_set_int(query,
SENSOR_RECORDER_QUERY_TIME_INTERVAL, 24 * 60)
!= SENSOR_ERROR_NONE) {
dlog_print(DLOG_WARN, LOG_TAG, "Cannot set query INTERVAL option: %d.",
24 * 60);
return;
}
if (sensor_recorder_query_set_time(query, SENSOR_RECORDER_QUERY_ANCHOR_TIME,
midnightTimestamp) != SENSOR_ERROR_NONE) {
dlog_print(DLOG_WARN, LOG_TAG, "Cannot set query ANCHOR option: %ld.",
(time_t) (7 * 3600));
return;
}
int error = sensor_recorder_read_sync(SENSOR_HUMAN_PEDOMETER, query,
sensor_pedometer_data_cb, NULL);
if (error != SENSOR_ERROR_NONE) {
dlog_print(DLOG_WARN, LOG_TAG, "Cannot read query: %d", error);
}
}
The log printout of the start and end dates are always the same value a any time I run the app, and it is not from midnight to current time, but 2.45pm to 2.46pm (just 1 minute apart). Therefore the “Step count” value is low.
Sensor recorder time period doesn’t follow query settings
I am trying to use the PEDOMETER on Tizen wearable 5.5. I can get the listener to work and return the data. But the data is aggregated to something I can’t find documentation about.
I found that I need to do the calculation myself (and found a few samples in here and github) but the behaviour I am expecting when using the recorder is quite weird. Here is my code:
Then the callback method is:
The log printout of the start and end dates are always the same value a any time I run the app, and it is not from midnight to current time, but 2.45pm to 2.46pm (just 1 minute apart). Therefore the “Step count” value is low.
What am I doing wrong?
BY
04 Nov 2024
Tizen Studio
BY
02 Apr 2024
Tizen Studio
BY
30 Oct 2023
Tizen Studio