Welcome to OGeek Q&A Community for programmer and developer-Open, Learning and Share
Welcome To Ask or Share your Answers For Others

Categories

0 votes
381 views
in Technique[技术] by (71.8m points)

c - Why am i getting constant step count in Tizen Native Wearable?

I'm running step count listener in Tizen Wearable using Native. I'm able to access the sensor data however it seems to print the same data forever? Am I doing something wrong here? Using API 3 and Samsung Galaxy Watch 3.

#include "stepcount.h"
#include "sensor.h"

void
example_sensor_callback(sensor_h sensor, sensor_event_s *event, void *user_data)
{
    /*
       If a callback is used to listen for different sensor types,
       it can check the sensor type
    */
    sensor_type_e type;
    sensor_get_type(sensor, &type);
    int i = 0;

    if (type == SENSOR_ACCELEROMETER) {
        unsigned long long timestamp = event->timestamp;
        int accuracy = event->accuracy;
        float x = event->values[0];
        float y = event->values[1];
        float z = event->values[2];
        dlog_print(DLOG_INFO, LOG_TAG, "ACCEL: %f %f %f", x,y,z);
    } else if (type == SENSOR_HRM) {
        unsigned long long timestamp = event->timestamp;
        int v = (int)event->values[0];
        dlog_print(DLOG_INFO, LOG_TAG, "Heart Rate: %.0f bpm", event->values[0]);
    }
    else if (type == SENSOR_HUMAN_PEDOMETER ){
            unsigned long long timestamp = event->timestamp;
            int accuracy = event->accuracy;
            int s = (int)event->values[0];
            int b = (int)event->values[1];
            dlog_print(DLOG_INFO, LOG_TAG, "Step Count: %d", event->values[0]);
            dlog_print(DLOG_INFO, LOG_TAG, "Walking Step Count: %d", event->values[1]);

    }
}

Base GUI
------
    bool supported = false;

    sensor_is_supported(SENSOR_HUMAN_PEDOMETER, &supported);
    if (!supported) {
        /* Accelerometer is not supported on the current device */
    }

    sensor_h sensor;
    sensor_get_default_sensor(SENSOR_HUMAN_PEDOMETER, &sensor);

    sensor_listener_h listener;
    sensor_create_listener(sensor, &listener);

    sensor_listener_start(listener);

    /* Register callback */
    sensor_listener_set_event_cb(listener, 1000, example_sensor_callback, NULL);

    sensor_listener_set_attribute_int(listener, SENSOR_ATTRIBUTE_PAUSE_POLICY, SENSOR_PAUSE_NONE);

Here's my LOG

01-29 13:25:00.035 : Info / stepcount ( 8215 : 8215 ) : Step Count: 4
01-29 13:25:00.091 : Info / stepcount ( 8215 : 8215 ) : Walking Step Count: 1
01-29 13:30:16.763 : Info / stepcount ( 8215 : 8215 ) : Step Count: 4
01-29 13:30:16.763 : Info / stepcount ( 8215 : 8215 ) : Walking Step Count: 1
01-29 13:30:17.143 : Info / stepcount ( 8215 : 8215 ) : Step Count: 4
01-29 13:30:17.143 : Info / stepcount ( 8215 : 8215 ) : Walking Step Count: 1
01-29 13:30:18.439 : Info / stepcount ( 8215 : 8215 ) : Step Count: 4
01-29 13:30:18.443 : Info / stepcount ( 8215 : 8215 ) : Walking Step Count: 1
01-29 13:30:18.655 : Info / stepcount ( 8215 : 8215 ) : Step Count: 4
01-29 13:30:18.655 : Info / stepcount ( 8215 : 8215 ) : Walking Step Count: 1

I want to read my acutal step count properly.

question from:https://stackoverflow.com/questions/65950726/why-am-i-getting-constant-step-count-in-tizen-native-wearable

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome To Ask or Share your Answers For Others

1 Reply

0 votes
by (71.8m points)

Please correct it as below.

        dlog_print(DLOG_INFO, LOG_TAG, "Step Count: %d", s);
        dlog_print(DLOG_INFO, LOG_TAG, "Walking Step Count: %d", b);

or

        dlog_print(DLOG_INFO, LOG_TAG, "Step Count: %f", event->values[0]);
        dlog_print(DLOG_INFO, LOG_TAG, "Walking Step Count: %f", event->values[1]);

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
OGeek|极客中国-欢迎来到极客的世界,一个免费开放的程序员编程交流平台!开放,进步,分享!让技术改变生活,让极客改变未来! Welcome to OGeek Q&A Community for programmer and developer-Open, Learning and Share
Click Here to Ask a Question

...