W3C home > Mailing lists > Public > public-device-apis@w3.org > February 2010

Re: Sensors simplified (or not)

From: Max Froumentin <maxfro@opera.com>
Date: Fri, 12 Feb 2010 10:26:53 +0100
Message-ID: <4B751EDD.3000106@opera.com>
To: "Nilsson, Claes1" <Claes1.Nilsson@sonyericsson.com>
CC: "public-device-apis@w3.org" <public-device-apis@w3.org>
On 11/02/2010 17:23, Nilsson, Claes1 wrote:

> However, don't we still need some method to discover which sensors
> this actual device supports? I am considering something similar to
> Android getSensorList,
> http://developer.android.com/reference/android/hardware/SensorManager.html#getSensorList(int)

I think you're right. Right now I'd considered that you would be able to 
write:

get("AmbientAtmosphericPressure",error,success);

function error(e) {
   if (e.type==INFORMATION_UNAVAILABLE) {
     // there's no pressure sensor, so do something else
   }
}

function success(p) {
   // we have a pressure value, proceed
   watch("AmbientAtmosphericPressure", error2, success2);
}

but perhaps it's indeed better if we could write:

if (navigator.device.sysinfo.supports("AmbientAtmosphericPressure"))
   // we have a pressure value, proceed
   watch("AmbientAtmosphericPressure", error, success);
else
   // no pressure sensor, do something else

Something like that?

Max.
Received on Friday, 12 February 2010 09:27:27 GMT

This archive was generated by hypermail 2.2.0+W3C-0.50 : Wednesday, 9 May 2012 00:14:06 GMT