Open GoogleCodeExporter opened 9 years ago
Hi !
This is what i'm currently using :
public static byte [] newPayLoad(OptionalParameter [] parameters) {
byte [] result = null;
for (OptionalParameter param : parameters) {
if (param.tag ==Tag.MESSAGE_PAYLOAD.code()) {
result = getValue(param);
break;
}
}
return result;
}
private static byte[] getValue(OptionalParameter param) {
byte [] value = param.serialize();
byte [] result = new byte[value.length -4];
System.arraycopy(value, 4, result, 0, value.length-4);
return result;
}
Take care that not all the optional parameters are treated the same :
public static int newSarMsgRefNum(OptionalParameter [] parameters) {
int result = 0;
for (OptionalParameter param : parameters) {
if (param.tag ==Tag.SAR_MSG_REF_NUM.code()) {
byte [] serialize = param.serialize();
result = OctetUtil.bytesToShort(serialize,4);
break;
}
}
return result;
}
or
public static int newSarSegmentSeqnum(OptionalParameter [] parameters) {
int result = 0;
for (OptionalParameter param : parameters) {
if (param.tag == Tag.SAR_SEGMENT_SEQNUM.code()) {
byte [] serialize = param.serialize();
result = serialize[4];
break;
}
}
return result;
}
Probably there's a better way, but that's the way it's working for me.
Original comment by almull...@gmail.com
on 7 Mar 2011 at 3:36
Original issue reported on code.google.com by
diptigar...@gmail.com
on 7 Feb 2011 at 4:30