Folks -- Having a little problem with kannel and binary messages sent via
HTTP.

Right now, I can't seem to successfully convert the text passed by kannel
via an HTTP relay connection back to the hex encoded string.

The original:

    UDH: 0B0504158100000003010301
    Txt: 
024A3A61A5B991858DB1D5880400D522CAEB2CD49082CAB12418400410B2AD49082CB312408B26D49082CAB12408B2CD49082CAB12418400410B2AD4

What I get from Kannel:

    [from] => #####
    [to] => 1##########
    [text] => J:a������Ո\0�\"��,[EMAIL PROTECTED],[EMAIL 
PROTECTED]&Ԑ�ʱ$��I,�A�\0A*�
    [smsc] => ####http
    [coding] => 2
    [udh] => �\0\0\0
    [textbin] => %b
    [worthless] => nothing?username=nada
    [password] => nada

I have a function that gets it close (taking each character and trying to
convert it to its binary then hex format, taking in account \0 is a null),
but not exact.

This is as close as I get:

    [udh]  => 0B05040F5100000003010301
    OrigUDH:  0B0504158100000003010301

    [text] => 
0204033D00005B550800005804000000000002005A520000181228040A0000310802000C28081A005A52000018080000310802000C29540029000200
    OrigTxt:  
024A3A61A5B991858DB1D5880400D522CAEB2CD49082CAB12418400410B2AD49082CB312408B26D49082CAB12408B2CD49082CAB12418400410B2AD4

Any suggestions?  Here's my function that I use to parse:

function decodebin($str) {
    $chars = preg_split("//", $str);    // split each character into an array
    $ret = "";
    while(list($k,$v) = each($chars)) {
        // skip first and last; preg_replace returns spaces/nulls as first and last
        if ($k == 0 or $k == (count($chars)-1)) continue;
        // check for the \0 null
        if ($v == "\\") {
            $backslash = 1;
            continue;
        }
        if ($backslash and $v == 0) {
            $ret .= "00";
            $backslash = 0;
            continue;
        }
        // if we are here, take the ascii val of the character, convert to hex, print 
leading 0 if less than F
        $ret .= sprintf("%02X", dechex(ord($v)));
        $backslash = 0;
    }
    return $ret;
}




---------------------------------------------------------------------------
Peter Beckman                                                  Internet Guy
[EMAIL PROTECTED]                             http://www.purplecow.com/
---------------------------------------------------------------------------

---------- Forwarded message ----------
Date: Fri, 6 Aug 2004 11:49:41 -0400
From: [EMAIL PROTECTED]
To: [EMAIL PROTECTED]
Subject: Mobileway HTTP

Array
(
    [from] => 25378
    [to] => 17032033393
    [text] => J:a������Ո\0�\"��,[EMAIL PROTECTED],[EMAIL 
PROTECTED]&Ԑ�ʱ$��I,�A�\0A*�
    [smsc] => mobilewayhttp
    [coding] => 2
    [udh] => �\0\0\0
    [textbin] => %b
    [worthless] => nothing?username=nada
    [password] => nada
)
In: POST /usa_opera_mnp/usa_opera_mnp.sms HTTP/1.1
HOST: 203.117.144.30
Authorization: Basic dXNhX29wZXJhX21ucDpiakVkbHJwaw==
content-length: 229

Subject=Example
[MSISDN]
List=17032033393
[MESSAGE]
Text=0204033D00005B550800005804051E000516000002005A520000181228040A0000310802000C28081A005A52000018080000310802000C2954051E29000200
Binary=05040F51051E051E051E03010301
Length=14
Out: HTTP/1.1 200 OK
Date: Fri, 06 Aug 2004 15:49:37 GMT
Server: Apache/1.3.27 (Unix) mod_perl/1.27
Content-Type: text/xml;charset="utf-8"
X-Cache: MISS from mt1.sg.mobileway.com
Transfer-Encoding: chunked

aa
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 3.2 Final//EN">
<HTML>
<HEAD>
</HEAD>
<BODY><br>
#Message Receive correctly<br>
ORDERID=2291797334<br>
</BODY>
</HTML>


0


Reply via email to