Languages

Menu
Sites
Language
How to sample sensor data reliably with Web Application

Hello, I was trying to read sensor data periodically (e.g. 25Hz) with Web application API.

I used JavaScript setTimeout() function with 40ms timeout, yet I encountered two problems:

1. Reading sensor data finished earlier than I expected.

I used callback functions that (1) increases the global counter and (2) setTimeout with 40ms for next read. I set repetition number to 150 to get sensor data for 6s. However 150 samples are filled much earlier than I expected (e.g. 4s).

2. Widget is not working when the watch face is downside.

I found out that when the watch face is downside, the widget is not working in the background, thus not reading the data. I am trying to gather sensor data to distinguish different gestures, where watch faces often goes downside.

So I want the sensor data to be collected in the background. Thus, I am finding ways to reliably gather data (1) with accurate time interval (e.g. 40ms) (2) in the background, even when the watch face is downside.

Is it possible to implement these sensor service with Web Application (JavaScript)? Or should I move to Native application? Thanks!

Edited by: Seonghyun Park on 29 Mar, 2019

Responses

3 Replies
GEUNSOO KIM

Well.. I'm affraid that you cannot.

Samsung is quite sensitive about battery time, so lots of restrictions are added to reduce any process alive until now.

1. widget will not work when it is down. you write the code, but run by home screen, not you. so you have no way to change it.

2. web/native UI app will not work in their down time either. even if you make enforce them awake, system will down your app or battery will consumed too much.

3. even a native service app, you cannot keep it alive as long as you wanted or scheduled.

4. the current interval you are using could be too short for some sensors. check the Tizen documents about the sensor you want to use and make it sure that the interval is enough.

5. So most common way to read sensor periodically on gear device is using alarm system, but the interval is quite higher than what you want currently.

I think you need to investigate more to find your solution.

good luck.

 

 

 

Seonghyun Park

Thanks for your answer.

I understand the usage of widget is quite limited, so from now on, I consider native apps.

AFAIK there are something that I can do to run apps in background or make them awake when the display is off.

For example, setting configurations (i.e., background-category/sensors) and using power APIs (i.e., device_power_request_lock()).

You mean these won't make my application run countinuously in the backgroud?

Then whate is the best way to continuously read sensor data with pretty short sampling rate (e.g. < 100ms)?

GEUNSOO KIM

Even a background native service app, it would enter sleep state except the following 2 cases.

1. Enforcing the service app awake using power lock api.

Yes. you can make it work with this, but this will consume battery very rapidly and could be messed up by losing release point in various reason.

And if you are think about publishing on store, there is a chance that Samsung would not allow the api usage.

2. Setting up an alarm to wake the service app at the point you want.

Because the app goes sleep in any time without power locking, you may use alarm to wake it up for sure when you want. But the minimum interval of alarm is 10 minutes.

 

There are my experience when I was making programs for tizen 3.0 gear devices.

I cannot sure that Samsung has changed their policy or behavior on tizen 4.0 or later.

You may need to try your own way, but these kind of obstacles could appear on your way.