Languages

Menu
Sites
Language
Tizen Wearable 3.0 unable to read accelerometer sensor from the device

Hello.

I'm trying to get accelerometer data from my Samsung Gear Sport. I'm following this API reference https://developer.tizen.org/ko/development/api-references/web-application?redirect=/dev-guide/latest/org.tizen.web.apireference/html/device_api/wearable/tizen/sensor.html&langredirect=1#AccelerationSensor::getAccelerationSensorData

 

here is my code:

 

 if (tizen.systeminfo.getCapability("http://tizen.org/feature/sensor.accelerometer") == true) {

            console.log("acceleration is supported in this device");

            var accelerationSensor = tizen.sensorservice.getDefaultSensor("ACCELERATION");

else {

            console.log("acceleration is not supported in this device");

}

 

and my logs say:

 

accelerometer is supported on this device.
VM45:1 Uncaught TypeMismatchError: Cannot convert ACCELERATION to enum.

 

I've also tried with "ACCELEROMETER" and "LINEAR_ACCELERATION" and "SENSOR_ACCELEROMETER". None worked.

Also I've tried with 'GYROSCOPE' and it works OK...

What is the problem?

Edited by: Damian Michalak on 09 Apr, 2018

Responses

5 Replies
GEUNSOO KIM

did you try the follwoing pair?

tizen.systeminfo.getCapability("http://tizen.org/feature/sensor.linear_acceleration") - "LINEAR_ACCELERATION"

(refernce: https://developer.tizen.org/development/api-references/web-application?redirect=https://developer.tizen.org/dev-guide/3.0.0/org.tizen.web.apireference/html/device_api/wearable/tizen/sensor.html#SensorService::getDefaultSensor)

I know you have tried "LINEAR_ACCELERATION", but I cannot sure you have checked the feature with "tizen.systeminfo.getCapability("http://tizen.org/feature/sensor.linear_acceleration") ".

 

GEUNSOO KIM

Or you can dump the supported sensors by using "getAvailableSensors"

 
Damian Michalak

It works with LINEAR_ACCELERATION. Thanks. 

But still there is a bug in Tizen OS, because it's telling that capability ACCELERATION is available when it's not.

Yasin Ali

"...because it's telling that capability ACCELERATION is available when it's not."

Possibly you are guessing this based on the result of this line

tizen.systeminfo.getCapability("http://tizen.org/feature/sensor.accelerometer") == true

But this is "accelerometer" not "acceleration".
For example, linear_acceleration for "LINEAR_ACCELERATION"

In my case "getAvailableSensors" does not lists ACCELERATION but LINEAR_ACCELERATION.

Your coding

var accelerationSensor = tizen.sensorservice.getDefaultSensor("ACCELERATION");

while  ACCELERATION is not listed/included in the listing extracted from "getAvailableSensors",
meaning you are trying to access something that is not present in current device. So, facing problem.

So, technically from your code it does not tell capability ACCELERATION is available when it's not.

Lippert

So I have the same problem at the moment and I can't understand why the developer did it this way.

So the LinearAccelerationSensor is implemented since version 3.0 and since your device has version 3.0 installed you get that sensor you can read it up here :

https://developer.tizen.org/development/api-references/web-application?redirect=https://developer.tizen.org/dev-guide/4.0.0/org.tizen.web.apireference/html/device_api/mobile/tizen/sensor.html#LinearAccelerationSensor

The normal AccelerationSensor is only implemented now in version 4.0 which is for example for my device Samsung Gear 3 not available at the moment. You can read the sensor specs up here: 

https://developer.tizen.org/development/api-references/web-application?redirect=https://developer.tizen.org/dev-guide/4.0.0/org.tizen.web.apireference/html/device_api/mobile/tizen/sensor.html#AccelerationSensor

So if you want to have access to all sensor data you should probably implement a native app. Im looking right now for an alternative way to still get the sensor data.

So if you found a way except of updating to Tizen version 4.0 on my hardware device please let me know.