[英]How can I get a short number when I receive a binary formatted sms in applet
我有一个Java卡小程序,可以接收二进制短信并对其进行处理。 现在,我需要检查它们是否来自特定的短号码。
那就是我所做的
case EVENT_FORMATTED_SMS_PP_ENV:{
final EnvelopeHandler eh = EnvelopeHandler.getTheHandler();
short sd_len = eh.getSecuredDataLength();
short sd_offset = eh.getSecuredDataOffset();
byte[] tmpData = new byte[10];
short dataLen = 0;
if (eh.findTLV(ToolkitConstants.TAG_ADDRESS, (byte) 1) != ToolkitConstants.TLV_NOT_FOUND) {
dataLen = eh.getValueLength();
eh.copyValue((short)0,tmpData,(short)0,(short)dataLen);
}
actions.showNumberBuffer(tmpData, (short)dataLen);
break;
}
我成功接收了地址,但它与短号不同,它发送二进制短信,也许还有其他方法可以获取短号?
地址TLV是服务中心地址。
发件人的地址是SMS-TPDU TLV中的TP-OA。 因此,您需要手动解析它。
这是一个例子:
// Format of data under first SMS TPDU TLV, taken using EnvelopeHandler.findTLV()
// ----------+-----+---------+---------+--------+--------+---------+--------+-------+
// 1 | 1 | 1 | 0~10 | 1 | 1 | 7 | 1 | 0~140 |
// ----------+-----+---------+---------+--------+--------+---------+--------+-------+
// | Len | TON/NPI | Address | | | | | |
// TP-MTI... | TP-OA | TP-PID | TP-DCS | TP-SCTS | TP-UDL | TP-UD |
// ----------+-----+---------+---------+--------+--------+---------+--------+-------+
// Get received TPOA
EnvelopeHandler envHdlr = EnvelopeHandler.getTheHandler();
envHdlr.findTLV(ToolkitConstants.TAG_SMS_TPDU, (byte) 1);
// Assign TPOA to a buffer [0] for bytes-length [1..12] for the value as coded in 3GPP TS 23.040
envHdlr.copyValue((short) 1, tpdaBuf, (short) 1, (short) 12);
byte lengthTPOA = (byte) ((tpdaBuf[1] + 5) / 2);
tpdaBuf[0] = lengthTPOA;
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.