blib/lib/Net/Radio/Modem/Adapter/oFono.pm

filter: Statementstmt 81.8% 9 / 11 Branchbran n/a Conditioncond n/a MC/DCmcdc n/a Subroutinesub 100% 4 / 4 Podpod n/a totaltotal 86.6% 13 / 15 CC 1 SCAR 0.7
CC
1
Cov
82%
BEGIN
1.3
BEGIN
1.0
BEGIN
1.0
CRAP 1.1
↑ Summary
1 package Net::Radio::Modem::Adapter::oFono;
2  
3 1 ▶use 5.010;
Subroutine BEGIN: called CC=1 SCAR=0.0
4  
5 1 ▶use strict;
Subroutine BEGIN: called CC=1 SCAR=0.0
6 1 ▶use warnings;
Subroutine BEGIN: called CC=1 SCAR=0.0
7  
8 0 ▶use Net::Radio::oFono;
Subroutine BEGIN: called CC=1 SCAR=2.6
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<Net::Radio::Modem> and
37 L<Net::Radio::oFono>.
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<NetworkRegistration>,
102 C<SimManager>, C<Modem>.
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<bug-net-radio-modem-adapter-ofono at rt.cpan.org>, or through the web
124 interface at
125 L<http://rt.cpan.org/NoAuth/ReportBug.html?Queue=Net-Radio-Modem-Adapter-oFono>.
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<http://www.chiark.greenend.org.uk/~sgtatham/bugs.html>.
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<http://rt.cpan.org/NoAuth/Bugs.html?Dist=Net-Radio-Modem-Adapter-oFono>
146  
147 If you think you've found a bug then please read "How to Report Bugs
148 Effectively" by Simon Tatham:
149 L<http://www.chiark.greenend.org.uk/~sgtatham/bugs.html>.
150  
151 =item * AnnoCPAN: Annotated CPAN documentation
152  
153 L<http://annocpan.org/dist/Net-Radio-Modem-Adapter-oFono>
154  
155 =item * CPAN Ratings
156  
157 L<http://cpanratings.perl.org/d/Net-Radio-Modem-Adapter-oFono>
158  
159 =item * Search CPAN
160  
161 L<http://search.cpan.org/dist/Net-Radio-Modem-Adapter-oFono/>
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<< <rehsack at cpan.org> >>
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
↑ Summary