GetNotification method registers a callback function to receive notifications of system data. It takes a set of input parameters that specifies entity and key of System Attribute.
It is available in only asynchronous mode.
The following is an example for using GetNotification:
Asynchronous
event_id = sysinfo_handle.call("GetNotification",
{"Entity": u"Battery", "Key": u"ChargingStatus"},
callback=sysinfo_callback)
where, sysinfo_callback is user defined function.
The following table summarizes the specification of GetNotification:
| Interface | ISysinfo |
| Description | Registers a callback function for listening to notifications. |
| Response Model | Asynchronous |
| Pre-condition | ISysInfo Interface is loaded. |
| Post-condition | Returns the generic parameter system data on success. |
Input Parameters
Input parameter specifies the Entity and Key of system attribute, and system data.
|
Output Parameters
Output parameter returns an object that contains the requested information. It also contains ErrorCode and an ErrorMessage, if the operation fails.
|
Errors
The following table lists the error codes and their values:
|
Error Messages
The following table lists the error messages and their description:
|
Example
import scriptext
import e32
lock = e32.Ao_lock()
messaging_handle = scriptext.load('Service.SysInfo', 'ISysInfo')
def sysinfo_callback(trans_id, event_id, input_params):
if event_id != scriptext.EventCompleted:
# Check the event status
print "Error in retrieving required info"
print "Error code is: " + str(input_params["ReturnValue"]["ErrorCode"])
if "ErrorMessage" in input_params["ReturnValue"]:
print "Error message is: " + input_params["ReturnValue"]["ErrorMessage"]
else:
print "Current Battery charging value: " + str(input_params["ReturnValue"]["Status"])
lock.signal()
# Make a request to get notification
event_id = sysinfo_handle.call("GetNotification", {"Entity": u"Battery", "Key": u"ChargingStatus"}, callback=sysinfo_callback)
lock.wait()
See About this document... for information on suggesting changes.