Subject: | Dcoding outgoing messages problems (Patch included) |
I've experienced problems with decoding messages from my
outbox.
The cause of the problem were in Device/Gsm/Sms/Token/SCA.pm
file:
$length = substr $msg, 0, 2;
# If length is `00', SCA = default end decoding ends
if( $length eq '00' ) {
$self->data( '' );
$self->state( Sms::Token::DECODED );
# Remove length-octet read from message
$$rMessage = substr( $$rMessage, 1 );
return 1;
}
It cropped only one character from $$rMessage when length is 00
while it should crop two of them.
Patch with new test-case for this problem is attached
Sincerely yours, Nikolay Shaplov
Subject: | Device-Gsm___outgouing_message_decoding_fix.diff |
diff -ur Device-Gsm-1.48.old/lib/Device/Gsm/Sms/Token/SCA.pm Device-Gsm-1.48/lib/Device/Gsm/Sms/Token/SCA.pm
--- Device-Gsm-1.48.old/lib/Device/Gsm/Sms/Token/SCA.pm 2006-04-21 00:07:19.000000000 +0400
+++ Device-Gsm-1.48/lib/Device/Gsm/Sms/Token/SCA.pm 2007-12-15 22:26:10.000000000 +0300
@@ -38,7 +38,7 @@
$self->data( '' );
$self->state( Sms::Token::DECODED );
# Remove length-octet read from message
- $$rMessage = substr( $$rMessage, 1 );
+ $$rMessage = substr( $$rMessage, 2 );
return 1;
}
diff -ur Device-Gsm-1.48.old/t/06msgcodec.t Device-Gsm-1.48/t/06msgcodec.t
--- Device-Gsm-1.48.old/t/06msgcodec.t 2006-08-12 12:57:19.000000000 +0400
+++ Device-Gsm-1.48/t/06msgcodec.t 2007-12-15 22:18:37.000000000 +0300
@@ -3,7 +3,7 @@
# test sim card message encoding/decoding functions
#
use Test::More;
-BEGIN { plan tests => 8 };
+BEGIN { plan tests => 9 };
use lib '../lib';
use_ok('Device::Gsm');
@@ -16,7 +16,8 @@
[ '+CMGL: 2,1,,31' => '0791932350593900040C919323988277190000208082319082000DC170382C168BC3E1B0582C06', 'Aaaabbbaaabbb' ],
[ '+CMGL: 1,1,,110' => '059172281991040B917228732143F90000202140311040806846F9BB0D2296EF613619444597E56F3708357DD7E96850D02C4F8FC3A99D8258B6A7C7E5D671DE06D963AE988DA548BBE7F4309B5D2683DE6E1008D59C5ED3EE992CC502C1CB7236C85E73C16036182CA668BEC9BA69B2D82C3AA7' ],
# [ '+CMGL: 2,2,,22' => '0791932350585800110000810000AD0FA0D8A61C100C4861F158B6FF2700' => '1<euro><lira><dollaro><yen><paragrafo>abc2<auml>' ]
- [ '+CMGL: 0,0,,00' => '07919471016730510410D06B7658DE7E8BD36C39006070228105118094C8309BFD6681C262D0FC6D7ECBE92071DA0D4A8FD1A0BA9B5E9683DCE57A590E92D6CDEE7ABB5D968356B45CAC16ABD972319A8C360395E5F2727A8C1687E52E90355D66974147B9DF530651DFF239BDEC0635FD6C7659EE5296E97A3A68CD0ECBC7613919242ECFE96536BBEC06D5DDF4B21C74BFDF5D6B7658DE7E8BD36C17B90C', "Hallo, ab sofort bin ich unter neuer Rufnummer +4915156914243 erreichbar. Viele Gr\xFC\xDFe Torsten M\xFCller.Jetzt klarcard bestellen unter www.klarmobil.de" ],
+ [ '+CMGL: 0,0,,00' => '07919471016730510410D06B7658DE7E8BD36C39006070228105118094C8309BFD6681C262D0FC6D7ECBE92071DA0D4A8FD1A0BA9B5E9683DCE57A590E92D6CDEE7ABB5D968356B45CAC16ABD972319A8C360395E5F2727A8C1687E52E90355D66974147B9DF530651DFF239BDEC0635FD6C7659EE5296E97A3A68CD0ECBC7613919242ECFE96536BBEC06D5DDF4B21C74BFDF5D6B7658DE7E8BD36C17B90C', "Hallo, ab sofort bin ich unter neuer Rufnummer +4915156914243 erreichbar. Viele Gr\xFC\xDFe Torsten M\xFCller.Jetzt klarcard bestellen unter www.klarmobil.de" ],
+ [ '+CMGL: 5,3,,35' => '0011FF048160110000AD1CD4F29C0E6A97E7F3F0B90C32BFE52062D99E1E9775BAE3BC0D','Test message for Device::Gsm'] # Test for outgoing message decoding
);
foreach my $m ( @messages ) {