4 # A Perl class to interface GSM devices as AT modems
5 # Basically just a few enhancements to Device::Gsm
8 $Device$Revision: 1.1 $ =~ /(\d+)\.(\d+)/;
13 @Device::Nokia::ISA = ('Device::Gsm');
16 # Who is the manufacturer of this device?
22 # Test if manufacturer code command is supported
23 if( $self->test_command('+CGMI') ) {
25 $self->atsend( 'AT+CGMI' . Device::Modem::CR );
26 ($ok, $man) = $self->parse_answer();
28 $self->log->write('info', 'manufacturer of this device appears to be ['.$man.']');
36 # What is the model of this device?
42 # Test if manufacturer code command is supported
43 if( $self->test_command('+CGMM') ) {
45 $self->atsend( 'AT+CGMM' . Device::Modem::CR );
46 ($code, $model) = $self->parse_answer();
48 $self->log->write('info', 'model of this device is ['.$model.']');
52 return $model || $code;
56 # Get mobile phone indicators
60 my($supported,$values,%results);
62 # Test if manufacturer code command is supported
63 if( $self->test_command('+CIND') ) {
64 $self->atsend( 'AT+CIND=?' . Device::Modem::CR );
65 ($_, $supported) = $self->parse_answer();
66 $supported =~ s/^\+CIND: //;
67 $self->atsend( 'AT+CIND?' . Device::Modem::CR );
68 ($_, $values) = $self->parse_answer();
69 $values =~ s/^\+CIND: //;
70 #@values = split (/,/, $values);
71 foreach (split (/,/, $values)) {
72 $supported =~ s/\("([^"]*)",\([^)]*\)\),?//;
75 $self->log->write('info', 'Indicator data retrieved (' . scalar(keys(%results)) . 'values)');
82 # Get mobile phone battery strength
84 sub battery_strength() {
86 # Error code, dBm (signal power), bit error rate
87 my($code, $strength, $line_power);
89 # Test if signal quality command is implemented
90 if( $self->test_command('+CBC') ) {
92 $self->atsend( 'AT+CBC' . Device::Modem::CR );
93 ($code, $strength) = $self->parse_answer();
95 if( $strength =~ /\+CBC: (\d+),(\d+)/ ) {
97 ($line_power, $strength) = ($1, $2);
99 $self->log->write('info', 'battery strength is ['.$strength.'], line power ['.$line_power.']');
103 $self->log->write('warn', 'cannot obtain battery strength');
109 $self->log->write('warn', 'battery strength command not supported!');
113 return wantarray ? ($line_power, $strength) : $strength;