I am running into odd errors when sending percent encoded bytes > 0x80, for some reason they are showing as 0xFFFFFFFD and I am unsure why. I am thinking it could be Java internals messing things up. So, if for example I am sending MT Binary SMS I would use the following parameters in my URL (which works fine): 

?udh=%02%70%00
&text=%00%F0%00%BA&F0%00
&username=…
&password=…
%to=… etc

However, I'm now attempting to receive MO binary SMS (for example, from an 3GPP TS 03.48 SMS-SUBMIT PoR) and I've found that there are some issues. I've written a server to handle these messages in Groovy, and I've provided below a small unit test for them below. 

#!/usr/local/bin/groovy
@Grab(group='org.codehaus.groovy.modules.http-builder', module='http-builder', version='0.5.0-RC2' )
import groovyx.net.http.*
import static groovyx.net.http.ContentType.*
import static groovyx.net.http.Method.*

/**
 * UDHL 0x02
 * IEIa 0x71
 * NULL 0x00
 * RPL 0x10 <----+
 * RHL 0x0A <-+  |
 * TAR 0x11   |  |
 * 0x22   |  |
 * 0x33   |  |
 * CNTR 0x00   |  |
 * 0x00   |  |
 * 0x00   |  |
 * 0x00   |  |
 * 0x01   |  |
 * PCNTR 0x00   |  |
 * STAT 0x01 <-+  | (RC/CC/DS Error)
 * Junk  0x80      |
 * 0x02      |
 * 0x90      |
 *       0x00 <----+
 * 
 * --- (outside of SMS-SUBMIT)
 * CSW 0x90 
 * 0x00
 *
 * -> 027100 00010A0000000000000001000180029000 9000
 */

def raw_udh = '027100'
def raw_alw = '00010A0000000000000001000180029000'

def expect = (raw_udh + raw_alw)

def encodeData(String data) {
StringBuilder sb = new StringBuilder()
int i
for(i = 0; i < data.length(); i+=2) {
sb.append('%').append(data.substring(i, i+2))
}
return sb.toString()
}

new java.lang.Thread() { 
    public void run() {
        def http = new HTTPBuilder('http://localhost:8080/server/kannelIncomingShortMessage/create?udh=' + 
encodeData(raw_udh) + '&allwords=' + encodeData(raw_alw))
        
        http.request( GET, JSON ) { req ->
            response.success = { resp, reader ->
                
def udh = reader.get('udh')
def alw = reader.get('allwords')
println udh + alw
assert expect == (udh + alw)
            }
    
            response.'404' = { resp, reader ->
                println '404, sadface.'
}
    
            response.'403' = { resp, reader ->
                println '403, sadface.'
            }
        }
    }
}.start()

However, on bytes '80029000' I've noticed that there are some issues. Any byte > 0x80 becomes 0xFFFFFFFD: 

assert expect == (udh + alw)
       |      |   |   | |
       |      |   |   | 00010A00000000000000010001FFFFFFFD02FFFFFFFD00
       |      |   |   02710000010A00000000000000010001FFFFFFFD02FFFFFFFD00
       |      |   027100
       |      false
       02710000010A0000000000000001000180029000

I'm not entirely sure why everything is just set to 0xFD, however I am wondering if anybody has come across similar in the past or if there's perhaps a way I can get around this? 

Thanks,

Christopher Burke
http://simulity.com
Office: +44 (0) 1248 679 281
Fax: +44 (0) 1248 660 323
Skype:krslynx


UK
Unit 8, Ash Court,
Parc Menai, Bangor,
Gwynedd, LL57 4DF,
Wales, UK

Malaysia
Level 30,
The Gardens North Tower,
Mid Valley City,
Lingkaran Syed Putra,
59200, Kuala Lumpur,
Malaysia

NOTICE: This message contains privileged & confidential information intended only for the use of the addressee named above. If you are not the intended recipient of this message, you are hereby notified that you must not disseminate, copy or take any action in reliance on it. If you have received this message in error, please notify Simulity Labs immediately. Any views expressed in this message are those of the individual sender except where the sender specifically states them to be the view of Simulity Labs

Reply via email to