Skip to content

Instantly share code, notes, and snippets.

@mohammedhanine
Created February 8, 2013 14:05
Show Gist options
  • Save mohammedhanine/4739207 to your computer and use it in GitHub Desktop.
Save mohammedhanine/4739207 to your computer and use it in GitHub Desktop.
#!/usr/bin/perl
$_SMS_CM="+34607003110";
#$_SMS_MODEM="/dev/ttyACM0";
$_SMS_MODEM="/dev/ttyUSB1";
if ($#ARGV != 1 ) {
print "Uso:\n";
print " ./sendsms.perl 444444444 \"text\"\n\n";
exit;
}
use Device::Modem;
my $modem = new Device::Modem( port => $_SMS_MODEM );
if ( $modem->connect( baudrate => 115200 ) ) {
$modem->echo(1);
$modem->verbose(1);
$modem->atsend( 'AT S7=45 S0=0 L1 V1 X4 &c1 E1 Q0'.Device::Modem::CR);
print $modem->answer()."\n";
$modem->atsend( 'AT+CMGF=1'.Device::Modem::CR);
print $modem->answer()."\n";
$modem->atsend( 'AT+CSCA="' . $_SMS_CM. '"'.Device::Modem::CR);
print $modem->answer()."\n";
$modem->atsend( 'AT+CMGS="' .$ARGV[0]. '"'.Device::Modem::CR);
print $modem->answer()."\n";
$modem->atsend( $ARGV[1].chr(26));
print $ARGV[1]."\n\n";
print "\nFin de la conexion.\n\n";
} else {
print "ERROR: No encuentro el modem.\n";
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment