Languages

Menu
Sites
Language
Heart Rate and Pedometer Sen

I am trying to develop a watch face that uses heart rate and pedometer information, I have searched all over here and can't figure out how to fix my problem.

I have included <sensor.h> and set http://tizen.org/prialege/healthifo privalege

The problem i am having is when I run  

sensor_get_default_sensor(SENSOR_HRM, &sensorHanlder);

for either the pedometer or the heart rate monitor, it returns -13 (Permission Denied) and I cant figure out anything regarding how to fix that. I also tride using 

sensor_get_default_sensor_by_uri("http://tizen.org/sensor/healthinfo/human_pedometer", &sensorHandler);

and it gives me the same error.

I have gotten this same code working for the accelerometer, so It is structured right for at least some sensors.

I am running tizen 4.0 with the emulator and on my galaxy watch and get the same results. any help would be greatly appreciated

the following is the section of code I am using (from example code from this site):

float hrnow;
int success;

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

//for heart rate monitor
void sensorEventCallBack(sensor_h sensorHanlder, sensor_event_s *event, void *user_data){
     sensor_type_e type;
     sensor_get_type(sensorHanlder, &type);
     switch (type)
     {
     case SENSOR_HRM:
      dlog_print(DLOG_DEBUG, LOG_TAG, "SENSOR_HRM data: %.2f", event->values[0]);
      hr_now = event->values[0];
      break;
     default:
      dlog_print(DLOG_ERROR, LOG_TAG, "Not an HRM event");
     }
}

void logPrintSensorData(appdata_s *ad){

      if(checkSupport(SENSOR_HRM)){

          sensor_h sensorHandler;
          success = sensor_get_default_sensor(SENSOR_HRM, &sensorHanlder);
//          success = sensor_get_default_sensor_by_uri("http://tizen.org/sensor/healthinfo/human_pedometer", &sensorHandler);
          sensor_listener_h sensorListener;
          sensor_create_listener(sensorHandler,&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");
      }
 }

Responses

3 Replies
Jacob Olson

UPDATE:

I compiled this with the tizen 3.0 api rather than the 4.0 api and it worked. anyone know why tizen 4.0 would not give access to heartrate and pedometer sensors? or is there a new way that you are supposed to do it?

Luzian Scherrer

Have you been able to solve this with the Tizen 4.0 API? I'm facing the exact same problem.

Luzian Scherrer

I've figured it out by now. On Tizen 4 the user has to go to Settings - Apps - Permissions and manually toggle sensor permission for your app to "on". You can however check in code with the ppm_check_permission() function for http://tizen.org/privilege/healthinfo permission and if it returns PRIVACY_PRIVILEGE_MANAGER_CHECK_RESULT_ASK you can trigger a permission request dialog with the ppm_request_permission() function. This is documented here: https://docs.tizen.org/application/native/guides/security/privacy-related-permissions/

That's fine in a consumer context I think but since I'm running in a controlled enterprise environment, I need to find a way to grant this permission for the managed devices. I quickly checked the Knox SDK but didn't find anything about sensor permission.