Skip Menu |

This queue is for tickets about the Net-UCP CPAN distribution.

Report information
The Basics
Id: 56318
Status: resolved
Priority: 0/
Queue: Net-UCP

People
Owner: Nobody in particular
Requestors: it [...] guru.de
Cc:
AdminCc:

Bug Information
Severity: Normal
Broken in: 0.40
Fixed in: (no value)



Subject: send_sms_multipart did not works correct
If i use the send_sms_multipart method, i get an endless loop in the while loop to split the message in chunks. I have write a new loop (as documented in attached patch) and some code optimizations.
Subject: Net_UCP_multisend.patch
--- Net-UCP-0.40/lib/Net/UCP.pm 2009-05-29 15:28:33.000000000 +0200 +++ Net-UCP-0.41/lib/Net/UCP.pm 2010-04-06 16:50:44.000000000 +0200 @@ -50,6 +50,7 @@ # login to SMSC sub login { my $self = shift(); + my %args = ( SMSC_ID => '', SMSC_PW => '', @@ -208,9 +209,7 @@ sub send_sms_multipart { my $self = shift; - - my %argsLong =( - RECIPIENT => '', + my %argsLong =(RECIPIENT => '', MESSAGE_TEXT => '', SENDER_TEXT => '', UDH => undef, @@ -219,45 +218,20 @@ TIMEOUT => undef, @_); - my $chunkBlock = 134; my $messageId = random_int(1,255); - my $multiHash; - - my $txtTmp = $argsLong{MESSAGE_TEXT}; my $countPart = 0; - my $chunk; - while (length($txtTmp) != 0) { - - if (length($txtTmp) > 134) { - $txtTmp =~ s/((.){134})//; - $chunk = $1; - } else { - $chunk = $txtTmp; - $txtTmp = ''; - } - + foreach my $chunk ($argsLong{MESSAGE_TEXT}=~m/(.{1,134})/sg){ $multiHash->{++$countPart} = $chunk; - } - - my $textChunk = ''; - my $k = ''; - my $udhChunk = ''; - my $ret; - - while (($k, $textChunk) = each %{$multiHash}) { - $udhChunk = "0106050003" - . sprintf("%02X", $messageId) - . sprintf("%02X", $countPart) - . sprintf("%02X", $k); - - $ret = $self->send_sms( + while (my ($k, $textChunk) = each %{$multiHash}) { + my $udh=sprintf('%s%02X%02X%02X',"0106050003",$messageId,$countPart,$k); + my $ret = $self->send_sms( RECIPIENT => $argsLong{RECIPIENT}, MESSAGE_TEXT => $textChunk, SENDER_TEXT => $argsLong{SENDER_TEXT}, - UDH => $udhChunk, + UDH => $udh ); return $ret if (!$ret || !defined($ret)); #it could be better
I have build a package, witch have include the fixes for this and bug 56317 at http://cpan.mirroring.de/authors/id/I/IT/ITGURU/Net-UCP-0.41.tgz