Stéphane KATTOOR > Device-Modem-GSM-0.3 > Device::Modem::GSM

Download:
Device-Modem-GSM/Device-Modem-GSM-0.3.tar.gz

Dependencies

Annotate this POD

View/Report Bugs
Module Version: 0.3   Source  

NAME ^

Device::Modem::GSM - Perl module to communicate with a GSM cell phone connected via some sort of Serial port (including but not limited to most USB data cables, IrDA, ... others ?).

SYNOPSIS ^

 use Device::Modem::GSM;
 
 my $gsm = new Device::Modem::GSM(
     port     => '/dev/ttyUSB0',
     log      => 'file,gsm_pb.log',
     loglevel => 'info');
 
 if ($gsm->connect(baudrate => 38400)) {
     print "Connected\n";
 }
 else {
     die "Couldn't connect, stopped";
 }
 if (not $gsm->pb_storage("SM")) {
     croak("Couldn't change phonebook storage");
 }
 $gsm->pb_write_entry(
     index => 0,
     text => "Daddy",
     number => '+1234567');

 $entries = $gsm->pb_read_entries(1,10);
 # or even $entries = $gsm->pb_read_all;
 foreach (@$entries) {
     print $_->{index}, ':', $_->{text}, ':', $_->{number}, "\n";
 }

DESCRIPTION ^

Device::Modem::GSM extends Device::Modem (which provides the basic communication layer) to provide access to high-level GSM functionnalities (such as access to phonebook or dealing with SMSes).

This module inherits from Device::Modem so if you need lower level access methods, start looking there.

METHODS ^

pb_storage

pb_storage must be called before any other method dealing with the phonebook. This method will set the storage on which other method calls will operate.

Supported storages will depend on the cell phone, but the following should always exist :

.

SM is the SIM card

.

ME is the phone memory

Ex : $gsm->pb_storage("SM");

pb_write_entry

This method will write an entry into the phonebook.

Ex :

 $gsm->pb_write_entry(
     index => 1,
     text => 'John Doe',
     number => '+3312345');

The "index" parameter specifies the storage slot to fill. If none specified, then the first empty is used.

pb_erase

This method will erase the entry at the specified index of the storage

Ex : $gsm->pb_erase(10);

pb_erase_all

This method will clear the whole phonebook for the used storage. Handle with care !

Ex : $gsm->pb_erase_all;

pb_read_entries

This method will fetch the specified entries in the phonebook storage and return them in a reference to an array. Each cell of the array is a reference to a hash holding the information.

Ex :

 my $entries = $gsm->pb_read_entries(1,10);

 foreach (@$entries) {
     print $_->{index}, ':', $_->{text}, ':', $_->{number}, "\n";
 }

With 2 arguments, the arguments are interpreted as an index range and entries inside of this range are returned.

With 1 argument, the argument is interpreted as an index and only this entry is returned.

pb_read_all

This is equivalent to a pb_read_entry where the range extends from the beginning of the phonebook storage to its end.

sms_send

This method will let you send an SMS to the specified phone number

Ex :

 $gsm->sms_send("+33123456", "Message to send as an SMS");

SUPPORT ^

Feel free to contact me at my email skattoor@cpan.org for questions or suggestions.

AUTHOR ^

Stephane KATTOOR, skattoor@cpan.org

COPYRIGHT ^

(c) 2007, Stephane KATTOOR, skattoor@cpan.org

This library is free software; you can only redistribute it and/or modify it under the same terms as Perl itself.

SEE ALSO ^

Device::Modem

syntax highlighting: