The London Perl and Raku Workshop takes place on 26th Oct 2024. If your company depends on Perl, please consider sponsoring and/or attending.

NAME

Device::Modem - Perl extension to talk to AT devices connected via serial port

WARNING

   This is C<PRE-ALPHA> software, still needs extensive testing and
   support for generic AT commads, so use it at your own risk,
   and without C<ANY> warranty! Have fun.

SYNOPSIS

  use Device::Modem;

  my $modem = new Device::Modem( port => '/dev/ttyS1', baud => 9600 )

  if( $modem->connect() ) {
      print "connected!\n";
  } else {
      print "sorry, no connection with serial port!\n';
  }

  $modem->attention();          # send `attention' sequence (+++)
 
  $modem->dial( '022704690' );  # dial number (*NOT WORKING YET*)
 
  $modem->echo(1);              # enable local echo
  $modem->echo(0);              # disable it

  $modem->offhook();            # Take off hook (ready to dial)
  $modem->hangup();             # returns modem answer
  $modem->reset();              # hangup + attention + restore setting 0 (Z0)

  $modem->restore_factory_settings();
                                # Handle with care!

  $modem->send_init_string();   # Send initialization string
                                # Now this is fixed to `ATZ0H0V1Q0E0'


  $modem->repeat();             # Repeat last command

  $modem->verbose(0);           # Modem responses are numerical
  $modem->verbose(1);           # Normal text responses
 
  #
  # Some raw at commands
  #
  $modem->atsend( 'ATH0' );
  print $modem->answer();

  $modem->atsend( 'ATDT01234567' . Device::Modem::CR );
  print $modem->answer();

DESCRIPTION

Device::Modem class implements basic AT device abstraction. It is meant to be inherited by sub classes (as Device::Gsm), which are based on serial connections.

REQUIRES

Device::SerialPort

EXPORT

None

TO-DO

  • AutoScan

    An AT command script with all interesting commands is run when `autoscan' is invoked, creating a `profile' of the current device, with list of supported commands, and database of brand/model-specific commands

  • Time::HiRes

    Check if Time::HiRes module is installed and use it to wait milliseconds instead of whole seconds

  • Many more to come!

AUTHOR

Cosimo Streppone, cosimo@cpan.org

SEE ALSO

Device::SerialPort(3), perl(1).