File Coverage

blib/lib/Net/Radio/Modem/Adapter/oFono.pm
Criterion Covered Total %
statement 10 12 83.3
branch n/a
condition n/a
subroutine 4 4 100.0
pod n/a
total 14 16 87.5


line stmt bran cond sub pod time code
1             package Net::Radio::Modem::Adapter::oFono;
2              
3 1     1   26518 use 5.010;
  1         3  
  1         40  
4              
5 1     1   6 use strict;
  1         3  
  1         32  
6 1     1   5 use warnings;
  1         6  
  1         27  
7              
8 1     1   470 use Net::Radio::oFono;
  0            
  0            
9              
10             =head1 NAME
11              
12             Net::Radio::Modem::Adapter::oFono - Adapter to use oFono controlled modems from Net::Radio::Modem
13              
14             =cut
15              
16             our $VERSION = '0.001';
17             use base qw(Net::Radio::Modem::Adapter);
18              
19             =head1 SYNOPSIS
20              
21             use Net::Radio::Modem;
22             my $modem = Net::Radio::Modem->new('oFono');
23             my @devs = $modem->get_modems();
24             my %modem_info => map {
25             $_ => {
26             'MNC' => $modem->get_modem_property($_, 'MNC'),
27             'MCC' => $modem->get_modem_property($_, 'MCC'),
28             'IMSI' => $modem->get_modem_property($_, 'IMSI'),
29             }
30             } @devs;
31              
32             =head1 METHODS
33              
34             =head2 new(;\%params)
35              
36             Instantiates new object proxying between L and
37             L.
38              
39             Supported paramaters:
40              
41             =over 8
42              
43             =item dbus_main_runs
44              
45             When set to a false value, all requests to Net::Radio::oFono are
46             done with enabled force flag. Otherwise the force flag is omitted
47             or set to a false value.
48              
49             =back
50              
51             =cut
52              
53             sub new
54             {
55             my ( $class, $params ) = @_;
56             my %instance;
57              
58             @instance{qw(dbus_main_runs serial_number path_pattern)} =
59             @$params{qw(dbus_main_runs serial_number path_pattern)};
60             $instance{ofono} = Net::Radio::oFono->new();
61              
62             return bless( \%instance, $class );
63             }
64              
65             =head2 get_modems
66              
67             Returns list of modems by object path known by oFono.
68              
69             =cut
70              
71             sub get_modems
72             {
73             my $self = $_[0];
74             return $self->{ofono}->get_modems( !( !$self->{dbus_main_runs} ) ); # avoid vim understands !! as m!!
75             }
76              
77             my %oFonoAliases = (
78             InternationalMobileSubscriberIdentity => 'SubscriberIdentity',
79             MobileSubscriberISDN => 'SubscriberNumbers',
80             IMSI => 'SubscriberIdentity',
81             MSISDN => 'SubscriberNumbers',
82              
83             );
84              
85             =head2 get_aliases
86              
87             Returns the associative list of known aliases.
88              
89             Overrides:
90              
91             InternationalMobileSubscriberIdentity => 'SubscriberIdentity',
92             MobileSubscriberISDN => 'SubscriberNumbers',
93              
94             =cut
95              
96             sub get_aliases { return ( $_[0]->SUPER::get_aliases(), %oFonoAliases ); }
97              
98             =head2 get_modem_property
99              
100             Returns specified property for given modem object path. Following modem
101             interfaces are queried (in that order): C,
102             C, C.
103              
104             =cut
105              
106             sub get_modem_property
107             {
108             my ( $self, $modem, $property ) = @_;
109              
110             for my $if_name (qw(NetworkRegistration SimManager Modem))
111             {
112             my $value;
113             my $if = $self->{ofono}->get_modem_interface( $modem, $if_name );
114             $if and $value = $if->GetProperty($property) and return $value;
115             }
116              
117             return;
118             }
119              
120             =head1 BUGS
121              
122             Please report any bugs or feature requests to
123             C, or through the web
124             interface at
125             L.
126             I will be notified, and then you'll automatically be notified of progress on
127             your bug as I make changes.
128              
129             If you think you've found a bug then please read "How to Report Bugs
130             Effectively" by Simon Tatham:
131             L.
132              
133             =head1 SUPPORT
134              
135             You can find documentation for this module with the perldoc command.
136              
137             perldoc Net::Radio::Modem::Adapter::oFono
138              
139             You can also look for information at:
140              
141             =over 4
142              
143             =item * RT: CPAN's request tracker (report bugs here)
144              
145             L
146              
147             If you think you've found a bug then please read "How to Report Bugs
148             Effectively" by Simon Tatham:
149             L.
150              
151             =item * AnnoCPAN: Annotated CPAN documentation
152              
153             L
154              
155             =item * CPAN Ratings
156              
157             L
158              
159             =item * Search CPAN
160              
161             L
162              
163             =back
164              
165             =head2 Where can I go for help with a concrete version?
166              
167             Bugs and feature requests are accepted against the latest version
168             only. To get patches for earlier versions, you need to get an
169             agreement with a developer of your choice - who may or not report the
170             issue and a suggested fix upstream (depends on the license you have
171             chosen).
172              
173             =head2 Business support and maintenance
174              
175             For business support you can contact Jens via his CPAN email
176             address rehsackATcpan.org. Please keep in mind that business
177             support is neither available for free nor are you eligible to
178             receive any support based on the license distributed with this
179             package.
180              
181             =head1 ACKNOWLEDGEMENTS
182              
183             =head1 AUTHOR
184              
185             Jens Rehsack, C<< >>
186              
187             =head1 LICENSE AND COPYRIGHT
188              
189             Copyright 2012 Jens Rehsack.
190              
191             This program is free software; you can redistribute it and/or modify it
192             under the terms of either: the GNU General Public License as published
193             by the Free Software Foundation; or the Artistic License.
194              
195             See http://dev.perl.org/licenses/ for more information.
196              
197             =cut
198              
199             1; # End of Net::Radio::Modem::Adapter::oFono