.\" -*- mode: troff; coding: utf-8 -*- .\" Automatically generated by Pod::Man 5.01 (Pod::Simple 3.43) .\" .\" Standard preamble: .\" ======================================================================== .de Sp \" Vertical space (when we can't use .PP) .if t .sp .5v .if n .sp .. .de Vb \" Begin verbatim text .ft CW .nf .ne \\$1 .. .de Ve \" End verbatim text .ft R .fi .. .\" \*(C` and \*(C' are quotes in nroff, nothing in troff, for use with C<>. .ie n \{\ . ds C` "" . ds C' "" 'br\} .el\{\ . ds C` . ds C' 'br\} .\" .\" Escape single quotes in literal strings from groff's Unicode transform. .ie \n(.g .ds Aq \(aq .el .ds Aq ' .\" .\" If the F register is >0, we'll generate index entries on stderr for .\" titles (.TH), headers (.SH), subsections (.SS), items (.Ip), and index .\" entries marked with X<> in POD. Of course, you'll have to process the .\" output yourself in some meaningful fashion. .\" .\" Avoid warning from groff about undefined register 'F'. .de IX .. .nr rF 0 .if \n(.g .if rF .nr rF 1 .if (\n(rF:(\n(.g==0)) \{\ . if \nF \{\ . de IX . tm Index:\\$1\t\\n%\t"\\$2" .. . if !\nF==2 \{\ . nr % 0 . nr F 2 . \} . \} .\} .rr rF .\" ======================================================================== .\" .IX Title "Device::Gsm::Sms 3" .TH Device::Gsm::Sms 3 2023-07-25 "perl v5.38.0" "User Contributed Perl Documentation" .\" For nroff, turn off justification. Always turn off hyphenation; it makes .\" way too many mistakes in technical documents. .if n .ad l .nh .SH NAME Device::Gsm::Sms \- SMS message internal class that represents a single text SMS message .SH SYNOPSIS .IX Header "SYNOPSIS" .Vb 2 \& # 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() , "\en"; \& print $msg\->recipient() , "\en"; \& print $msg\->sender() , "\en"; \& print $msg\->content() , "\en"; \& print $msg\->time() , "\en"; \& print $msg\->type() , "\en"; \& } \& } \& \& # Or you can instance a sms message from raw PDU data \& my $msg = new Device::Gsm::Sms( \& header => \*(Aq+CMGL: ...\*(Aq, \& pdu => \`[encoded pdu data]\*(Aq, \& storage=> \*(AqME\*(Aq, # or \*(AqSC\*(Aq \& ); \& \& if( defined $msg ) { \& print $msg\->recipient() , "\en"; \& print $msg\->sender() , "\en"; \& print $msg\->content() , "\en"; # or $msg\->text() \& print $msg\->time() , "\en"; \& print $msg\->type() , "\en"; \& } \& \& $msg\->delete(); .Ve .SH DESCRIPTION .IX Header "DESCRIPTION" \&\f(CW\*(C`Device::Gsm::Sms\*(C'\fR class implements very basic SMS message object, that can be used to decode \f(CW\*(C`+CMGL\*(C'\fR GSM command response to build a more friendly high-level object. .SH METHODS .IX Header "METHODS" The following is a list of methods applicable to \f(CW\*(C`Device::Gsm::Sms\*(C'\fR objects. .SS \fBcontent()\fP .IX Subsection "content()" See \fBtext()\fR method. .SS \fBdecode()\fP .IX Subsection "decode()" 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. .PP If decoding process has errors or pdu data is not provided, return value is 0 (zero). .SS \fBdelete()\fP .IX Subsection "delete()" Delete the current SMS message from sim card. Example: .PP .Vb 4 \& $gsm = Device::Gsm\->new(); \& ... \& my @msg = $gsm\->messages(); \& $msg[0] && $msg[0]\->delete(); .Ve .SS \fBnew()\fP .IX Subsection "new()" Basic constructor. You can build a new \f(CW\*(C`Device::Gsm::Sms\*(C'\fR object from the raw \fB+CMGL\fR header and \fBPDU\fR data. Those data is then decoded and a new sms object is instanced and all information filled, to be available for subsequent method calls. .PP The allowed parameters to \fBnew()\fR method are: .IP header 4 .IX Item "header" This is the raw \fB+CMGL\fR header string as modem outputs when you issue a \fB+CMGL\fR command .IP pdu 4 .IX Item "pdu" Binary encoded sms data .IP storage 4 .IX Item "storage" Tells which storage to delete the message from. Check the documentation of your phone to know valid storage values. Default values are: .RS 4 .ie n .IP """ME""" 4 .el .IP \f(CWME\fR 4 .IX Item "ME" Deletes messages from gsm phone memory. .ie n .IP """SC""" 4 .el .IP \f(CWSC\fR 4 .IX Item "SC" Deletes messages from sim card. .RE .RS 4 .RE .SS \fBindex()\fP .IX Subsection "index()" 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. .PP .Vb 7 \& my $gsm = Device::Gsm\->new(port=>\*(Aq/dev/ttyS0\*(Aq); \& ... \& my @messages = $gsm\->messages(); \& ... \& # Delete the first returned message \& my $msg = shift @messages; \& $gsm\->delete_sms( $msg\->index() ); .Ve .SS \fBrecipient()\fP .IX Subsection "recipient()" Returns the sms recipient number (destination address = DA) as string (ex.: \f(CW+39012345678\fR). .SS \fBsender()\fP .IX Subsection "sender()" Returns the sms sender number (originating address = OA) as string. .SS \fBstatus()\fP .IX Subsection "status()" Status of the message can be one value from the following list: .SS \fBstorage()\fP .IX Subsection "storage()" Returns the storage where SMS has been read from. .SS \fBtext()\fP .IX Subsection "text()" Returns the textual content of sms message. .SS \fBtoken()\fP .IX Subsection "token()" Returns the given PDU token of the decoded message (internal usage). .SS \fBtype()\fP .IX Subsection "type()" SMS messages can be of two types: SMS_SUBMIT and SMS_DELIVER, that are defined by two constants with those names. \fBtype()\fR method returns one of these two values. .PP Example: .PP .Vb 6 \& if( $sms\->type() == Device::Gsm::Sms::SMS_DELIVER ) { \& # ... \& } \& elsif( $sms\->type() == Device::Gsm::Sms::SMS_SUBMIT ) { \& # ... \& } .Ve .SH REQUIRES .IX Header "REQUIRES" .IP \(bu 4 Device::Gsm .SH EXPORTS .IX Header "EXPORTS" None .SH TODO .IX Header "TODO" .IP \(bu 4 Complete and proof-read documentation and examples .SH COPYRIGHT .IX Header "COPYRIGHT" Device::Gsm::Sms \- SMS message simple class that represents a text SMS message .PP Copyright (C) 2002\-2015 Cosimo Streppone, cosimo@cpan.org .PP This program is free software; you can redistribute it and/or modify it only under the terms of Perl itself. .PP 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. .SH AUTHOR .IX Header "AUTHOR" Cosimo Streppone, cosimo@cpan.org .SH "SEE ALSO" .IX Header "SEE ALSO" Device::Gsm, \fBperl\fR\|(1)