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::Gsm - Perl extension to interface GSM cellular / modems

WARNING

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

SYNOPSIS

  use Device::Gsm;

  my $gsm = new Device::Gsm( port => '/dev/ttyS1', pin => 'xxxx' );

  if( $gsm->connect() ) {
      print "connected!\n";
  } else {
      print "sorry, no connection with gsm phone on serial port!\n';
  }
 
  # Register to GSM network (you must supply PIN number in above new() call)
  $gsm->register();
 
  # Get the manufacturer and model code of device
  my $mnf   = $gsm->manufacturer();
  my $model = $gsm->model();
  print 'soft version is ", $gsm->software_version(), "\n";

  my $imei = $gsm->imei() or
        $imei = $gsm->serial_number();
 
  # Test for command support
  if( $self->test_command('CGMI') ) {
      # `AT+CGMI' is supported!
  } else {
      # No luck, CGMI command not available
  }
 
  print 'Service number is now: ', $gsm->service_number(), "\n";
  $gsm->service_number( '+001505050' );   # Sets new number
  
  # Send quickly a short text message
  $modem->send_sms(
      recipient => '+3934910203040',
      content   => 'Hello world! from Device::Gsm'
  );

  # The long way...
  $modem->send_sms(

      recipient => '34910203040',
      content   => 'Hello world again, with more args',

      # SMS Class (can be `normal' or `flash')
      # `flash' mode delivers instantly!
      class     => 'normal',

      # SMS sending mode
      # try `text' or old phones or GSM modems
      # `pdu' is the default nowadays
      mode      => 'pdu'
  );
 

DESCRIPTION

Device::Gsm class implements basic GSM functions, network registration and SMS sending.

This class supports also PDU mode to send SMS messages, and should be fairly usable. I'm developing and testing it under Linux RedHat 7.1 with a 16550 serial port and Siemens C35i / C45 GSM phones attached with a Siemens-compatible serial cable.

Please be kind to the universe and contact me if you have troubles or you are interested in this.

REQUIRES

  • Device::Modem, which in turn requires

  • Device::SerialPort (or Win32::SerialPort on Windows machines)

EXPORT

None

TO-DO

Validity Period

Support validity period option on SMS sending. Tells how much time the SMS Service Center must hold the SMS for delivery.

Profiles

Build a profile of the GSM device used, so that we don't have to always test each command to know whether it is supported or not, because this takes too time to be done every time.

AUTHOR

Cosimo Streppone, cosimo@cpan.org

SEE ALSO

Device::Modem, Device::SerialPort, Win32::SerialPort, perl(1)