public void setBody(ByteBuffer buffer) throws NotEnoughDataInByteBufferException, TerminatingZeroNotFoundException, PDUException { setServiceType(buffer.removeCString()); sourceAddr.setData(buffer); // ? destAddr.setData(buffer); // ? setEsmClass(buffer.removeByte()); setProtocolId(buffer.removeByte()); setPriorityFlag(buffer.removeByte()); setScheduleDeliveryTime(buffer.removeCString()); setValidityPeriod(buffer.removeCString()); setRegisteredDelivery(buffer.removeByte()); setReplaceIfPresentFlag(buffer.removeByte()); setDataCoding(buffer.removeByte()); setSmDefaultMsgId(buffer.removeByte()); setSmLength(decodeUnsigned(buffer.removeByte())); shortMessage.setData(buffer.removeBuffer(getSmLength())); }
public static Collection buildSubmitEMS(ByteBuffer otaData, String srcAddr, String destAddr, int contentType, BigDecimal emsId, byte registeredDelivery, int MsgType, BigDecimal RequestID) throws EMSException { Vector vRequests; SubmitSM request = null; vRequests = new Vector(); String mobileOperator = ""; mobileOperator = Preference.mobileOperator; otaData = addHeaders2OTAData(otaData, mobileOperator, contentType); Logger.info("otadata.length:" + otaData.length()); if(otaData.length() <= 133) { MAX_LENGTH = 133; isFragmented = false; totalSegments = 1; } else { MAX_LENGTH = 128; isFragmented = true; totalSegments = (byte)(otaData.length() / MAX_LENGTH + 1); } ByteBuffer message = null; for(byte i = 1; i <= totalSegments; i++) { SubmitSM request = new SubmitSM(); request.setSourceAddr((byte)0, (byte)1, srcAddr); request.setDestAddr((byte)1, (byte)1, destAddr); request.setServiceType("WPUSH"); message = new ByteBuffer(); if(otaData.length() <= MAX_LENGTH) message.appendBuffer(otaData); else message.appendBuffer(otaData.removeBuffer(MAX_LENGTH)); request.setShortMessageData(message); request.setEsmClass((byte)0); request.setProtocolId((byte)0); String s_emsId = emsId.toString(); request.setSequenceNumber(Integer.parseInt(s_emsId + i)); if(i == totalSegments) request.setRegisteredDelivery(registeredDelivery); String DestSubAddress = "0xB0"; if(MsgType != 3) { ByteBuffer ChargeDest = new ByteBuffer(); ChargeDest.appendByte((byte)-80); ChargeDest.appendString(RequestID); DestSubAddress = DestSubAddress + RequestID; if("SFONE".equalsIgnoreCase(Preference.mobileOperator)) request.setDestSubaddress(ChargeDest); } String chargeflag = "0x0000"; if("SFONE".equalsIgnoreCase(Preference.mobileOperator)) if(MsgType == 1) { request.setSfoneChargeFlag((short)256); chargeflag = "0x0100"; } else if((new StringBuffer(String.valueOf(MsgType))).toString().startsWith("21")) { request.setSfoneChargeFlag((short)513); chargeflag = "0x0201"; } else if((new StringBuffer(String.valueOf(MsgType))).toString().startsWith("22")) { request.setSfoneChargeFlag((short)514); chargeflag = "0x0202"; } else if((new StringBuffer(String.valueOf(MsgType))).toString().equals("2")) { request.setSfoneChargeFlag((short)513); chargeflag = "0x0201"; } else { request.setSfoneChargeFlag((short)0); } Logger.info("SMSCTools.buildSubmitSM", "{RequestID=" + RequestID + "}{srcAddr=" + srcAddr + "}{destAddr=" + destAddr + "}{setDestSubaddress=" + DestSubAddress + "} {chargeflag=" + chargeflag + "} "); vRequests.addElement(request); } return vRequests; Exception e; e; throw new EMSException(e.getMessage()); }