SYNOPSIS

    # A list of Device::Gsm::Sms messages is returned by
    # Device::Gsm messages() method.

    use Device::Gsm;
    ...
    @sms = $gsm->messages();

    if( @sms ) {
        foreach( @sms ) {
            print $msg->storage()   , "\n";
            print $msg->recipient() , "\n";
            print $msg->sender()    , "\n";
            print $msg->content()   , "\n";
            print $msg->time()      , "\n";
            print $msg->type()      , "\n";
        }
    }

    # Or you can instance a sms message from raw PDU data
    my $msg = new Device::Gsm::Sms(
        header => '+CMGL: ...',
        pdu    => `[encoded pdu data]',
        storage=> 'ME', # or 'SC'
    );

    if( defined $msg ) {
        print $msg->recipient() , "\n";
        print $msg->sender()    , "\n";
        print $msg->content()   , "\n";  # or $msg->text()
        print $msg->time()      , "\n";
        print $msg->type()      , "\n";
    }

        $msg->delete();

DESCRIPTION

\*(C`Device::Gsm::Sms\*(C' class implements very basic \s-1SMS\s0 message object, that can be used to decode \*(C`+CMGL\*(C' \s-1GSM\s0 command response to build a more friendly high-level object.

METHODS

The following is a list of methods applicable to \*(C`Device::Gsm::Sms\*(C' objects.

\fIcontent()\fP

See text() method.

\fIdecode()\fP

Starts the decoding process of pdu binary data. If decoding process ends in success, return value is true and sms object is filled with all proper values.

If decoding process has errors or pdu data is not provided, return value is 0 (zero).

\fIdelete()\fP

Delete the current \s-1SMS\s0 message from sim card. Example:

$gsm = Device::Gsm->new(); ... my @msg = $gsm->messages(); $msg[0] && $msg[0]->delete();

\fInew()\fP

Basic constructor. You can build a new \*(C`Device::Gsm::Sms\*(C' object from the raw +CMGL header and \s-1PDU\s0 data. Those data is then decoded and a new sms object is instanced and all information filled, to be available for subsequent method calls.

The allowed parameters to new() method are:

header

This is the raw +CMGL header string as modem outputs when you issue a +CMGL command

pdu

Binary encoded sms data

storage

Tells which storage to delete the message from. Check the documentation of your phone to know valid storage values. Default values are:

Deletes messages from gsm phone memory. Deletes messages from sim card.

\fIindex()\fP

Returns the sms message index number, that is the position of message in the internal device memory or sim card. This number is used for example to delete the message.

my $gsm = Device::Gsm->new(port=>'/dev/ttyS0'); ... my @messages = $gsm->messages(); ... # Delete the first returned message my $msg = shift @messages; $gsm->delete_sms( $msg->index() );

\fIrecipient()\fP

Returns the sms recipient number (destination address = \s-1DA\s0) as string (ex.: +39012345678).

\fIsender()\fP

Returns the sms sender number (originating address = \s-1OA\s0) as string.

\fIstatus()\fP

Status of the message can be one value from the following list:

\fIstorage()\fP

Returns the storage where \s-1SMS\s0 has been read from.

\fItext()\fP

Returns the textual content of sms message.

\fItoken()\fP

Returns the given \s-1PDU\s0 token of the decoded message (internal usage).

\fItype()\fP

\s-1SMS\s0 messages can be of two types: \s-1SMS_SUBMIT\s0 and \s-1SMS_DELIVER\s0, that are defined by two constants with those names. type() method returns one of these two values.

Example:

if( $sms->type() == Device::Gsm::Sms::SMS_DELIVER ) { # ... } elsif( $sms->type() == Device::Gsm::Sms::SMS_SUBMIT ) { # ... }

REQUIRES

  • Device::Gsm

EXPORTS

None

TODO

  • Complete and proof-read documentation and examples

COPYRIGHT

Device::Gsm::Sms - \s-1SMS\s0 message simple class that represents a text \s-1SMS\s0 message

Copyright (C) 2002-2009 Cosimo Streppone, [email protected]

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

This program is distributed in the hope that it will be useful, but \s-1WITHOUT\s0 \s-1ANY\s0 \s-1WARRANTY\s0; without even the implied warranty of \s-1MERCHANTABILITY\s0 or \s-1FITNESS\s0 \s-1FOR\s0 A \s-1PARTICULAR\s0 \s-1PURPOSE\s0. See the Perl licensing terms for details.

AUTHOR

Cosimo Streppone, [email protected]

RELATED TO Device::Gsm::Sms…

Device::Gsm, perl\|(1)