언어 설정

Menu
Sites
Language
In web api, we can get pedometer count and last heart rate, how to do in native?
In web api, we can get pedometer count and last heart rate, how to do in native? Thanks
답변 바로가기

Responses

11 댓글
Armaan-Ul- Islam

Hello, I am sharing Code Samples for you:

HRM data:

    #include <sensor.h>
    #include<stdbool.h>


    bool checkSupport(sensor_type_e type){
         bool support;
         sensor_is_supported(type,&support);
         return support;
    }

    void sensorEventCallBack(sensor_h sensorHanlder, sensor_event_s *event, void *user_data){
          dlog_print(DLOG_DEBUG, LOG_TAG, "SENSOR_HRM data: %.2f", event->values[0]);
    }


    void logPrintSensorData(){

         if(checkSupport(SENSOR_HRM)){

             sensor_h sensorHanlder;
             sensor_get_default_sensor(SENSOR_HRM, &sensorHanlder);

             sensor_listener_h sensorListener;
             sensor_create_listener(sensorHanlder,&sensorListener);

             sensor_listener_set_event_cb(sensorListener,1000, sensorEventCallBack, NULL);
             sensor_listener_set_option(sensorListener,SENSOR_OPTION_ALWAYS_ON);
             sensor_listener_start(sensorListener);
            
              /* Once Task Completed*/
             //sensor_listener_stop(sensorListener);

         }

         else {
             dlog_print(DLOG_ERROR, LOG_TAG, "SENSOR_HRM Not Supported");
         }
    }

In tizen-manifest.xml add privilege http://tizen.org/privilege/healthinfo

 

Pedometer data (Since Tizen 3.0 ):

    #include <sensor.h>
    #include<stdbool.h>

    bool checkSupport(sensor_type_e type){
         bool support;
         sensor_is_supported(type,&support);
         return support;
    }

    void sensorEventCallBack(sensor_h sensorHanlder, sensor_event_s *event, void *user_data){

          dlog_print(DLOG_DEBUG, LOG_TAG, "Number of steps: %d", event->values[0]);
          dlog_print(DLOG_DEBUG, LOG_TAG, "Number of walking steps: %d", event->values[1]);
          dlog_print(DLOG_DEBUG, LOG_TAG, "Calories burned: %.2f kcal", event->values[4]);
           /* values[0] to values[7]*/
    }

    void logPrintSensorData(){

         if(checkSupport(SENSOR_HUMAN_PEDOMETER)){

             sensor_h sensorHanlder;
             sensor_get_default_sensor(SENSOR_HUMAN_PEDOMETER, &sensorHanlder);

             sensor_listener_h sensorListener;
             sensor_create_listener(sensorHanlder,&sensorListener);

             sensor_listener_set_event_cb(sensorListener,1000, sensorEventCallBack, NULL);
             sensor_listener_set_option(sensorListener,SENSOR_OPTION_ALWAYS_ON);
             sensor_listener_start(sensorListener);
            
              /* Once Task Completed*/
             //sensor_listener_stop(sensorListener);

         }

         else {
             dlog_print(DLOG_ERROR, LOG_TAG, "SENSOR_HUMAN_PEDOMETER Not Supported");
         }
    }

In tizen-manifest.xml add privilege http://tizen.org/privilege/healthinfo


Please Check Sensor Guide & Sensor API References for details Implementation:

https://developer.tizen.org/development/guides/native-application/location-and-sensors/device-sensors
https://developer.tizen.org/development/guides/native-application/location-and-sensors/device-sensors#hrm                                                        https://developer.tizen.org/development/guides/native-application/location-and-sensors/device-sensors#pedometer
https://developer.tizen.org/development/api-references/native-application?redirect=/dev-guide/latest/org.tizen.native.wearable.apireference/group__CAPI__SYSTEM__SENSOR__MODULE.html

 

Tizen is me

Thanks, since in gear s3, the tizen version is 2.3.2, we should wait for the new version ?

Mark as answer
Armaan-Ul- Islam

If the situation is you have to be rigid with NATIVE platform, then yes my friend you have to wait till update. But if you can also work with Tizen WEB Platform , then you can read pedometer data from gear S3 right now. I am sharing the code sample just in case.

 

 function onsuccessCB(pedometerInfo) {
     console.log("Step status : " + pedometerInfo.stepStatus);
     console.log("Cumulative total step count : " + pedometerInfo.cumulativeTotalStepCount);
 }

 function onerrorCB(error) {
     console.log("Error occurs. name:"+error.name + ", message: "+error.message);
 }

 function onchangedCB(pedometerdata) {
     console.log("From now on, you will be notified when the pedometer data changes.");
     // To get the current data information
     tizen.humanactivitymonitor.getHumanActivityData("PEDOMETER", onsuccessCB, onerrorCB);
 }

 tizen.humanactivitymonitor.start("PEDOMETER", onchangedCB);
 

    Add these privileges on config.xml:

<tizen:privilege name="http://tizen.org/privilege/healthinfo"/>
<tizen:privilege name="http://tizen.org/privilege/location"/>

 

Output example:

 From now on, you will be notified when the pedometer data changes.
 Step status : WALKING
 Cumulative total step count : 100

 

For details: https://developer.tizen.org/development/api-references/web-application?redirect=https://developer.tizen.org/dev-guide/2.3.2/org.tizen.web.apireference/html/device_api/wearable/tizen/humanactivitymonitor.html

Sandip Patil

@Armaan-Ul- Islam

Whenever I use 

tizen.humanactivitymonitor.getHumanActivityData("PEDOMETER", onsuccessCB, onerrorCB);

I am getting step count as zero and as I starting walking it starts increasing step count i.e it is giving cumulative total step count. So, is there any way in which I can get total step count till date?

 

Tizen is me

Thanks, is it possible to call web api from native ? 

dev madrad

No.

Reiko Weiss

i tested the code snipped as Native C in 3.0.0 in Emulator.  But i can read the Calories, not the steps.

Armaan-Ul- Islam

By Default, Pedeometer state is set to 'Stop' in Emulator.

 

Go to Emulator > Right click on Mouse > Control Panel > Pedometer (In Second Page) > Change Pedometer State then check your logs realtime.

 

Choi

Hello
It is very difficult to develop a Tizen wearable native pedometer. Please give me a full source code.I'd appreciate your help.

wuckertrhea wuckertrhea

The creation of a native wearable pedometer for Tizen is highly challenging. Please send me the complete source code.Please lend me a hand.  
basketball stars