Tizen wearable sensor data loss in background after wifi is switched off

痴心易碎 提交于 2020-12-04 11:59:01

问题


I am developing a hybrid application for Tizen Wearable 2.3. For the application, accelerometer and gyroscope sensor data is extracted and written to a file in native service application at a frequency of 100Hz.

However, in certain trials I see that data is lost after few minutes upon switching off WiFi. For instance, if I record the data for 10 minutes, while keeping the app in background (display off) and turn off wifi during the fifth minute, the file shows data for only first 5 minutes, the remaining data is not written to the file. How can I stop this behaviour?

Thanks.


回答1:


Finally, found that I had not obtained the device_power_request_lock on CPU.

device_power_request_lock( POWER_LOCK_CPU, 0);

The function locks the given lock state for infinite time, and doesn't allow CPU to go into sleep state, which was causing the data loss. To unlock CPU after session is recorded:

device_power_release_lock(POWER_LOCK_CPU); 



回答2:


As a complement to the previous answer, besides setting the CPU lock on, it's still necessary to add Background Category type of 'sensor' to prevent the tizen system (I am using tizen 3.0 on Gear S3 frontier) from killing the app due to high energy consumption, as one answer mentioned in this post Is it possible to keep Tizen application alive non stop.

Go to tizen-manifest.xml >> Advanced >> Background Category >> add Category type 'sensor'.

In my case, at the beginning, I only set the CPU lock on, and the sensors did continuously record data in the background. But in less than ten minutes the app was started, the tizen system popped out a window asking something like 'XXX application consumes lots of energy, do you want to close it'. Funny that no vibration as notification of this while the screen is still black. I barely found this pop-up by chance. If you choose to keep the app running and think everything is fine, then you are totally wrong. The system will do the same thing every now and then (10 mins or so), and if a single time you didn't notice, your app will be killed. The tizen document is really a mess and mostly you can only figure out problems by trial and error and with the help of online posts.



来源:https://stackoverflow.com/questions/40449985/tizen-wearable-sensor-data-loss-in-background-after-wifi-is-switched-off

标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!