Net::Radio::oFono - Perl API to oFono
This is the frontend API to communicate with the oFono daemon over DBus.
use Net::Radio::oFono; my $oFono = Net::Radio::oFono->new(); my @modems = $oFono->get_modems(); foreach my $modem_path (@modems) { my $nwreg = $oFono->get_modem_interface("NetworkRegistration"); if( $nwreg ) { if( $nwreg->GetProperty("Status", 1) eq "registered" ) { say "Network for modem '" . $modem_path . "': ", $nwreg->GetProperty("Name"); } else { say "Network for modem '" . $modem_path . "' is in status ", $nwreg->GetProperty("Status"); } } else { say "No network registration for modem $modem_path"; } } # or use the event API my $oFono = Net::Radio::oFono->new( "ON_NETWORKREGISTRATION_PROPERTY_NAME_CHANGED" => sub { my ( $ofono, $event, $info ) = @_; my ( $modem_path, $name ) = @$info; say "Network for modem '" . $modem_path . "': ", $name; }, ... );
Net::Radio::oFono ISA Net::Radio::oFono::Helpers::EventMgr
Instances of Net::Radio::oFono can trigger following events (all characters are upper cased):
Triggered when a new modem is added. On initialization, it is triggered for each found modem.
Parameters:
D-Bus object path to the modem oject.
Triggered when a modem is removed. On destrcution, it is triggered for each remaining modem.
Triggered when an interface is added to a modem object. Modem interfaces depend on the modem states, for example the SimManager interface is always available when the modem is Powered.
The name of the propagated interface (eg. SimManager, RadioSettings, ...)
The advantage of this event compared to ON_MODEM_INTERFACE_ADDED is the delegation of the dispatching for different interfaces to the EventMgr.
Triggered when an interface is removed from a modem object. Modem interfaces depend on the modem states, for example the SimManager interface is always available when the modem is Powered and will be removed when the modem is turned off.
The advantage of this event compared to ON_MODEM_INTERFACE_REMOVED is the delegation of the dispatching for different interfaces to the EventMgr.
Triggered when a property of a modem object or modem interface object is changed. Modem is handled as any other interface for this event.
Typical name for such an event is ON_SIMMANAGER_PROPERTY_CHANGED.
Name of the changed property.
Typical name for such an event is ON_SIMMANAGER_PROPERTY_PINREQUIRED_CHANGED.
The advantage of this event compared to ON_ . $interface . _PROPERTY_CHANGED is the delegation of the dispatching for different properties to the EventMgr.
The value of the changed property.
Instantiates new oFono frontend accessor, registers specified events and initializes the modem manager. Events between frontend accessor and wrapper classes are separated.
Initializes the frontend accessor component:
Instantiates Net::Radio::oFono::Manager.
Instantiates Net::Radio::oFono::Modem for each already known modem device using "_add_modem".
Registers events ON_MODEM_ADDED and ON_MODEM_REMOVED on the manager.
ON_MODEM_ADDED
ON_MODEM_REMOVED
Internal method to properly add a modem to the frontend for accessing it.
Registers the events ON_PROPERTY_CHANGED and ON_PROPERTY_INTERFACES_CHANGED on the created object.
ON_PROPERTY_CHANGED
ON_PROPERTY_INTERFACES_CHANGED
Triggers the event ON_MODEM_ADDED when finished with that procedure.
Internal method to properly remove a modem from the frontend for accessing it.
Removes all interfaces objects from the modem using "_update_modem_interfaces" mocking and empty interface list and finally destroy the modem object itself.
Triggers ON_MODEM_REMOVED when the procedure has completed.
Internal function to adjust the interface objects of a remote modem objects. It iterates over the list of the available interfaces of the "Interfaces" property of the modem object to instantiate a new interface object for newly added ones and removes those objects of interfaces which are removed.
Triggers the events ON_MODEM_INTERFACE_ADDED and ON_MODEM_INTERFACE_ . uc($interface) . _ADDED for each newly instantiated interface. Triggers the events ON_MODEM_INTERFACE_REMOVED and ON_MODEM_INTERFACE_ . uc($interface) . _REMOVED for each interface which was removed.
ON_MODEM_INTERFACE_ADDED
ON_MODEM_INTERFACE_ . uc($interface) . _ADDED
ON_MODEM_INTERFACE_REMOVED
ON_MODEM_INTERFACE_ . uc($interface) . _REMOVED
Returns the list of object path's for currently known (and instantiated) modem objects.
TODO: implement way to get without Net::DBus::Reactor->main->run() ...
Returns the object for the specified interface on the given modem object. If either the modem device isn't known or the interface isn't available yet, it returns nothing.
Returns the object for the specified remote object on the given object path. Missing $if_name is replaced by $type.
If one of $type, $obj_path or $if_name isn't available, nothing is returned.
Invoked when the even ON_MODEM_ADDED is triggered by the modem manager and invokes "_add_modem" for the submitted object path.
Invoked when the even ON_MODEM_REMOVED is triggered by the modem manager and invokes "_remove_modem" for the submitted object path.
Triggered when a modem object changes it's list of available interfaces in addition to on_property_changed with Interfaces as name of the changed property.
Interfaces
Updates active interface objects using "_update_modem_interfaces".
Invoked when the even ON_ ... _ADDED is triggered by any modem interface with manager role when an embedded object is added. Triggers event "ON_" . uc($mgr_type) . "_" . uc($mgmt_type) . "_ADDED" with the object path of the created object as parameter.
ON_ ... _ADDED
"ON_" . uc($mgr_type) . "_" . uc($mgmt_type) . "_ADDED"
When a new context is added in ConnectionManager, the event ON_CONNECTIONMANAGER_CONTEXT_ADDED is triggered.
ON_CONNECTIONMANAGER_CONTEXT_ADDED
Invoked when the even ON_ ... _REMOVED is triggered by any modem interface with manager role when an embedded object is removed. Triggers event "ON_" . uc($mgr_type) . "_" . uc($mgmt_type) . "_ADDED" with the object path of the created object as parameter.
ON_ ... _REMOVED
When a context is removed from ConnectionManager, the event ON_CONNECTIONMANAGER_CONTEXT_REMOVED is triggered.
ON_CONNECTIONMANAGER_CONTEXT_REMOVED
Triggered when a modem object modifies a property.
Triggers ON_ . uc($interface) . _PROPERTY_CHANGED with modem path and property name as parameter as well as ON_ . uc($interface) . _PROPERTY_ . uc($property) . _CHANGED with modem path and property value as parameter.
ON_ . uc($interface) . _PROPERTY_CHANGED
ON_ . uc($interface) . _PROPERTY_ . uc($property) . _CHANGED
Triggered when any managed remote object fires an event which is not usually watched. This event is enriched with some information about the original sender:
The name of the event is modified by placing the upper cased basename of the triggering object interface directly behind the leading "ON_".
The list of arguments is prepended by the basename of the triggering object and the object path of the triggering object.
Use /get_remote_object($type,$obj_path;$if_name) to get the object instance.
Please report any bugs or feature requests to bug-net-radio-ofono at rt.cpan.org, or through the web interface at http://rt.cpan.org/NoAuth/ReportBug.html?Queue=Net-Radio-oFono. I will be notified, and then you'll automatically be notified of progress on your bug as I make changes.
bug-net-radio-ofono at rt.cpan.org
If you think you've found a bug then please read "How to Report Bugs Effectively" by Simon Tatham: http://www.chiark.greenend.org.uk/~sgtatham/bugs.html.
You can find documentation for this module with the perldoc command.
perldoc Net::Radio::oFono
You can also look for information at:
RT: CPAN's request tracker (report bugs here)
http://rt.cpan.org/NoAuth/Bugs.html?Dist=Net-Radio-oFono
AnnoCPAN: Annotated CPAN documentation
http://annocpan.org/dist/Net-Radio-oFono
CPAN Ratings
http://cpanratings.perl.org/d/Net-Radio-oFono
Search CPAN
http://search.cpan.org/dist/Net-Radio-oFono/
Bugs and feature requests are accepted against the latest version only. To get patches for earlier versions, you need to get an agreement with a developer of your choice - who may or not report the issue and a suggested fix upstream (depends on the license you have chosen).
For business support you can contact Jens via his CPAN email address rehsackATcpan.org. Please keep in mind that business support is neither available for free nor are you eligible to receive any support based on the license distributed with this package.
At first the guys from the oFono-Team shall be named: Marcel Holtmann and Denis Kenzior, the maintainers and all the people named in ofono/AUTHORS. Without their effort, there would no need for a Net::Radio::oFono module.
Further, Peter "ribasushi" Rabbitson helped a lot by providing hints and support how to make this API accessor a valuable CPAN module.
Jens Rehsack, <rehsack at cpan.org>
<rehsack at cpan.org>
Copyright 2012 Jens Rehsack.
This program is free software; you can redistribute it and/or modify it under the terms of either: the GNU General Public License as published by the Free Software Foundation; or the Artistic License.
See http://dev.perl.org/licenses/ for more information.
1 POD Error
The following errors were encountered while parsing the POD:
alternative text '/get_remote_object($type,$obj_path;$if_name)' contains non-escaped | or /
To install Net::Radio::oFono, copy and paste the appropriate command in to your terminal.
cpanm
cpanm Net::Radio::oFono
CPAN shell
perl -MCPAN -e shell install Net::Radio::oFono
For more information on module installation, please visit the detailed CPAN module installation guide.