📄 smsmsgoutgoing.java
字号:
//// Copyright (c) 2001 Kvanttisofta oy. All rights reserved.////// SMS PDU message class for outgoing messages.// (aspa@users.sourceforge.net).//// $Id: SmsMsgOutgoing.java,v 1.1.1.1 2001/04/18 04:19:00 aspa Exp $.//// TODO:// - support for including SMSC info and setting msg validity period// - better handling of recipient address type// - support other data encoding schemes than GSM 7 bit// - message reference support//package fi.kvanttisofta.sms;public class SmsMsgOutgoing { public final int SMS_MSG_ENCODING_7BIT = 0; private int smscAddressLength = 0; private int smscAddressType; private String smscAddress; private int smsSubmitCode = 0x11; private int tpMsgRef = 0; private int recipientAddressLength; private int recipientAddressType = 0x91; private String recipientAddress; private String recipientAddressEnc; private int tpPid; // protocol identifier. private int tpDcs; // data coding scheme. private int tpValidity = 0xaa; private int tpUdl; // message length. private String tpUd; // user message (as sent). private String msg; // user message (unencoded). public SmsMsgOutgoing(String recipientAddress, String msg) { this.recipientAddress = recipientAddress; this.msg = msg; } public String toString() { StringBuffer sb = new StringBuffer(320); if(false) { sb.append(SmsPduCodec.toHexString(smscAddressLength)); if( smscAddressLength > 0 ) { // add smscAddressType and smscAddressType to sb. } } sb.append(SmsPduCodec.toHexString(smsSubmitCode)); sb.append(SmsPduCodec.toHexString(tpMsgRef)); // recipientAddress. recipientAddressLength = recipientAddress.length(); if( (recipientAddress.length()%2) == 1 ) recipientAddressEnc = SmsPduCodec.swapDigits(recipientAddress+"F"); else recipientAddressEnc = SmsPduCodec.swapDigits(recipientAddress); sb.append(SmsPduCodec.toHexString(recipientAddressLength)); sb.append(SmsPduCodec.toHexString(recipientAddressType)); sb.append(recipientAddressEnc); sb.append(SmsPduCodec.toHexString(tpPid)); sb.append(SmsPduCodec.toHexString(tpDcs)); sb.append(SmsPduCodec.toHexString(tpValidity)); // encode message and calculate message length. tpUd = SmsPduCodec.sevenBitEncode(msg); tpUdl = msg.length(); sb.append(SmsPduCodec.toHexString(tpUdl)); sb.append(tpUd); return new String(sb); } public void setTarget(String number) { } public void setMessage(String msg) { } public static void main(String[] args) { // phone: 46708251358, msg: hellohello. String smspdu1 = "0011000B916407281553F80000AA0AE8329BFD4697D9EC37"; //SmsMsgOutgoing sms1 = new SmsMsgOutgoing("46708251358", "hellohello"); //System.err.println("smspdu1: " + smspdu1); //System.err.println("enc: " + sms1.toString().toUpperCase() ); SmsMsgOutgoing sms2 = new SmsMsgOutgoing("358985019963", "hello, world"); System.err.println("358985019963: 'hello, world', "+ sms2.toString().length()); System.err.println("sms2 enc: " + sms2.toString().toUpperCase() ); SmsMsgOutgoing sms3=new SmsMsgOutgoing("358985019963","testiviesti."); System.err.println("358985019963: 'testiviesti.', " + sms3.toString().length()); System.err.println("sms3 enc: " + sms3.toString().toUpperCase() ); }}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -