Device::Gsm::Sms(3pm)
π Device::Gsm::Sms π
okay so bestie, this is the Device::Gsm::Sms page from the User Contributed Perl Documentation β she's a whole queen and she's about to explain herself. β¨
πΈ NAME πΈ
Device::Gsm::Sms β SMS message internal class that represents a single text SMS message π«Ά
β¨ SYNOPSIS β¨
so like, here's how you actually use her π
# 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 π
the Device::Gsm::Sms class implements a very basic SMS message object, bestie. it's literally here so you can decode a +CMGL GSM command response and turn it into a friendlier high-level object. it's giving glow-up for raw modem output π
π METHODS π
here's the full list of methods that work on Device::Gsm::Sms objects, no skips, no gatekeeping π
π© content()
see the text() method. that's it, that's the whole thing. π
π decode()
kicks off the decoding process of the pdu binary data. if the decoding process ends in success, the return value is true and the sms object gets filled with all the proper values. β¨
if the decoding process has errors, or if pdu data is not provided, the return value is 0 (zero). π«
ποΈ delete()
deletes the current SMS message from the sim card. example:
$gsm = Device::Gsm->new();
...
my @msg = $gsm->messages();
$msg[0] && $msg[0]->delete();
π new()
the basic constructor, bestie. you can build a new Device::Gsm::Sms object from the raw +CMGL header and PDU data. that data gets decoded, a new sms object is instanced, and all the information is filled in so it's ready for all the subsequent method calls. main character energy fr fr π
the allowed parameters to the new() method are:
headerβ this is the raw+CMGLheader string as the modem outputs it when you issue a+CMGLcommand πpduβ binary encoded sms datastorageβ tells which storage to delete the message from. check the documentation of your phone to know the valid storage values. the default values are:"ME"β deletes messages from gsm phone memory. π§"SC"β deletes messages from sim card. π³
π’ index()
returns the sms message index number, which is the position of the message in the internal device memory or sim card. this number is used for example to delete the message. lowkey important, don't sleep on it π
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() );
π€ recipient()
returns the sms recipient number (destination address = DA) as a string (ex.: +39012345678). π
π₯ sender()
returns the sms sender number (originating address = OA) as a string. who's texting you bestie π
π¦ status()
the status of the message can be one value from the following list:
π¦ storage()
returns the storage where the SMS has been read from. ποΈ
π text()
returns the textual content of the sms message. the actual words, the tea β
π token()
returns the given PDU token of the decoded message (internal usage). iykyk π€«
π·οΈ type()
SMS messages can be of two types: SMS_SUBMIT and SMS_DELIVER, which are defined by two constants with those names. the type() method returns one of these two values. periodt π
example:
if( $sms->type() == Device::Gsm::Sms::SMS_DELIVER ) {
# ...
}
elsif( $sms->type() == Device::Gsm::Sms::SMS_SUBMIT ) {
# ...
}
π§ REQUIRES π§
- Device::Gsm
π¦ EXPORTS π¦
None. she exports nothing, she's mysterious like that π
β TODO β
- Complete and proof-read documentation and examples π
not me leaving the docs on read, we'll get to it bestie π
π COPYRIGHT π
Device::Gsm::Sms β SMS message simple class that represents a text SMS message
Copyright (C) 2002-2015 Cosimo Streppone, cosimo@cpan.org
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 WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the Perl licensing terms for details.
fr fr, no warranty, read the license, it's iconic π
π AUTHOR π
Cosimo Streppone, cosimo@cpan.org β king behaviour, we stan π
π« SEE ALSO π«
- Device::Gsm
- perl(1)
and that's the whole page bestie, slay π β¨
this gorgeous lil page is from perl v5.32.0, dated 2021-01-19 β and it's the Device::Gsm::Sms(3pm) manual page. mwah, take care, go decode some PDUs ππ«Άπ
π¦ where this page comes from
- debian bookworm: libdevice-gsm-perl 1.61-3 Β· Artistic-1.0-Perl OR GPL-1.0-or-later
- debian trixie: libdevice-gsm-perl 1.61-3 Β· Artistic-1.0-Perl OR GPL-1.0-or-later
- ubuntu jammy: libdevice-gsm-perl 1.61-3 Β· Artistic-1.0-Perl OR GPL-1.0-or-later
- ubuntu noble: libdevice-gsm-perl 1.61-3 Β· Artistic-1.0-Perl OR GPL-1.0-or-later
- ubuntu resolute: libdevice-gsm-perl 1.61-3 Β· Artistic-1.0-Perl OR GPL-1.0-or-later
- ubuntu stonking: libdevice-gsm-perl 1.61-3 Β· Artistic-1.0-Perl OR GPL-1.0-or-later
- π girlified by deepseek-ai/DeepSeek-V4.1-Flash on : a language model's rewrite of the original, under its terms