/// <summary> Called to return the PDU for this type of object </summary> /// <returns> A byte array </returns> public byte[] GetPDU() { if (UserData.Headers.Count > 0) { EsmClass |= 0x40; } SmppBuffer tmpBuff = new SmppBuffer(DefaultEncoding, this); tmpBuff.AddCString(ServiceType); tmpBuff.AddByte(SourceTon); tmpBuff.AddByte(SourceNpi); tmpBuff.AddCString(SourceAddr); tmpBuff.AddByte(DestTon); tmpBuff.AddByte(DestNpi); tmpBuff.AddCString(DestAddr); tmpBuff.AddByte(EsmClass); tmpBuff.AddByte(ProtocolId); tmpBuff.AddByte(PriorityFlag); tmpBuff.AddTimeString(ScheduleDeliveryTime, 17); tmpBuff.AddTimeString(ValidityPeriod, 17); tmpBuff.AddByte(RegisteredDelivery); tmpBuff.AddByte(ReplaceIfPresent); tmpBuff.AddByte((byte) DataCoding); tmpBuff.AddByte(DefaultMessageId); tmpBuff.AddUserData(UserData); tmpBuff.AddTLVCollection(Optional); tmpBuff.AddFinalLength(); return tmpBuff.Buffer; }
/// <summary> Called to return the PDU for this type of object </summary> /// <returns> byte[] </returns> public byte[] GetPDU() { // Create buffer and add header information SmppBuffer tmpBuff = new SmppBuffer(DefaultEncoding, this); // Add properties tmpBuff.AddCString(ServiceType); tmpBuff.AddCString(MessageId); tmpBuff.AddByte(SourceTon); tmpBuff.AddByte(SourceNpi); tmpBuff.AddCString(SourceAddr); tmpBuff.AddByte(DestTon); tmpBuff.AddByte(DestNpi); tmpBuff.AddCString(DestAddr); // Insert final length tmpBuff.AddFinalLength(); // Return byte array return tmpBuff.Buffer; }
/// <summary> Called to return the PDU for this type of object </summary> /// <returns> byte[] </returns> public byte[] GetPDU() { SmppBuffer tmpBuff = new SmppBuffer(DefaultEncoding, this); tmpBuff.AddCString(SystemId); tmpBuff.AddCString(Password); tmpBuff.AddCString(SystemType); tmpBuff.AddByte(InterfaceVersion); tmpBuff.AddByte(AddrTon); tmpBuff.AddByte(AddrNpi); tmpBuff.AddCString(AddressRange); tmpBuff.AddFinalLength(); return tmpBuff.Buffer; }
/// <summary> Called to return the PDU for this type of object </summary> /// <returns> byte[] </returns> public byte[] GetPDU() { SmppBuffer tmpBuff = new SmppBuffer(DefaultEncoding, this); tmpBuff.AddCString(MessageId); tmpBuff.AddByte(SourceTon); tmpBuff.AddByte(SourceNpi); tmpBuff.AddCString(SourceAddr); tmpBuff.AddFinalLength(); return tmpBuff.Buffer; }
/// <summary> Called to return the PDU for this type of object </summary> /// <returns> byte[] </returns> public byte[] GetPDU() { SmppBuffer tmpBuff = new SmppBuffer(DefaultEncoding, this); tmpBuff.AddCString(MessageId); tmpBuff.AddCString(FinalDateString); tmpBuff.AddByte((byte) MessageState); tmpBuff.AddByte((byte) ErrorCode); tmpBuff.AddFinalLength(); return tmpBuff.Buffer; }
/// <summary> Prepare SubmitSm instances for sending as wap push </summary> /// <param name="transactionId"></param> /// <param name="serviceType"></param> /// <param name="srcTon"></param> /// <param name="srcNpi"></param> /// <param name="srcAddr"></param> /// <param name="destTon"></param> /// <param name="destNpi"></param> /// <param name="destAddr"></param> /// <param name="url"></param> /// <param name="title"></param> /// <returns> A SubmitSm object </returns> public SubmitSm PrepareWapPush(byte transactionId, string serviceType, byte srcTon, byte srcNpi, string srcAddr, byte destTon, byte destNpi, string destAddr, string url, string title) { SubmitSm sp = null; SmppBuffer sb = new SmppBuffer(DefaultEncoding); sb.AddByte(transactionId); sb.AddByte(0x06); //PDU Type: Push sb.AddByte(0x01); //Header Length sb.AddByte(0xAE); // application/vnd.wap.sic 0x24 ^ 0x80 // WAP Binary XML sb.AddByte(0x02); //Version 1.2 sb.AddByte(0x05); //Public Identifier sb.AddByte(0x6a); //Character Set: utf-8 sb.AddByte(0x00); //String table 0 bytes sb.AddByte(0x45); //(.C) <si> sb.AddByte(0xc6); //(AC) <indication string urlTmp = url; if (url.StartsWith("http://www.")) { sb.AddByte(0x0d); urlTmp = url.Remove(0, "http://www.".Length); } else if (url.StartsWith("http://")) { sb.AddByte(0x0c); urlTmp = url.Remove(0, "http://".Length); } else if (url.StartsWith("https://www.")) { sb.AddByte(0x0f); urlTmp = url.Remove(0, "https://www.".Length); } else if (url.StartsWith("https://")) { sb.AddByte(0x0e); urlTmp = url.Remove(0, "https://".Length); } else { sb.AddByte(0x0b); } string[] parts = Regex.Split(urlTmp, @"(\.com/|\.org/\.edu/|\.net/)"); foreach (string part in parts) { if (part == ".com/") { sb.AddByte(0x85); } else if (part == ".edu/") { sb.AddByte(0x86); } else if (part == ".net/") { sb.AddByte(0x87); } else if (part == ".org/") { sb.AddByte(0x88); } else { sb.AddEncodedString(part, DataCodings.Octets); } } sb.AddByte(0x07); // action='signal-medium' sb.AddByte(0x01); // END attribute list sb.AddEncodedString(title, DataCodings.Octets); sb.AddByte(0x01); // END </indication> sb.AddByte(0x01); // END </si> if (sb.Buffer.Length < 255 - 7) { sp = SubmitSm.Create(DefaultEncoding, serviceType, srcTon, srcNpi, srcAddr, destTon, destNpi, destAddr); sp.EsmClass = 0x40; sp.DataCoding = DataCodings.Class1ME8Bit; sp.ShortMessageBytes = sb.Buffer; sp.UserData.Headers.Add( InformationElementIdentifiers.ApplicationPortAddressingScheme16bit, new byte[] { 0x0b, 0x84, 0x23, 0xf0 } ); } else { throw new ArgumentException("Message too large to send", "message_length"); } return sp; }
/// <summary> Called to return the PDU for this type of object </summary> /// <returns> byte[] </returns> public byte[] GetPDU() { if (UserData.Headers.Count > 0) { EsmClass |= 0x40; } SmppBuffer tmpBuff = new SmppBuffer(DefaultEncoding, this); tmpBuff.AddCString(ServiceType); tmpBuff.AddByte(SourceTon); tmpBuff.AddByte(SourceNpi); tmpBuff.AddCString(SourceAddr); tmpBuff.AddByte(DestTon); tmpBuff.AddByte(DestNpi); tmpBuff.AddCString(DestAddr); tmpBuff.AddByte(EsmClass); tmpBuff.AddByte(RegisteredDelivery); tmpBuff.AddByte((byte) DataCoding); tmpBuff.AddTLVCollection(Optional); tmpBuff.AddFinalLength(); return tmpBuff.Buffer; }