언어 설정

Menu
Sites
Language
Sensors in sleep mode

Hello !

I'm trying to retrieve continous heart rate with Sensor Listener API.  

Everything works fine excepts that when the wearable goes into sleep mode, the sensor call_back stops to be called.

I 've already added SENSOR_OPTION_ALWAYS_ON and SENSOR_PAUSE_NONE but like the doc says, it doesn't affect sensors on sleep mode.

I'd like to know under what conditions the device enters in sleep mode ?

Is there a way to make HRM work during sleep mode ? Or maybe to make it works in batch manner like SENSOR_SLEEP_MONITOR does ? 


Thanks in advance !

Responses

12 댓글
Yasin Ali

Hi,
Check below options.

Is there a way to make HRM work during sleep mode ?

You may mark your app as background app. Use:

<metadata key="http://tizen.org/metadata/background-category/sensor"/>

Also check Enumeration for sensor options:

1. SENSOR_OPTION_ON_IN_SCREEN_OFF 
Receives data when the LCD is off
 
2. SENSOR_OPTION_ON_IN_POWERSAVE_MODE 
Receives data in the power save mode
 
3. SENSOR_OPTION_ALWAYS_ON 
Receives data when the LCD is off and in the power save mode
 
Ref:
https://developer.tizen.org/zh-hans/development/api-references/native-application?redirect=/dev-guide/2.4.0/org.tizen.native.mobile.apireference/group__CAPI__SYSTEM__SENSOR__MODULE.html&langredirect=1#gaf517b61e58b872f985fc2fc2a26aa56a
[ Native Service App Concept ]

I'd like to know under what conditions the device enters in sleep mode ?

For this case try to call this api periodically:

device_display_change_state (DISPLAY_STATE_NORMAL);

maybe you could try to use timer or use

device_add_callback (device_callback_e type, device_changed_cb callback, void *user_data)

with

device_callback_e = DEVICE_CALLBACK_DISPLAY_STATE

and check inside callback that display state was changed from

DISPLAY_STATE_NORMAL to DISPLAY_STATE_SCREEN_DIM
Remember to add: <privilege>http://tizen.org/privilege/display</privilege>

Hints on Code:

static void
display_changed_cb(device_callback_e type, void *value, void *user_data){
    int error;
    if(DEVICE_CALLBACK_DISPLAY_STATE == type) {
        dlog_print(DLOG_INFO, LOG_TAG, "[device_changed_cb] display state: %d\n", (char*)value);
     error = device_display_change_state(DISPLAY_STATE_NORMAL);
    }
}

// register the display state changed callback
device_add_callback(DEVICE_CALLBACK_DISPLAY_STATE, display_changed_cb, NULL);

Hope it will help you.
If you find my post is helpful for you, please mark it as the Best Answer to promote this post to others.

 

Fanny Huang

Hi, thanks for your reply !

I tried adding

<metadata key="http://tizen.org/metadata/background-category/sensor"/>

to my manifest but does not seem to work, I still get very few HR recordings.

My app is a background service, not a conventional app, would that make a difference?

Thanks.

Yasin Ali

Is this standalone Native service app? I mean no UI app connected anyhow?

How you retrieving data/ View data?

Fanny Huang

Hi Yaslin,

Yes, it's a standalone native service app that sends data to another app has a UI.

I tried adding a Timer in my service App, but it doesn't work. I still have data holes. It seems that the timer is also paused when the device enters in sleep mode.

Is there another way to make HRM keep monitoring even in sleep mode ?

Thanks.

Yasin Ali

Try with CPU lock. With this Display can be made off but not the CPU.
Your app can even run in the screen off state/sleep mode.

int error;
error = device_power_request_lock(POWER_LOCK_CPU, 0);
// Other code
error = device_power_release_lock(POWER_LOCK_CPU);

Ref link:
https://developer.tizen.org/ko/development/api-references/native-application?redirect=/dev-guide/2.3.1/org.tizen.native.mobile.apireference/group__CAPI__SYSTEM__DEVICE__POWER__MODULE.html&langredirect=1

Hope it'll help.
Thanks.

Damian Michalak

Hi Fanny.

Have you found a solution to this problem?

I'm currently facing similar situation. Application is not getting HRM events when it goes to sleep - after 10 minutes or so. 

And all those background-category stuff is waking up the application, but not often enough. There are even 20 minutes holes between measurements and this is not acceptable for me. I need constant measurement of the heart rate. 

GEUNSOO KIM

You'd better use "alarm" instead of timer for wearable devices because the sleep mode is too strong so you cannot control it with timer.

Only thing you have to keep in mind is the alarm period. the alarm period should be at least 10 minutes or more from Tizen 3.0.

 

Damian Michalak

Thank you for the response GENSOO. Curently I'm trying with alarms, but they no only wake up the application but also launch it and briong it to the front. So there could be a case when my heart rate monitor app would popup for no reason just to keep the data recording on. Is there a way to handle the alarm without making the application UI visible? Or even without turning on the display.

GEUNSOO KIM

Are you using "APP_CONTROL_OPERATION_DEFAULT" on your alarm?

If you are, try "APP_CONTROL_OPERATION_MAIN" instead of it. usually the default app control causes re-launching your app.

good luck.

Damian Michalak

Hi, I was using APP_CONTROL_OPERATION_DEFAULT, thanks for the suggestion with APP_CONTROL_OPERATION_MAIN flag. Works fine. \

 

Is there some sort of alarm callback or some method that will be called when time for alarm comes? I would like to set an alarm for one minute in future, and when it comes, set another alarm for one more minute and continue this process until needed.

GEUNSOO KIM

Well.. Only I can think about it is just setting another alarm with different information .

You can custom the information used for the alarm app control like URI or even operation.

Because the alarm is used here to wake up from sleep mode and 1 minute is quite long and can enter sleep, it looks that alarm is the only way you can pick.

good luck.