public SmppPduSmBase(SmppCommandType commandType, string serviceType, byte sourceAddrTon, byte sourceAddrNpi, string sourceAddr, byte destAddrTon, byte destAddrNpi, string destAddr, byte esmClass, byte protocolId, byte priorityFlag, string scheduleDeliveryTime, string validityPeriod, byte registeredDelivery, byte replaceIfPresentFlag, byte dataCoding, byte smDefaultMsgId, /*byte smLength,*/ string shortMessage, SmppOptionalParameter[] optionalParameters = null) : base(commandType) { if (commandType != GetCommandType()) { throw new Exception("Invaid command ID"); } if (serviceType.Length > 5) { throw new ArgumentOutOfRangeException("systemType"); } offsetServiceType = CurrentOffset; WriteCString(serviceType); offsetSourceAddrTon = CurrentOffset; WriteByte(sourceAddrTon); offsetSourceAddrNpi = CurrentOffset; WriteByte(sourceAddrNpi); if (sourceAddr.Length > 20) { throw new ArgumentOutOfRangeException("sourceAddr"); } offsetSourceAddr = CurrentOffset; WriteCString(sourceAddr); offsetDestAddrTon = CurrentOffset; WriteByte(destAddrTon); offsetDestAddrNpi = CurrentOffset; WriteByte(destAddrNpi); if (destAddr.Length > 20) { throw new ArgumentOutOfRangeException("destAddr"); } offsetDestAddr = CurrentOffset; WriteCString(destAddr); offsetEsmClass = CurrentOffset; WriteByte(esmClass); offsetProtocolId = CurrentOffset; WriteByte(protocolId); offsetPriorityFlag = CurrentOffset; WriteByte(priorityFlag); if (scheduleDeliveryTime.Length != 0 && scheduleDeliveryTime.Length != 16) { throw new ArgumentOutOfRangeException("scheduleDeliveryTime"); } offsetScheduleDeliveryTime = CurrentOffset; WriteCString(scheduleDeliveryTime); if (validityPeriod.Length != 0 && validityPeriod.Length != 16) { throw new ArgumentOutOfRangeException("validityPeriod"); } offsetValidityPeriod = CurrentOffset; WriteCString(validityPeriod); offsetRegisteredDelivery = CurrentOffset; WriteByte(registeredDelivery); offsetReplaceIfPresentFlag = CurrentOffset; WriteByte(replaceIfPresentFlag); offsetDataCoding = CurrentOffset; WriteByte(dataCoding); offsetSmDefaultMsgId = CurrentOffset; WriteByte(smDefaultMsgId); if (DataEncoder.GetByteCount(shortMessage) > 254) { throw new ArgumentOutOfRangeException("smLength"); } offsetSmLength = CurrentOffset; WriteByte((byte)DataEncoder.GetByteCount(shortMessage)); offsetShortMessage = CurrentOffset; WriteString(shortMessage, (byte)DataEncoder.GetByteCount(shortMessage), DataEncoder); offsetOptionalParameters = CurrentOffset; if (optionalParameters != null) { WriteOptionalParameters(optionalParameters); } }