In association with heise online

04 February 2010, 10:02

W3C proposes hardware interface

  • Twitter
  • Facebook
  • submit to slashdot
  • StumbleUpon
  • submit to reddit

W3C Logo The World Wide Web Consortium (W3C) draft for a "System Information API" specifies JavaScript functions for accessing the battery, CPU, sensors and other hardware characteristics of a device. For this purpose, the window.navigator object's SystemInfo interface has to implement the get, set and watch methods. set can only be applied to some screen properties such as brightness and orientation, while all other hardware properties are marked as readonly. watch is used for monitoring readings, for example those of a heat sensor.

All the methods work asynchronously, and an application doesn't wait for their completion. Instead, the method calls an event handler. One of the W3C's examples alerts the user when the battery level is below 20% to illustrate the process:

navigator<span class="sh_symbol">.</span>system<span class="sh_symbol">.
</span>watch("Power",success,null,{lowThreshold:0.2});
 function success(power) {
  alert("Low battery level: "+power.level);
}; 

The document currently specifies access to the power supply, CPU, heat and other sensors, network, A/V codecs, storage systems such as hard disks, optical media and RAM as well as input and output channels of a device. Applications using the API must request permission for retrieving device data from the device owner. At least that's what proposed in the draft's "Security and Privacy" section.

See also:

(crve)

Print Version | Send by email | Permalink: http://h-online.com/-921734
 


  • July's Community Calendar





The H Open

The H Security

The H Developer

The H Internet Toolkit