<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<title>Device::Gsm::Sms - SMS message internal class that represents a single text SMS message</title>
<link rev="made" href="mailto:cosimo@cpan.org" />
</head>

<body style="background-color: white">

<p><a name="__index__"></a></p>
<!-- INDEX BEGIN -->

<ul>

	<li><a href="#name">NAME</a></li>
	<li><a href="#synopsis">SYNOPSIS</a></li>
	<li><a href="#description">DESCRIPTION</a></li>
	<li><a href="#methods">METHODS</a></li>
	<ul>

		<li><a href="#content__"><code>content()</code></a></li>
		<li><a href="#decode__"><code>decode()</code></a></li>
		<li><a href="#delete__"><code>delete()</code></a></li>
		<li><a href="#new__"><code>new()</code></a></li>
		<li><a href="#index__"><code>index()</code></a></li>
		<li><a href="#recipient__"><code>recipient()</code></a></li>
		<li><a href="#sender__"><code>sender()</code></a></li>
		<li><a href="#status__"><code>status()</code></a></li>
		<li><a href="#storage__"><code>storage()</code></a></li>
		<li><a href="#text__"><code>text()</code></a></li>
		<li><a href="#token__"><code>token()</code></a></li>
		<li><a href="#type__"><code>type()</code></a></li>
	</ul>

	<li><a href="#requires">REQUIRES</a></li>
	<li><a href="#exports">EXPORTS</a></li>
	<li><a href="#todo">TODO</a></li>
	<li><a href="#copyright">COPYRIGHT</a></li>
	<li><a href="#author">AUTHOR</a></li>
	<li><a href="#see_also">SEE ALSO</a></li>
</ul>
<!-- INDEX END -->

<hr />
<p>
</p>
<hr />
<h1><a name="name">NAME</a></h1>
<p>Device::Gsm::Sms - SMS message internal class that represents a single text SMS message</p>
<p>
</p>
<hr />
<h1><a name="synopsis">SYNOPSIS</a></h1>
<pre>
    # A list of Device::Gsm::Sms messages is returned by
    # Device::Gsm messages() method.</pre>
<pre>
    use Device::Gsm;
    ...
    @sms = $gsm-&gt;messages();</pre>
<pre>
    if( @sms ) {
        foreach( @sms ) {
            print $msg-&gt;storage()   , &quot;\n&quot;;
            print $msg-&gt;recipient() , &quot;\n&quot;;
            print $msg-&gt;sender()    , &quot;\n&quot;;
            print $msg-&gt;content()   , &quot;\n&quot;;
            print $msg-&gt;time()      , &quot;\n&quot;;
            print $msg-&gt;type()      , &quot;\n&quot;;
        }
    }</pre>
<pre>
    # Or you can instance a sms message from raw PDU data
    my $msg = new Device::Gsm::Sms(
        header =&gt; '+CMGL: ...',
        pdu    =&gt; `[encoded pdu data]',
        storage=&gt; 'ME', # or 'SC'
    );</pre>
<pre>
    if( defined $msg ) {
        print $msg-&gt;recipient() , &quot;\n&quot;;
        print $msg-&gt;sender()    , &quot;\n&quot;;
        print $msg-&gt;content()   , &quot;\n&quot;;  # or $msg-&gt;text()
        print $msg-&gt;time()      , &quot;\n&quot;;
        print $msg-&gt;type()      , &quot;\n&quot;;
    }</pre>
<p>
</p>
<hr />
<h1><a name="description">DESCRIPTION</a></h1>
<p><code>Device::Gsm::Sms</code> class implements very basic SMS message object,
that can be used to decode <code>+CMGL</code> GSM command response to build a more
friendly high-level object.</p>
<p>
</p>
<hr />
<h1><a name="methods">METHODS</a></h1>
<p>The following is a list of methods applicable to <code>Device::Gsm::Sms</code> objects.</p>
<p>
</p>
<h2><a name="content__"><code>content()</code></a></h2>
<p>See <code>text()</code> method.</p>
<p>
</p>
<h2><a name="decode__"><code>decode()</code></a></h2>
<p>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.</p>
<p>If decoding process has errors or pdu data is not provided, return
value is 0 (zero).</p>
<p>
</p>
<h2><a name="delete__"><code>delete()</code></a></h2>
<p>Delete the current SMS message from sim card.
Example:</p>
<pre>
    $gsm = Device::Gsm-&gt;new();
    ...
    my @msg = $gsm-&gt;messages();
    $msg[0] &amp;&amp; $msg[0]-&gt;delete();</pre>
<p>
</p>
<h2><a name="new__"><code>new()</code></a></h2>
<p>Basic constructor. You can build a new <code>Device::Gsm::Sms</code> object from the
raw <strong>+CMGL</strong> header and <strong>PDU</strong> data. Those data is then decoded and a new
sms object is instanced and all information filled, to be available
for subsequent method calls.</p>
<p>The allowed parameters to <code>new()</code> method are:</p>
<dl>
<dt><strong><a name="item_header">header</a></strong><br />
</dt>
<dd>
This is the raw <strong>+CMGL</strong> header string as modem outputs when you
issue a <strong>+CMGL</strong> command
</dd>
<p></p>
<dt><strong><a name="item_pdu">pdu</a></strong><br />
</dt>
<dd>
Binary encoded sms data
</dd>
<p></p>
<dt><strong><a name="item_storage">storage</a></strong><br />
</dt>
<dd>
Tells which storage to delete the message from. Check the documentation of your
phone to know valid storage values. Default values are:
</dd>
<dl>
<dt><strong><a name="item_me"><code>ME</code></a></strong><br />
</dt>
<dd>
Deletes messages from gsm phone memory.
</dd>
<p></p>
<dt><strong><a name="item_sc"><code>SC</code></a></strong><br />
</dt>
<dd>
Deletes messages from sim card.
</dd>
<p></p></dl>
</dl>
<p>
</p>
<h2><a name="index__"><code>index()</code></a></h2>
<p>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.</p>
<pre>
    my $gsm = Device::Gsm-&gt;new(port=&gt;'/dev/ttyS0');
    ...
    my @messages = $gsm-&gt;messages();
    ...
    # Delete the first returned message
    my $msg = shift @messages;
    $gsm-&gt;delete_sms( $msg-&gt;index() );</pre>
<p>
</p>
<h2><a name="recipient__"><code>recipient()</code></a></h2>
<p>Returns the sms recipient number (destination address = DA)
as string (ex.: <code>+39012345678</code>).</p>
<p>
</p>
<h2><a name="sender__"><code>sender()</code></a></h2>
<p>Returns the sms sender number (originating address = OA) as string.</p>
<p>
</p>
<h2><a name="status__"><code>status()</code></a></h2>
<p>Status of the message can be one value from the following list:</p>
<FORM><SELECT><OPTION>UNKNOWN<OPTION>REC UNREAD<OPTION>REC READ<OPTION>SENT UNREAD<OPTION>SENT READ</SELECT></FORM><p>
</p>
<h2><a name="storage__"><a href="#item_storage"><code>storage()</code></a></a></h2>
<p>Returns the storage where SMS has been read from.</p>
<p>
</p>
<h2><a name="text__"><code>text()</code></a></h2>
<p>Returns the textual content of sms message.</p>
<p>
</p>
<h2><a name="token__"><code>token()</code></a></h2>
<p>Returns the given PDU token of the decoded message (internal usage).</p>
<p>
</p>
<h2><a name="type__"><code>type()</code></a></h2>
<p>SMS messages can be of two types: SMS_SUBMIT and SMS_DELIVER, that are defined by
two constants with those names. <code>type()</code> method returns one of these two values.</p>
<p>Example:</p>
<pre>
        if( $sms-&gt;type() == Device::Gsm::Sms::SMS_DELIVER ) {
                # ...
        }
        elsif( $sms-&gt;type() == Device::Gsm::Sms::SMS_SUBMIT ) {
                # ...
        }</pre>
<p>
</p>
<hr />
<h1><a name="requires">REQUIRES</a></h1>
<ul>
<li></li>
Device::Gsm
<p></p></ul>
<p>
</p>
<hr />
<h1><a name="exports">EXPORTS</a></h1>
<p>None</p>
<p>
</p>
<hr />
<h1><a name="todo">TODO</a></h1>
<ul>
<li></li>
Complete and proof-read documentation and examples
<p></p></ul>
<p>
</p>
<hr />
<h1><a name="copyright">COPYRIGHT</a></h1>
<p>Device::Gsm::Sms - SMS message simple class that represents a text SMS message</p>
<p>Copyright (C) 2002-2006 Cosimo Streppone, <a href="mailto:cosimo@cpan.org">cosimo@cpan.org</a></p>
<p>This program is free software; you can redistribute it and/or modify
it only under the terms of Perl itself.</p>
<p>This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
Perl licensing terms for details.</p>
<p>
</p>
<hr />
<h1><a name="author">AUTHOR</a></h1>
<p>Cosimo Streppone, <a href="mailto:cosimo@cpan.org">cosimo@cpan.org</a></p>
<p>
</p>
<hr />
<h1><a name="see_also">SEE ALSO</a></h1>
<p><a href="/Device/Gsm.html">the Device::Gsm manpage</a>, <code>perl(1)</code></p>

</body>

</html>