ASNMTAP

 view release on metacpan or  search on metacpan

lib/ASNMTAP/Asnmtap/Plugins/Modem.pod  view on Meta::CPAN

=over 4

=item get_modem_request()

...

=over 4

=item asnmtapInherited

A required reference to an ASNMTAP::Asnmtap::Plugins or ASNMTAP::Asnmtap::Plugins::Nagios subclass

Through this way of working we inherited the command line option I<--debug>.

=item custom

optional, is an reference to your own custom defined function

=over 4

=item $asnmtapInherited

A required reference to an ASNMTAP::Asnmtap::Plugins or ASNMTAP::Asnmtap::Plugins::Nagios subclass

Through this way of working we inherited the command line option I<--debug>.

=item $parms

a reference to the get_modem_request () parameters

=item $modem

the MODEM object provides a reference to the currently used Device::Modem object

=item $ok

the latesd $ok status for dial() from Device::Modem

returns only success of connection. If modem answer contains C<CONNECT> string, it returns successful state, else false value is returned.

=item $answer

the latesd $answer (OK, RING, NO CARRIER, ERROR, NO DIALTONE, BUSY or undef) status from Device::Modem

 OK         : Command executed without errors
 RING       : Detected phone ring
 NO CARRIER : Link not established or disconnected
 ERROR      : Invalid command or command line too long
 NO DIALTONE: No dial tone, dialing not possible or wrong mode
 BUSY       : Remote terminal busy

returns the exact modem answer in the C<$answer> scalar. C<$answer> typically can contain strings like C<CONNECT 19200> or C<NO CARRIER>, C<BUSY>, ... all standard modem answers to a dial command.

=over 4

=item SKIP HANGUP

in a custom function you can set $$answer to 'SKIP HANGUP' for skipping the function $modem->hangup() on exit, needed for some PABX.

 sub actionOnModemResponse {
   my ($asnmtapInherited, $parms, $modem, $ok, $answer, $not_connected_guess, $arguments) = @_;

   my $debug = $asnmtapInherited->getOptionsValue ('debug');

   print 'ASNMTAP::Asnmtap::Plugins::Modem::get_modem_request::actionOnModemResponse: ', $asnmtapInherited->programDescription (), "\n" if ( $debug );

   unless ( $$ok ) {
     my $ATDT = 'ATDT'. $$parms{phonenumber};
     my $busy = ( $$answer eq $ATDT ? 1 : ( $$answer =~ /^$ATDT\s*(?:BUSY)?\s*$/ ? 2 : 0 ) );

     if ( $busy ) {
       $$answer = 'SKIP HANGUP' if ( $busy == 2 );
       print "OK: BUSY\n" if ($debug);
       $$ok = 1;
     } else {
       print "NOK: BUSY\n" if ($debug);
       $$not_connected_guess++;
       $asnmtapInherited->pluginValues ( { stateValue => $ERRORS{UNKNOWN}, alert => "Cannot dial [". $$parms{phonenumber} ."], answer: BUSY" }, $TYPE{APPEND} );
     }
   }

   return ( ( $$ok and ! $$not_connected_guess ) ? $ERRORS{OK} : $ERRORS{UNKNOWN} ); 
 }

=back

=item $not_connected_guess

default 0, everytime there is a problem we do $not_connected_guess++

=back

 sub actionOnModemResponse {
   my ($asnmtapInherited, $parms, $modem, $ok, $answer, $not_connected_guess) = @_;
   return ($returnCode);
 }

and now with customArguments:

 sub actionOnModemResponse {
   my ($asnmtapInherited, $parms, $modem, $ok, $answer, $not_connected_guess, $arguments) = @_;
   return ($returnCode);
 }

=item customArguments

optional, when you need to pass parameters to your own custom defined function, this can be done with customArguments.

 customArguments: SCALAR, ARRAY, HASH,
                  REF SCALAR, REF ARRAY, REF HASH

=back

=item windows

optional, scalar value 1 means force to be threated as Windows, 0 if under Linux or some kind of unix machine and undef means that we detect it automatically for you.

=item phonenumber

required, scalar [.0-9]

=item port

port where the modem connects to

if under Linux or some kind of unix machine: /dev/ttyS0, /dev/ttyS1, /dev/ttyS2 or /dev/ttyS3 or windows: com1, com2, com3 or com4

required, scalar, default /dev/ttyS0

=item baudrate

controls the speed of serial communications. However, here you can supply a custom value. Common speed values: 300, 1200, 2400, 4800, 9600, 19200, 38400, 57600, 115200.

optional, scalar, default 19200

=item databits

this tells how many bits your data word is composed of.

optional, scalar, between 5 and 8, default 8

=item initString

custom initialization string can be supplied instead of the built-in one

optional, scalar, default H0 Z S7=45 S0=0 Q0 V1 E0 &C0 X4

=item parity

controls how parity bit is generated and checked.

optional, scalar, can be even, odd or none, default none

=item stopbits

tells how many bits are used to identify the end of a data word.

optional, scalar, default 1

=item timeout



( run in 0.498 second using v1.01-cache-2.11-cpan-437f7b0c052 )