Exemplo n.º 1
0
        protected IEnumerable <string> ReadResponse(ATChat chat)
        {
            string responsePrefix = Command + ": ";
            var    lines          = new List <string>();

            foreach (var line in chat.ReadLines())
            {
                lines.Add(line);
                if (line.StartsWith(responsePrefix))
                {
                    yield return(line.Substring(responsePrefix.Length));

                    continue;
                }

                if (line == AT_OK)
                {
                    yield break;
                }

                if (line.Contains(AT_ERROR))
                {
                    throw new ATCommandException(lines);
                }
            }

            throw new ATCommandException(lines);
        }
Exemplo n.º 2
0
        protected virtual async IAsyncEnumerable <string> ExecuteCore(ATChat chat)
        {
            await WriteCommand(chat);

            await foreach (var line in ReadResponse(chat))
            {
                yield return(line);
            }
        }
Exemplo n.º 3
0
 protected void WriteCommand(ATChat chat)
 {
     chat.WriteLine("AT" + Command + "=" + string.Join(",", Arguments));
 }
Exemplo n.º 4
0
        protected virtual IEnumerable <string> ExecuteCore(ATChat chat)
        {
            WriteCommand(chat);

            return(ReadResponse(chat));
        }
Exemplo n.º 5
0
        public string[] Execute(Stream stream)
        {
            var chat = new ATChat(stream);

            return(ExecuteCore(chat).ToArray());
        }
Exemplo n.º 6
0
 protected async Task WriteCommand(ATChat chat)
 {
     await chat.WriteLine("AT" + Command + "=" + string.Join(",", Arguments));
 }
Exemplo n.º 7
0
        public IAsyncEnumerable <string> Execute(Stream stream)
        {
            var chat = new ATChat(stream);

            return(ExecuteCore(chat));
        }