Skip to content

Commit

Permalink
Add support for SMS_STATUS (CDS), add message_reference selector
Browse files Browse the repository at this point in the history
  • Loading branch information
marcin-gryszkalis committed Apr 24, 2012
1 parent 8706e8a commit 641e46d
Show file tree
Hide file tree
Showing 2 changed files with 32 additions and 2 deletions.
30 changes: 30 additions & 0 deletions lib/Device/Gsm/Sms.pm
Expand Up @@ -93,6 +93,24 @@ sub new {
undef $self;
}

}
elsif ($opt{'header'} =~ /\+CDS:\s*(\d+)/o) {

$self->{'mr'} = $1; # Message number
$self->{'pdu'} = $opt{'pdu'}; # PDU content

bless $self, $class;

if ($self->decode(Device::Gsm::Sms::SMS_STATUS)) {
# _log('OK, message decoded correctly!');

}
else {

# _log('CASINO!');
undef $self;
}

}
else {

Expand Down Expand Up @@ -395,6 +413,18 @@ sub recipient {
}
}

#
# Only valid for SMS_STATUS messages?
#
sub message_reference {
my $self = shift;
if ( $self->type() == SMS_STATUS) {
my $t = $self->token('MR');
return $t->toString() if $t;
}
}


#
#Only valid for SMS_STATUS messages returns status code(in hex) extracted from status message
#Codes are explained in ST.pm
Expand Down
4 changes: 2 additions & 2 deletions lib/Device/Gsm/Sms/Token/SCA.pm
Expand Up @@ -55,9 +55,9 @@ sub decode {

$self->set('length' => $length);

# Get type of message (81 = national, 91 = international)
# Get type of message (81 = national, 91 = international, 80 = empty for status messages)
$type = substr $msg, 2, 2;
if ($type ne '81' and $type ne '91') {
if ($type ne '81' and $type ne '91' and $type ne '80') {
$self->data(undef);
$self->state(Sms::Token::ERROR);
return 0;
Expand Down

0 comments on commit 641e46d

Please sign in to comment.