Site Tools


projects:sms_via_ubuntu

SMS via Ubuntu

Owen — Tue, 13/04/2010 - 4:18pm

I have a Samsung SGH-A411 and wondered if I could send a sms from my linux machine. This Home SMS Gateway using Perl, Ubuntu and Nokia was the basis of the program below.

Using CPAN to install Device::Gsm I notice it also installed Device::Modem. I already had Device::USB installed.

The serial device was discovered via dmesg.

The service centre number is in the phone, but had to be explicitly assigned to get the thing to work. I have left some unnecessary debugging info in the program.

#!/usr/bin/perl

use Device::Gsm;
my $gsm = new Device::Gsm( port => '/dev/ttyACM0', log =>
'file, /home/owen/network.log', loglevel => 'debug'); # Got to be writable. 

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

my $imei = $gsm->imei();
print "imie is $imei\n";

my $model = $gsm->model();
print "Model is $model\n";

$srv_cnt = $gsm->service_center();
print "My service center number is: $srv_cnt\n";

# My service center number is: +CSCA: "", 
my $ok = $gsm->service_center('+61418706700');  # Telstra's service center number
print "Service center changed!\n" if $ok;

$srv_cnt = $gsm->service_center();
print "My service center number is: $srv_cnt\n";

$gsm->register();

$gsm->send_sms(
recipient => '+614********',
content => 'Here is your Ubuntu talking',
class => 'normal'
);
projects/sms_via_ubuntu.txt · Last modified: 2013/11/10 09:48 by brenda