public ATFrame(string command, ATCommandType commandType, Stream dataStream, string inParameters) { this.command = command; this.commandType = commandType; this.dataStream = dataStream; this.inParameters = inParameters; }
public ATFrame(string command, ATCommandType commandType, Stream dataStream, string inParameters) { this.command = command; this.commandType = commandType; this.dataStream = dataStream; this.inParameters = inParameters; }
public ATFrame(string command, ATCommandType commandType, Stream dataStream, bool unsolicited, string result, string outParameters) { this.command = command; this.commandType = commandType; this.dataStream = dataStream; this.unsolicited = unsolicited; this.result = result; this.outParameters = outParameters; }
public ATFrame(string command, ATCommandType commandType, Stream dataStream, bool unsolicited, string result, string outParameters) { this.command = command; this.commandType = commandType; this.dataStream = dataStream; this.unsolicited = unsolicited; this.result = result; this.outParameters = outParameters; }
public override ATParserResult ParseResponse(string command, ATCommandType commandType, byte[] buffer, int index, int count) { ATFrameParser frameParser = (ATFrameParser)this.frameParsers[ this.GetFrameParserKey(command, commandType)]; if (frameParser == null) return null; return frameParser.Parse(buffer, index, count); }
protected void AddRegexFrameParser(string command, ATCommandType commandType, Regex regex, int regexParametersGroup, int regexResultGroup) { this.AddFrameParser(new RegexATFrameParser() { Command = command, CommandType = commandType, Regex = regex, RegexParametersGroup = regexParametersGroup, RegexResultGroup = regexResultGroup }); }
protected void AddRegexFrameParser(string command, ATCommandType commandType, Regex regex, int regexParametersGroup, int regexResultGroup) { this.AddFrameParser(new RegexATFrameParser() { Command = command, CommandType = commandType, Regex = regex, RegexParametersGroup = regexParametersGroup, RegexResultGroup = regexResultGroup }); }
public static ATFrame GetInstance(string command, ATCommandType commandType, Stream dataStream, string inParameters) { ATFrame instance = requestInstance; instance.command = command; instance.commandType = commandType; instance.dataStream = dataStream; instance.inParameters = inParameters; return(instance); }
public override ATParserResult ParseResponse(string command, ATCommandType commandType, byte[] buffer, int index, int count) { ATFrameParser frameParser = (ATFrameParser)this.frameParsers[ this.GetFrameParserKey(command, commandType)]; if (frameParser == null) { return(null); } return(frameParser.Parse(buffer, index, count)); }
public static ATFrame GetInstance(string command, ATCommandType commandType, Stream dataStream, bool unsolicited, string result, string outParameters) { ATFrame instance = unsolicited ? unsolicitedResponseInstance : responseInstance; instance.command = command; instance.commandType = commandType; instance.dataStream = dataStream; instance.unsolicited = unsolicited; instance.result = result; instance.outParameters = outParameters; return(instance); }
public IAsyncResult BeginProcess(ATFrame frame, bool waitResponse, int timeout, AsyncCallback callback, Object state) { lock (this.syncRoot) { lock (this.waitingLock) { this.waitingEcho = this.echoEnabled; this.waitingResponse = waitResponse; this.waitingTimeout = Environment.TickCount + timeout; this.waitingCommand = frame.Command; this.waitingCommandType = frame.CommandType; this.waitingCallback = callback; this.waitingAsyncResult = WaitingAsyncResult.GetInstance(); this.waitingAsyncResult.AsyncState = state; } try { this.sendingLength = frame.GetBytes(this.sendingBuffer, 0); this.stream.Write(this.sendingBuffer, 0, this.sendingLength); #if (DEBUG) Debug.Print("Sent frame > "); Debug.Print(new string(ATParser.Bytes2Chars(this.sendingBuffer, 0, this.sendingLength))); #endif return(this.waitingAsyncResult); } catch { lock (this.waitingLock) { this.waitingEcho = false; this.waitingResponse = false; } throw new ATModemException(ATModemError.Generic); } } }
public ATFrame Process(ATFrame frame, bool waitResponse, int timeout, AsyncCallback callback) { lock (this.syncRoot) { if (waitResponse) { lock (this.waitingLock) { this.waitingEcho = this.echoEnabled; this.waitingResponse = true; this.waitingTimeout = Environment.TickCount + timeout; this.waitingCommand = frame.Command; this.waitingCommandType = frame.CommandType; this.waitingCallback = null; this.waitingEchoEvent.Reset(); this.waitingResponseEvent.Reset(); } } try { this.sendingLength = frame.GetBytes(this.sendingBuffer, 0); this.stream.Write(this.sendingBuffer, 0, this.sendingLength); #if (DEBUG) Debug.Print("Sent frame > "); Debug.Print(new string(ATParser.Bytes2Chars(this.sendingBuffer, 0, this.sendingLength))); #endif if (this.waitingEcho && !this.waitingEchoEvent.WaitOne(defaultEchoTimeout, true)) throw new ATModemException(ATModemError.Timeout); if (!waitResponse) return null; if (this.waitingResponseEvent.WaitOne(timeout, true)) { return this.waitingFrame; } throw new ATModemException(ATModemError.Timeout); } finally { if (waitResponse) { lock (this.waitingLock) { this.waitingEcho = false; this.waitingResponse = false; } } } } }
public ATFrame CreateRequestFrame(string command, ATCommandType commandType, string inParameters) { return ATFrame.GetInstance(command, commandType, ATRequestDataStream.GetInstance(this), inParameters); }
public IAsyncResult BeginProcess(ATFrame frame, bool waitResponse, int timeout, AsyncCallback callback, Object state) { lock (this.syncRoot) { lock (this.waitingLock) { this.waitingEcho = this.echoEnabled; this.waitingResponse = waitResponse; this.waitingTimeout = Environment.TickCount + timeout; this.waitingCommand = frame.Command; this.waitingCommandType = frame.CommandType; this.waitingCallback = callback; this.waitingAsyncResult = WaitingAsyncResult.GetInstance(); this.waitingAsyncResult.AsyncState = state; } try { this.sendingLength = frame.GetBytes(this.sendingBuffer, 0); this.stream.Write(this.sendingBuffer, 0, this.sendingLength); #if (DEBUG) Debug.Print("Sent frame > "); Debug.Print(new string(ATParser.Bytes2Chars(this.sendingBuffer, 0, this.sendingLength))); #endif return this.waitingAsyncResult; } catch { lock (this.waitingLock) { this.waitingEcho = false; this.waitingResponse = false; } throw new ATModemException(ATModemError.Generic); } } }
private string GetFrameParserKey(string command, ATCommandType commandType) { return(String.Concat(commandType, "+", command)); }
public static ATFrame GetInstance(string command, ATCommandType commandType, Stream dataStream, bool unsolicited, string result, string outParameters) { ATFrame instance = unsolicited ? unsolicitedResponseInstance : responseInstance; instance.command = command; instance.commandType = commandType; instance.dataStream = dataStream; instance.unsolicited = unsolicited; instance.result = result; instance.outParameters = outParameters; return instance; }
public static ATFrame GetInstance(string command, ATCommandType commandType, Stream dataStream, string inParameters) { ATFrame instance = requestInstance; instance.command = command; instance.commandType = commandType; instance.dataStream = dataStream; instance.inParameters = inParameters; return instance; }
private void DataReceived(object sender, SerialDataReceivedEventArgs e) { try { string line = ""; while ((line = serial.ReadLine()) != null) { ATCommandType cmdType = GetCmdType(line); switch (cmdType) { case ATCommandType.ReceivedMessage: string meta = line; string data = serial.ReadLine(); string[] items = meta.Remove(0, 6).Replace("\"", "").Split(','); string num = FormatNumber(items[0]); string time = items[2] + "," + items[3]; NotifyNewMessage(num, data, time); break; case ATCommandType.CallingLineIdentification: if (!gotIncomingNum) { Invoke(new Action(() => { newCallNumber.Text = "Incoming call: " + line.Split('"')[1]; Util.Animate(callNotification, Util.Effect.Slide, 150, 90); })); gotIncomingNum = true; } break; case ATCommandType.ConnectedLineIdentification: Invoke(new Action(() => { newCallNumber.Text = numberToReply; })); break; case ATCommandType.CallEnd: Invoke(new Action(() => { Util.Animate(callNotification, Util.Effect.Slide, 150, 90); })); gotIncomingNum = false; break; case ATCommandType.OK: if (answeredCall) { answeredCall = false; } break; case ATCommandType.SubscriberNumber: string[] newdata = line.Split('"'); myNum = FormatNumber(newdata[3]); Console.WriteLine(myNum); gotOwnNumber = true; break; } } } catch (System.IO.IOException io) { Console.WriteLine("Error: " + io.Message); } }
public abstract ATParserResult ParseResponse(string command, ATCommandType commandType, byte[] buffer, int index, int count);
public ATFrame CreateRequestFrame(string command, ATCommandType commandType, string inParameters) { return(ATFrame.GetInstance(command, commandType, ATRequestDataStream.GetInstance(this), inParameters)); }
private string GetFrameParserKey(string command, ATCommandType commandType) { return String.Concat(commandType, "+", command); }
public ATFrame Process(ATFrame frame, bool waitResponse, int timeout, AsyncCallback callback) { lock (this.syncRoot) { if (waitResponse) { lock (this.waitingLock) { this.waitingEcho = this.echoEnabled; this.waitingResponse = true; this.waitingTimeout = Environment.TickCount + timeout; this.waitingCommand = frame.Command; this.waitingCommandType = frame.CommandType; this.waitingCallback = null; this.waitingEchoEvent.Reset(); this.waitingResponseEvent.Reset(); } } try { this.sendingLength = frame.GetBytes(this.sendingBuffer, 0); this.stream.Write(this.sendingBuffer, 0, this.sendingLength); #if (DEBUG) Debug.Print("Sent frame > "); Debug.Print(new string(ATParser.Bytes2Chars(this.sendingBuffer, 0, this.sendingLength))); #endif if (this.waitingEcho && !this.waitingEchoEvent.WaitOne(defaultEchoTimeout, true)) { throw new ATModemException(ATModemError.Timeout); } if (!waitResponse) { return(null); } if (this.waitingResponseEvent.WaitOne(timeout, true)) { return(this.waitingFrame); } throw new ATModemException(ATModemError.Timeout); } finally { if (waitResponse) { lock (this.waitingLock) { this.waitingEcho = false; this.waitingResponse = false; } } } } }
public abstract ATParserResult ParseResponse(string command, ATCommandType commandType, byte[] buffer, int index, int count);