Permalink
Browse files

Add support for SMS_STATUS (CDS), add message_reference selector

  • Loading branch information...
1 parent 8706e8a commit 641e46de1b9984bd151e921ff50e2e7f21cc43a3 @marcin-gryszkalis marcin-gryszkalis committed Apr 24, 2012
Showing with 32 additions and 2 deletions.
  1. +30 −0 lib/Device/Gsm/Sms.pm
  2. +2 −2 lib/Device/Gsm/Sms/Token/SCA.pm
View
30 lib/Device/Gsm/Sms.pm
@@ -94,6 +94,24 @@ sub new {
}
}
+ 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 {
# Warning: could not parse message header
@@ -396,6 +414,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
#
View
4 lib/Device/Gsm/Sms/Token/SCA.pm
@@ -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;

0 comments on commit 641e46d

Please sign in to comment.