| 1 | package Net::Radio::Modem; | ||||||||||||||||||||
| 2 | |||||||||||||||||||||
| 3 | 3 | ▶ | use 5.010; | ||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||
| 4 | |||||||||||||||||||||
| 5 | 3 | ▶ | use strict; | ||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||
| 6 | 3 | ▶ | use warnings; | ||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||
| 7 | |||||||||||||||||||||
| 8 | =head1 NAME | ||||||||||||||||||||
| 9 | |||||||||||||||||||||
| 10 | Net::Radio::Modem - Independently access radio network modems (such as 3GPP) | ||||||||||||||||||||
| 11 | |||||||||||||||||||||
| 12 | =cut | ||||||||||||||||||||
| 13 | |||||||||||||||||||||
| 14 | 3 | our $VERSION = '0.002'; | |||||||||||||||||||
| 15 | |||||||||||||||||||||
| 16 | =head1 SYNOPSIS | ||||||||||||||||||||
| 17 | |||||||||||||||||||||
| 18 | use Net::Radio::Modem; | ||||||||||||||||||||
| 19 | my $modem = Net::Radio::Modem->new('Static', '/test_0' => { | ||||||||||||||||||||
| 20 | MNC => '262', MCC => '02', IMSI => '262020555017753', | ||||||||||||||||||||
| 21 | LAC => ...}, '/test_1' => { ... } ... ); | ||||||||||||||||||||
| 22 | my @modems = $modem->get_modems(); # returns ('/test_0', 'test_1', ...) | ||||||||||||||||||||
| 23 | my $local_modem = grep { | ||||||||||||||||||||
| 24 | $modem->get_modem_property($_, 'MobileCountryCode') == 364 | ||||||||||||||||||||
| 25 | } @modems; # find the one for Bahamas | ||||||||||||||||||||
| 26 | |||||||||||||||||||||
| 27 | my $real_m = Net::Radio::Modem->new('oFono', { | ||||||||||||||||||||
| 28 | dbus_main_runs => 0 # fetch values, don't rely on dbus-signals | ||||||||||||||||||||
| 29 | }); | ||||||||||||||||||||
| 30 | my @rm = $real_m->get_modems(); | ||||||||||||||||||||
| 31 | my $o2sim = grep { | ||||||||||||||||||||
| 32 | $real_m->get_modem_property($_, 'MCC') == 262 # Germany | ||||||||||||||||||||
| 33 | and $real_m->get_modem_property($_, 'MNC') ~~ qw(07 08 11) # O2 | ||||||||||||||||||||
| 34 | } @rf; | ||||||||||||||||||||
| 35 | |||||||||||||||||||||
| 36 | =head1 METHODS | ||||||||||||||||||||
| 37 | |||||||||||||||||||||
| 38 | =head2 new($imp;@impl_args) | ||||||||||||||||||||
| 39 | |||||||||||||||||||||
| 40 | Instantiates new modem accessor from package C<Net::Radio::Modem::Adapter::$impl>. | ||||||||||||||||||||
| 41 | If no package C<Net::Radio::Modem::Adapter::$impl> is available, | ||||||||||||||||||||
| 42 | C<Net::Radio::Modem::Adapter::Null> is used. | ||||||||||||||||||||
| 43 | |||||||||||||||||||||
| 44 | C<@impl_args> are passed to the initialisation of the implementation class. | ||||||||||||||||||||
| 45 | |||||||||||||||||||||
| 46 | =cut | ||||||||||||||||||||
| 47 | |||||||||||||||||||||
| 48 | sub new | ||||||||||||||||||||
| 49 | 3 | ▶ | { | ||||||||||||||||||
|
Subroutine
new: called CC=2 SCAR=7.1
Pod
documented
| |||||||||||||||||||||
| 50 | 3 | my ( $class, $impl, @args ) = @_; | |||||||||||||||||||
| 51 | |||||||||||||||||||||
| 52 | 3 | my $self = bless( {}, $class ); | |||||||||||||||||||
| 53 | |||||||||||||||||||||
| 54 | 3 | my $impl_class = _load_plugin($impl); | |||||||||||||||||||
| 55 | 3 | ▶ | $impl_class //= _load_plugin("Net::Radio::Modem::Adapter::Null"); | ||||||||||||||||||
|
Condition33%1/3
$impl_class //= _load_plugin("Net::Radio::Modem::Adapter::Null")
MC/DC0%0/2
$impl_class //= _load_plugin("Net::Radio::Modem::Adapter::Null")
$impl_class
_load_plugin("Net::Radio::Modem::Adapter::Null")
Truth table33%1/3
A //= B
A= $impl_classB= _load_plugin("Net::Radio::Modem::Adapter::Null")
| |||||||||||||||||||||
| 56 | |||||||||||||||||||||
| 57 | 3 | $self->{impl_class} = $impl_class; | |||||||||||||||||||
| 58 | 3 | $self->{impl} = $impl_class->new(@args); | |||||||||||||||||||
| 59 | |||||||||||||||||||||
| 60 | 3 | return $self; | |||||||||||||||||||
| 61 | } | ||||||||||||||||||||
| 62 | |||||||||||||||||||||
| 63 | sub _load_plugin | ||||||||||||||||||||
| 64 | 6 | ▶ | { | ||||||||||||||||||
|
Subroutine
_load_plugin: called CC=6 SCAR=18.4
| |||||||||||||||||||||
| 65 | 6 | my $plugin = shift; | |||||||||||||||||||
| 66 | |||||||||||||||||||||
| 67 | 6 | ▶ | $plugin->isa("Net::Radio::Modem::Adapter") and return $plugin; | ||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||
| 68 | |||||||||||||||||||||
| 69 | 5 | ( my $module_file = "$plugin.pm" ) =~ s{::}{/}g; | |||||||||||||||||||
| 70 | 5 | ▶ | defined $INC{$module_file} and return; | ||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||
| 71 | |||||||||||||||||||||
| 72 | 5 | eval { require $module_file; }; | |||||||||||||||||||
| 73 | 5 | ▶ | if ($@) | ||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||
| 74 | { | ||||||||||||||||||||
| 75 | 3 | ▶ | $plugin =~ m/Net::Radio::Modem::Adapter/ | ||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||
| 76 | or return _load_plugin("Net::Radio::Modem::Adapter::$plugin"); | ||||||||||||||||||||
| 77 | } | ||||||||||||||||||||
| 78 | else | ||||||||||||||||||||
| 79 | { | ||||||||||||||||||||
| 80 | 2 | ▶ | $plugin->isa("Net::Radio::Modem::Adapter") and return $plugin; | ||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||
| 81 | } | ||||||||||||||||||||
| 82 | |||||||||||||||||||||
| 83 | 0 | return; | |||||||||||||||||||
| 84 | } | ||||||||||||||||||||
| 85 | |||||||||||||||||||||
| 86 | =head2 get_modems() | ||||||||||||||||||||
| 87 | |||||||||||||||||||||
| 88 | Provides a list of modems available. | ||||||||||||||||||||
| 89 | |||||||||||||||||||||
| 90 | =cut | ||||||||||||||||||||
| 91 | |||||||||||||||||||||
| 92 | sub get_modems | ||||||||||||||||||||
| 93 | 3 | ▶ | { | ||||||||||||||||||
|
Subroutine
get_modems: called CC=1 SCAR=0.0
Pod
documented
| |||||||||||||||||||||
| 94 | 3 | return $_[0]->{impl}->get_modems(); | |||||||||||||||||||
| 95 | } | ||||||||||||||||||||
| 96 | |||||||||||||||||||||
| 97 | =head2 get_modem_property($modem,$property) | ||||||||||||||||||||
| 98 | |||||||||||||||||||||
| 99 | Provides the value of given property for specified modem. | ||||||||||||||||||||
| 100 | Property can be an L<Net::Radio::Modem::Adapter/Alias|alias name>. | ||||||||||||||||||||
| 101 | |||||||||||||||||||||
| 102 | =cut | ||||||||||||||||||||
| 103 | |||||||||||||||||||||
| 104 | sub get_modem_property | ||||||||||||||||||||
| 105 | 40 | ▶ | { | ||||||||||||||||||
|
Subroutine
get_modem_property: called CC=1 SCAR=0.0
Pod
documented
| |||||||||||||||||||||
| 106 | 40 | my $self = $_[0]; | |||||||||||||||||||
| 107 | 40 | my $modem = $_[1]; | |||||||||||||||||||
| 108 | 40 | my $property = $self->{impl}->get_alias_for( $_[2] ); | |||||||||||||||||||
| 109 | 40 | $self->{impl}->get_modem_property( $modem, $property ); | |||||||||||||||||||
| 110 | } | ||||||||||||||||||||
| 111 | |||||||||||||||||||||
| 112 | =head1 BUGS | ||||||||||||||||||||
| 113 | |||||||||||||||||||||
| 114 | Please report any bugs or feature requests to C<bug-net-radio-modem at rt.cpan.org>, or through | ||||||||||||||||||||
| 115 | the web interface at L<http://rt.cpan.org/NoAuth/ReportBug.html?Queue=Net-Radio-Modem>. I will be notified, and then you'll | ||||||||||||||||||||
| 116 | automatically be notified of progress on your bug as I make changes. | ||||||||||||||||||||
| 117 | |||||||||||||||||||||
| 118 | If you think you've found a bug then please read "How to Report Bugs | ||||||||||||||||||||
| 119 | Effectively" by Simon Tatham: | ||||||||||||||||||||
| 120 | L<http://www.chiark.greenend.org.uk/~sgtatham/bugs.html>. | ||||||||||||||||||||
| 121 | |||||||||||||||||||||
| 122 | =head1 SUPPORT | ||||||||||||||||||||
| 123 | |||||||||||||||||||||
| 124 | You can find documentation for this module with the perldoc command. | ||||||||||||||||||||
| 125 | |||||||||||||||||||||
| 126 | perldoc Net::Radio::Modem | ||||||||||||||||||||
| 127 | |||||||||||||||||||||
| 128 | You can also look for information at: | ||||||||||||||||||||
| 129 | |||||||||||||||||||||
| 130 | =over 4 | ||||||||||||||||||||
| 131 | |||||||||||||||||||||
| 132 | =item * RT: CPAN's request tracker (report bugs here) | ||||||||||||||||||||
| 133 | |||||||||||||||||||||
| 134 | L<http://rt.cpan.org/NoAuth/Bugs.html?Dist=Net-Radio-Modem> | ||||||||||||||||||||
| 135 | |||||||||||||||||||||
| 136 | If you think you've found a bug then please read "How to Report Bugs | ||||||||||||||||||||
| 137 | Effectively" by Simon Tatham: | ||||||||||||||||||||
| 138 | L<http://www.chiark.greenend.org.uk/~sgtatham/bugs.html>. | ||||||||||||||||||||
| 139 | |||||||||||||||||||||
| 140 | =item * AnnoCPAN: Annotated CPAN documentation | ||||||||||||||||||||
| 141 | |||||||||||||||||||||
| 142 | L<http://annocpan.org/dist/Net-Radio-Modem> | ||||||||||||||||||||
| 143 | |||||||||||||||||||||
| 144 | =item * CPAN Ratings | ||||||||||||||||||||
| 145 | |||||||||||||||||||||
| 146 | L<http://cpanratings.perl.org/d/Net-Radio-Modem> | ||||||||||||||||||||
| 147 | |||||||||||||||||||||
| 148 | =item * Search CPAN | ||||||||||||||||||||
| 149 | |||||||||||||||||||||
| 150 | L<http://search.cpan.org/dist/Net-Radio-Modem/> | ||||||||||||||||||||
| 151 | |||||||||||||||||||||
| 152 | =back | ||||||||||||||||||||
| 153 | |||||||||||||||||||||
| 154 | =head2 Where can I go for help with a concrete version? | ||||||||||||||||||||
| 155 | |||||||||||||||||||||
| 156 | Bugs and feature requests are accepted against the latest version | ||||||||||||||||||||
| 157 | only. To get patches for earlier versions, you need to get an | ||||||||||||||||||||
| 158 | agreement with a developer of your choice - who may or not report the | ||||||||||||||||||||
| 159 | issue and a suggested fix upstream (depends on the license you have | ||||||||||||||||||||
| 160 | chosen). | ||||||||||||||||||||
| 161 | |||||||||||||||||||||
| 162 | =head2 Business support and maintenance | ||||||||||||||||||||
| 163 | |||||||||||||||||||||
| 164 | For business support you can contact Jens via his CPAN email | ||||||||||||||||||||
| 165 | address rehsackATcpan.org. Please keep in mind that business | ||||||||||||||||||||
| 166 | support is neither available for free nor are you eligible to | ||||||||||||||||||||
| 167 | receive any support based on the license distributed with this | ||||||||||||||||||||
| 168 | package. | ||||||||||||||||||||
| 169 | |||||||||||||||||||||
| 170 | =head1 ACKNOWLEDGEMENTS | ||||||||||||||||||||
| 171 | |||||||||||||||||||||
| 172 | =head1 ROADMAP | ||||||||||||||||||||
| 173 | |||||||||||||||||||||
| 174 | Following things will be nice to have: | ||||||||||||||||||||
| 175 | |||||||||||||||||||||
| 176 | =over 4 | ||||||||||||||||||||
| 177 | |||||||||||||||||||||
| 178 | =item * | ||||||||||||||||||||
| 179 | |||||||||||||||||||||
| 180 | List of features useful in a perl module (excluding NIH features) | ||||||||||||||||||||
| 181 | |||||||||||||||||||||
| 182 | =item * | ||||||||||||||||||||
| 183 | |||||||||||||||||||||
| 184 | Class hierarchy with wrapper implementation of required functions | ||||||||||||||||||||
| 185 | using a configurable adapter class hierarchy. | ||||||||||||||||||||
| 186 | |||||||||||||||||||||
| 187 | =item * | ||||||||||||||||||||
| 188 | |||||||||||||||||||||
| 189 | Implement I<Composite> and I<Mediator> pattern to allow mocking | ||||||||||||||||||||
| 190 | of specific values and/or fallback values ... | ||||||||||||||||||||
| 191 | |||||||||||||||||||||
| 192 | =item * | ||||||||||||||||||||
| 193 | |||||||||||||||||||||
| 194 | Patches | ||||||||||||||||||||
| 195 | |||||||||||||||||||||
| 196 | =back | ||||||||||||||||||||
| 197 | |||||||||||||||||||||
| 198 | =head1 AUTHOR | ||||||||||||||||||||
| 199 | |||||||||||||||||||||
| 200 | Jens Rehsack, C<< <rehsack at cpan.org> >> | ||||||||||||||||||||
| 201 | |||||||||||||||||||||
| 202 | =head1 LICENSE AND COPYRIGHT | ||||||||||||||||||||
| 203 | |||||||||||||||||||||
| 204 | Copyright 2012 Jens Rehsack. | ||||||||||||||||||||
| 205 | |||||||||||||||||||||
| 206 | This program is free software; you can redistribute it and/or modify it | ||||||||||||||||||||
| 207 | under the terms of either: the GNU General Public License as published | ||||||||||||||||||||
| 208 | by the Free Software Foundation; or the Artistic License. | ||||||||||||||||||||
| 209 | |||||||||||||||||||||
| 210 | See http://dev.perl.org/licenses/ for more information. | ||||||||||||||||||||
| 211 | |||||||||||||||||||||
| 212 | |||||||||||||||||||||
| 213 | =cut | ||||||||||||||||||||
| 214 | |||||||||||||||||||||
| 215 | 3 | 1; # End of Net::Radio::Modem | |||||||||||||||||||