public void SaveTextMessage(Sms sms, ATCommunicator.CmgwStoreLocation location) { comm.At(); if (!comm.CmqwSupportQuery()) { throw new NotSupportedException("Message writing is not supported."); } ATCommunicator.CpmsStorageArea[] s1, s2, s3; comm.CpmsQuery(out s1, out s2, out s3); comm.Cpms(FindPreferredLocation(s1), FindPreferredLocation(s2), FindPreferredLocation(s3)); comm.Cmgf(0); EnumerableHelper.ForEach(PduEncoder.Encode(sms), pdu => comm.Cmgw(pdu, location)); }
public static IEnumerable<string> Encode(Sms sms) { if (sms.Message.Length <= 160) { yield return EncodeShortMessage(sms.Recipient, sms.Message); } else { var offset = 0; byte idx = 0; var parts = (byte)Math.Ceiling(sms.Message.Length/154f); while (offset < sms.Message.Length) { var messagePart = sms.Message.Substring(offset, Math.Min(154, sms.Message.Length-offset)); yield return EncodeMultipartMessage(sms.Recipient, messagePart, idx, parts); offset += 154; idx++; } } }
public static IEnumerable <string> Encode(Sms sms) { if (sms.Message.Length <= 160) { yield return(EncodeShortMessage(sms.Recipient, sms.Message)); } else { var offset = 0; byte idx = 0; var parts = (byte)Math.Ceiling(sms.Message.Length / 154f); while (offset < sms.Message.Length) { var messagePart = sms.Message.Substring(offset, Math.Min(154, sms.Message.Length - offset)); yield return(EncodeMultipartMessage(sms.Recipient, messagePart, idx, parts)); offset += 154; idx++; } } }
public void SendTextMessage(Sms sms) { comm.At(); comm.Cmgf(0); EnumerableHelper.ForEach(PduEncoder.Encode(sms), pdu => comm.Cmgs(pdu)); }