| 1 | package Net::Radio::Modem::Adapter::Static; | ||||||||||||||||||||||||||||||||
| 2 | |||||||||||||||||||||||||||||||||
| 3 | 2 | ▶ | use 5.010; | ||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||
| 4 | |||||||||||||||||||||||||||||||||
| 5 | 2 | ▶ | use strict; | ||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||
| 6 | 2 | ▶ | use warnings; | ||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||
| 7 | |||||||||||||||||||||||||||||||||
| 8 | 2 | ▶ | use Carp qw(croak); | ||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||
| 9 | |||||||||||||||||||||||||||||||||
| 10 | =head1 NAME | ||||||||||||||||||||||||||||||||
| 11 | |||||||||||||||||||||||||||||||||
| 12 | Net::Radio::Modem::Adapter::Static - static modem information adapter | ||||||||||||||||||||||||||||||||
| 13 | |||||||||||||||||||||||||||||||||
| 14 | =head1 DESCRIPTION | ||||||||||||||||||||||||||||||||
| 15 | |||||||||||||||||||||||||||||||||
| 16 | Allows mocking by defining static information for radio modems. | ||||||||||||||||||||||||||||||||
| 17 | |||||||||||||||||||||||||||||||||
| 18 | =head1 SYNOPSIS | ||||||||||||||||||||||||||||||||
| 19 | |||||||||||||||||||||||||||||||||
| 20 | use Net::Radio::Modem; | ||||||||||||||||||||||||||||||||
| 21 | my $modem = Net::Radio::Modem->new('Static', | ||||||||||||||||||||||||||||||||
| 22 | '/test_0' => { | ||||||||||||||||||||||||||||||||
| 23 | MNC => '262', MCC => '02', IMSI => '262020555017753', | ||||||||||||||||||||||||||||||||
| 24 | LAC => ...}, | ||||||||||||||||||||||||||||||||
| 25 | '/test_1' => { ... } ... ); | ||||||||||||||||||||||||||||||||
| 26 | my @modems = $modem->get_modems(); # returns ('/test_0', 'test_1', ...) | ||||||||||||||||||||||||||||||||
| 27 | my $local_modem = grep { | ||||||||||||||||||||||||||||||||
| 28 | $modem->get_modem_property($_, 'MobileCountryCode') == 364 | ||||||||||||||||||||||||||||||||
| 29 | } @modems; # find the one for Bahamas | ||||||||||||||||||||||||||||||||
| 30 | |||||||||||||||||||||||||||||||||
| 31 | To fill in reasonable value, see | ||||||||||||||||||||||||||||||||
| 32 | |||||||||||||||||||||||||||||||||
| 33 | =over 4 | ||||||||||||||||||||||||||||||||
| 34 | |||||||||||||||||||||||||||||||||
| 35 | =item * | ||||||||||||||||||||||||||||||||
| 36 | |||||||||||||||||||||||||||||||||
| 37 | L<http://en.wikipedia.org/wiki/List_of_mobile_country_codes> | ||||||||||||||||||||||||||||||||
| 38 | |||||||||||||||||||||||||||||||||
| 39 | =item * | ||||||||||||||||||||||||||||||||
| 40 | |||||||||||||||||||||||||||||||||
| 41 | L<http://en.wikipedia.org/wiki/Mobile_Network_Code> | ||||||||||||||||||||||||||||||||
| 42 | |||||||||||||||||||||||||||||||||
| 43 | =back | ||||||||||||||||||||||||||||||||
| 44 | |||||||||||||||||||||||||||||||||
| 45 | =cut | ||||||||||||||||||||||||||||||||
| 46 | |||||||||||||||||||||||||||||||||
| 47 | 2 | our $VERSION = '0.002'; | |||||||||||||||||||||||||||||||
| 48 | 2 | ▶ | use base qw(Net::Radio::Modem::Adapter); | ||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||
| 49 | |||||||||||||||||||||||||||||||||
| 50 | =head1 METHODS | ||||||||||||||||||||||||||||||||
| 51 | |||||||||||||||||||||||||||||||||
| 52 | =head2 new | ||||||||||||||||||||||||||||||||
| 53 | |||||||||||||||||||||||||||||||||
| 54 | Instantiates new static modem adapter. | ||||||||||||||||||||||||||||||||
| 55 | |||||||||||||||||||||||||||||||||
| 56 | B<TODO>: clone (depending on refcount?) provided information to allow | ||||||||||||||||||||||||||||||||
| 57 | further modification in caller. | ||||||||||||||||||||||||||||||||
| 58 | |||||||||||||||||||||||||||||||||
| 59 | =cut | ||||||||||||||||||||||||||||||||
| 60 | |||||||||||||||||||||||||||||||||
| 61 | sub new | ||||||||||||||||||||||||||||||||
| 62 | 2 | ▶ | { | ||||||||||||||||||||||||||||||
|
Subroutine
new: called CC=6 SCAR=18.1
Pod
documented
| |||||||||||||||||||||||||||||||||
| 63 | 2 | my $class = shift; | |||||||||||||||||||||||||||||||
| 64 | 2 | my %params; | |||||||||||||||||||||||||||||||
| 65 | |||||||||||||||||||||||||||||||||
| 66 | 2 | ▶ | if ( scalar(@_) == 1 and ref( $_[0] ) eq "HASH" ) | ||||||||||||||||||||||||||||||
|
Branch: 2 branches
Condition66%2/3
scalar @_ == 1 and ref $_[0] eq "HASH"
MC/DC50%1/2
scalar @_ == 1 and ref $_[0] eq "HASH"
scalar @_ == 1
ref $_[0] eq "HASH"
Truth table66%2/3
A and B
A= scalar @_ == 1B= ref $_[0] eq "HASH"
| |||||||||||||||||||||||||||||||||
| 67 | { | ||||||||||||||||||||||||||||||||
| 68 | 1 | %params = %{ $_[0] }; | |||||||||||||||||||||||||||||||
| 69 | } | ||||||||||||||||||||||||||||||||
| 70 | elsif ( 0 == ( scalar(@_) % 2 ) ) | ||||||||||||||||||||||||||||||||
| 71 | { | ||||||||||||||||||||||||||||||||
| 72 | 1 | %params = @_; | |||||||||||||||||||||||||||||||
| 73 | } | ||||||||||||||||||||||||||||||||
| 74 | else | ||||||||||||||||||||||||||||||||
| 75 | { | ||||||||||||||||||||||||||||||||
| 76 | 0 | croak("Expecting hash or hash reference as argument(s)"); | |||||||||||||||||||||||||||||||
| 77 | } | ||||||||||||||||||||||||||||||||
| 78 | |||||||||||||||||||||||||||||||||
| 79 | 2 | my %info; | |||||||||||||||||||||||||||||||
| 80 | 2 | foreach my $modem ( keys %params ) | |||||||||||||||||||||||||||||||
| 81 | { | ||||||||||||||||||||||||||||||||
| 82 | 10 | foreach my $property ( keys %{ $params{$modem} } ) | |||||||||||||||||||||||||||||||
| 83 | { | ||||||||||||||||||||||||||||||||
| 84 | 36 | my $value = $params{$modem}->{$property}; | |||||||||||||||||||||||||||||||
| 85 | 36 | $property = __PACKAGE__->get_alias_for($property); | |||||||||||||||||||||||||||||||
| 86 | 36 | $info{$modem}->{$property} = $value; | |||||||||||||||||||||||||||||||
| 87 | } | ||||||||||||||||||||||||||||||||
| 88 | } | ||||||||||||||||||||||||||||||||
| 89 | |||||||||||||||||||||||||||||||||
| 90 | 2 | return bless( { config => \%info }, $class ); | |||||||||||||||||||||||||||||||
| 91 | } | ||||||||||||||||||||||||||||||||
| 92 | |||||||||||||||||||||||||||||||||
| 93 | =head2 get_modems | ||||||||||||||||||||||||||||||||
| 94 | |||||||||||||||||||||||||||||||||
| 95 | Returns the keys of given initialisation hash as list of known modems. | ||||||||||||||||||||||||||||||||
| 96 | |||||||||||||||||||||||||||||||||
| 97 | =cut | ||||||||||||||||||||||||||||||||
| 98 | |||||||||||||||||||||||||||||||||
| 99 | sub get_modems | ||||||||||||||||||||||||||||||||
| 100 | 2 | ▶ | { | ||||||||||||||||||||||||||||||
|
Subroutine
get_modems: called CC=1 SCAR=0.0
Pod
documented
| |||||||||||||||||||||||||||||||||
| 101 | 2 | return keys %{ $_[0]->{config} }; | |||||||||||||||||||||||||||||||
| 102 | } | ||||||||||||||||||||||||||||||||
| 103 | |||||||||||||||||||||||||||||||||
| 104 | =head2 get_modem_property | ||||||||||||||||||||||||||||||||
| 105 | |||||||||||||||||||||||||||||||||
| 106 | Return the specified modem property, when known. Empty value otherwise. | ||||||||||||||||||||||||||||||||
| 107 | |||||||||||||||||||||||||||||||||
| 108 | =cut | ||||||||||||||||||||||||||||||||
| 109 | |||||||||||||||||||||||||||||||||
| 110 | sub get_modem_property | ||||||||||||||||||||||||||||||||
| 111 | 40 | ▶ | { | ||||||||||||||||||||||||||||||
|
Subroutine
get_modem_property: called CC=3 SCAR=14.2
Pod
documented
| |||||||||||||||||||||||||||||||||
| 112 | 40 | my ( $self, $modem, $property ) = @_; | |||||||||||||||||||||||||||||||
| 113 | |||||||||||||||||||||||||||||||||
| 114 | defined( $self->{config}->{$modem} ) | ||||||||||||||||||||||||||||||||
| 115 | and defined( $self->{config}->{$modem}->{$property} ) | ||||||||||||||||||||||||||||||||
| 116 | 40 | ▶ | and return $self->{config}->{$modem}->{$property}; | ||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition33%1/3
defined $self->{"config"}{$modem} and defined $self->{"config"}{$modem}{$property}
MC/DC0%0/2
defined $self->{"config"}{$modem} and defined $self->{"config"}{$modem}{$property}
defined $self->{"config"}{$modem}
defined $self->{"config"}{$modem}{$property}
Truth table33%1/3
A and B
A= defined $self->{"config"}{$modem}B= defined $self->{"config"}{$modem}{$property}
| |||||||||||||||||||||||||||||||||
| 117 | |||||||||||||||||||||||||||||||||
| 118 | 0 | return; | |||||||||||||||||||||||||||||||
| 119 | } | ||||||||||||||||||||||||||||||||
| 120 | |||||||||||||||||||||||||||||||||
| 121 | =head1 BUGS | ||||||||||||||||||||||||||||||||
| 122 | |||||||||||||||||||||||||||||||||
| 123 | Please report any bugs or feature requests to C<bug-net-radio-modem at rt.cpan.org>, or through | ||||||||||||||||||||||||||||||||
| 124 | the web interface at L<http://rt.cpan.org/NoAuth/ReportBug.html?Queue=Net-Radio-Modem>. I will be notified, and then you'll | ||||||||||||||||||||||||||||||||
| 125 | automatically be notified of progress on your bug as I make changes. | ||||||||||||||||||||||||||||||||
| 126 | |||||||||||||||||||||||||||||||||
| 127 | If you think you've found a bug then please read "How to Report Bugs | ||||||||||||||||||||||||||||||||
| 128 | Effectively" by Simon Tatham: | ||||||||||||||||||||||||||||||||
| 129 | L<http://www.chiark.greenend.org.uk/~sgtatham/bugs.html>. | ||||||||||||||||||||||||||||||||
| 130 | |||||||||||||||||||||||||||||||||
| 131 | =head1 SUPPORT | ||||||||||||||||||||||||||||||||
| 132 | |||||||||||||||||||||||||||||||||
| 133 | You can find documentation for this module with the perldoc command. | ||||||||||||||||||||||||||||||||
| 134 | |||||||||||||||||||||||||||||||||
| 135 | perldoc Net::Radio::Modem | ||||||||||||||||||||||||||||||||
| 136 | |||||||||||||||||||||||||||||||||
| 137 | You can also look for information at: | ||||||||||||||||||||||||||||||||
| 138 | |||||||||||||||||||||||||||||||||
| 139 | =over 4 | ||||||||||||||||||||||||||||||||
| 140 | |||||||||||||||||||||||||||||||||
| 141 | =item * RT: CPAN's request tracker (report bugs here) | ||||||||||||||||||||||||||||||||
| 142 | |||||||||||||||||||||||||||||||||
| 143 | L<http://rt.cpan.org/NoAuth/Bugs.html?Dist=Net-Radio-Modem> | ||||||||||||||||||||||||||||||||
| 144 | |||||||||||||||||||||||||||||||||
| 145 | If you think you've found a bug then please read "How to Report Bugs | ||||||||||||||||||||||||||||||||
| 146 | Effectively" by Simon Tatham: | ||||||||||||||||||||||||||||||||
| 147 | L<http://www.chiark.greenend.org.uk/~sgtatham/bugs.html>. | ||||||||||||||||||||||||||||||||
| 148 | |||||||||||||||||||||||||||||||||
| 149 | =item * AnnoCPAN: Annotated CPAN documentation | ||||||||||||||||||||||||||||||||
| 150 | |||||||||||||||||||||||||||||||||
| 151 | L<http://annocpan.org/dist/Net-Radio-Modem> | ||||||||||||||||||||||||||||||||
| 152 | |||||||||||||||||||||||||||||||||
| 153 | =item * CPAN Ratings | ||||||||||||||||||||||||||||||||
| 154 | |||||||||||||||||||||||||||||||||
| 155 | L<http://cpanratings.perl.org/d/Net-Radio-Modem> | ||||||||||||||||||||||||||||||||
| 156 | |||||||||||||||||||||||||||||||||
| 157 | =item * Search CPAN | ||||||||||||||||||||||||||||||||
| 158 | |||||||||||||||||||||||||||||||||
| 159 | L<http://search.cpan.org/dist/Net-Radio-Modem/> | ||||||||||||||||||||||||||||||||
| 160 | |||||||||||||||||||||||||||||||||
| 161 | =back | ||||||||||||||||||||||||||||||||
| 162 | |||||||||||||||||||||||||||||||||
| 163 | =head2 Where can I go for help with a concrete version? | ||||||||||||||||||||||||||||||||
| 164 | |||||||||||||||||||||||||||||||||
| 165 | Bugs and feature requests are accepted against the latest version | ||||||||||||||||||||||||||||||||
| 166 | only. To get patches for earlier versions, you need to get an | ||||||||||||||||||||||||||||||||
| 167 | agreement with a developer of your choice - who may or not report the | ||||||||||||||||||||||||||||||||
| 168 | issue and a suggested fix upstream (depends on the license you have | ||||||||||||||||||||||||||||||||
| 169 | chosen). | ||||||||||||||||||||||||||||||||
| 170 | |||||||||||||||||||||||||||||||||
| 171 | =head2 Business support and maintenance | ||||||||||||||||||||||||||||||||
| 172 | |||||||||||||||||||||||||||||||||
| 173 | For business support you can contact Jens via his CPAN email | ||||||||||||||||||||||||||||||||
| 174 | address rehsackATcpan.org. Please keep in mind that business | ||||||||||||||||||||||||||||||||
| 175 | support is neither available for free nor are you eligible to | ||||||||||||||||||||||||||||||||
| 176 | receive any support based on the license distributed with this | ||||||||||||||||||||||||||||||||
| 177 | package. | ||||||||||||||||||||||||||||||||
| 178 | |||||||||||||||||||||||||||||||||
| 179 | =head1 ACKNOWLEDGEMENTS | ||||||||||||||||||||||||||||||||
| 180 | |||||||||||||||||||||||||||||||||
| 181 | =head1 AUTHOR | ||||||||||||||||||||||||||||||||
| 182 | |||||||||||||||||||||||||||||||||
| 183 | Jens Rehsack, C<< <rehsack at cpan.org> >> | ||||||||||||||||||||||||||||||||
| 184 | |||||||||||||||||||||||||||||||||
| 185 | =head1 LICENSE AND COPYRIGHT | ||||||||||||||||||||||||||||||||
| 186 | |||||||||||||||||||||||||||||||||
| 187 | Copyright 2012 Jens Rehsack. | ||||||||||||||||||||||||||||||||
| 188 | |||||||||||||||||||||||||||||||||
| 189 | This program is free software; you can redistribute it and/or modify it | ||||||||||||||||||||||||||||||||
| 190 | under the terms of either: the GNU General Public License as published | ||||||||||||||||||||||||||||||||
| 191 | by the Free Software Foundation; or the Artistic License. | ||||||||||||||||||||||||||||||||
| 192 | |||||||||||||||||||||||||||||||||
| 193 | See http://dev.perl.org/licenses/ for more information. | ||||||||||||||||||||||||||||||||
| 194 | |||||||||||||||||||||||||||||||||
| 195 | =cut | ||||||||||||||||||||||||||||||||
| 196 | |||||||||||||||||||||||||||||||||
| 197 | 2 | 1; | |||||||||||||||||||||||||||||||