Accessing and modifying system information

The SystemInfo Service API of WRT 1.1 allows widgets to access and modify system information on a device. System information is represented as a set of system attributes. You can use the SystemInfo Service to create widgets that:

  • Read and modify system attribute values

  • Notify the user when system attribute values change

The system attributes are grouped into the following categories:

  • Battery

  • Connectivity

  • Device

  • Display

  • Features

  • General

  • Memory

  • Network

Only a few system attributes are modifiable and support change notifications. For more information about system attributes, see section System attributes

Accessing the API and supported methods

To create a service object for the SystemInfo Service API, use Service.SysInfo to identify the service provider and ISysInfo to identify the supported interface:

var so = device.getServiceObject("Service.SysInfo", "ISysInfo");

The ISysInfo interface provides the following methods:

  • GetInfo()

    Use the GetInfo() method to retrieve information about a system attribute.

  • SetInfo()

    Use the SetInfo() method to modify the value of a system attribute.

  • GetNotification()

    Use the GetNotification() method to receive a notification when the value of a system attribute is changed.

  • Cancel()

    Use the Cancel() method to cancel an ongoing asynchronous call. This method is valid for any asynchronous call made through the SystemInfo Service API.

Using the service in a widget

To access and modify system information using the SystemInfo Service API:

  1. Create a service object for the API using device.getServiceObject().

  2. Define the tasks you want to perform and choose the correct methods for them.

  3. Optionally, define how you want the results filtered.

  4. Define methods to process the results.

  5. Retrieve the results using the methods from step 2. Use asynchronous methods together with callback().

  6. Process the results using the methods defined in step 4.

For the complete source of a sample widget that demonstrates how to use this service, see the full example.