private IMessageIndicationObject HandleDeliverPduModeIndication(ref string input) { Regex regex = new Regex("\\+CMT: (\\w*),(\\d+)\\r\\n(\\w+)"); Match match = regex.Match(input); if (match.Success) { string value = match.Groups[1].Value; int num = int.Parse(match.Groups[2].Value); string str = match.Groups[3].Value; ShortMessage shortMessage = new ShortMessage(value, num, str); input = input.Remove(match.Index, match.Length); return shortMessage; } else { throw new ArgumentException("Input string does not contain an SMS-DELIVER PDU mode indication."); } }
private void comm_MessageReceived(object sender, MessageReceivedEventArgs e) { try { IMessageIndicationObject obj = e.IndicationObject; if (obj is GsmComm.GsmCommunication.ShortMessage) { GsmComm.GsmCommunication.ShortMessage msg = (GsmComm.GsmCommunication.ShortMessage)obj; SmsPdu pdu = comm.DecodeReceivedMessage(msg); } if (obj is MemoryLocation) { MemoryLocation loc = (MemoryLocation)obj; //statusBar1.Text = "New message received in storage "+loc.Storage + ", index " + loc.Index; } Read_message(); } catch (Exception ex) { MessageBox.Show(ex.Message.ToString()); } }
private SmsPdu DecodeStoredMessage(ShortMessage message) { OutgoingSmsPdu outgoingSmsPdu = null; try { outgoingSmsPdu = OutgoingSmsPdu.Decode(message.Data, true, message.Length); } catch (Exception exception1) { Exception exception = exception1; this.LogIt(LogLevel.Error, string.Concat("OutgoingSmsPdu decoder can't decode message: ", exception.Message)); this.LogIt(LogLevel.Error, string.Concat(" Message data = \"", message.Data, "\"")); int length = message.Length; this.LogIt(LogLevel.Error, string.Concat(" Message length = ", length.ToString())); throw; } return outgoingSmsPdu; }
/// <summary> /// Decodes a received short message. /// </summary> /// <param name="message">The message to decode</param> /// <returns>The decoded message as <see cref="T:GsmComm.PduConverter.SmsPdu" /> object.</returns> public SmsPdu DecodeReceivedMessage(ShortMessage message) { IncomingSmsPdu incomingSmsPdu = null; try { incomingSmsPdu = IncomingSmsPdu.Decode(message.Data, true, message.Length); } catch (Exception exception1) { Exception exception = exception1; this.LogIt(LogLevel.Error, string.Concat("IncomingSmsPdu decoder can't decode message: ", exception.Message)); this.LogIt(LogLevel.Error, string.Concat(" Message data = \"", message.Data, "\"")); int length = message.Length; this.LogIt(LogLevel.Error, string.Concat(" Message length = ", length.ToString())); throw; } return incomingSmsPdu; }
/// <summary> /// Stores a raw short message in the specified storage without setting a specific message status. /// </summary> /// <param name="message">The message to store.</param> /// <param name="storage">The storage to store the message in.</param> /// <returns>The index of the message. If the index could not be retrieved, zero is returned.</returns> /// <remarks> /// <para>The message is stored with a predefined status set in the phone.</para> /// <see cref="M:GsmComm.GsmCommunication.GsmCommMain.WriteRawMessage(GsmComm.GsmCommunication.ShortMessageFromPhone,System.String)" /> /// <see cref="M:GsmComm.GsmCommunication.GsmCommMain.WriteRawMessage(GsmComm.GsmCommunication.ShortMessage,System.String,System.Int32)" /> /// </remarks> public int WriteRawMessageWithoutStatus(ShortMessage message, string storage) { this.theDevice.SelectWriteStorage(storage); return this.theDevice.WriteMessageToMemory(message.Data, message.Length); }
private IMessageIndicationObject HandleStatusReportPduModeIndication(ref string input) { Regex regex = new Regex("\\+CDS: (\\d+)\\r\\n(\\w+)"); Match match = regex.Match(input); if (match.Success) { int num = int.Parse(match.Groups[1].Value); string value = match.Groups[2].Value; ShortMessage shortMessage = new ShortMessage(string.Empty, num, value); input = input.Remove(match.Index, match.Length); return shortMessage; } else { throw new ArgumentException("Input string does not contain an SMS-STATUS-REPORT PDU mode indication."); } }