Device::Gsm::Sms(3pm)

πŸ“¦
version 1.61 Β· 2 versions
  • 1.61 Β· debian bookworm, debian trixie, ubuntu jammy, ubuntu noble, ubuntu resolute, ubuntu stonking (latest)
  • 1.61 Β· arch rolling
, in debian bookworm, debian trixie, ubuntu jammy, ubuntu noble, ubuntu resolute, ubuntu stonking

πŸ’– 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 +CMGL header string as the modem outputs it 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 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 😭

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 πŸ’«


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