diff --git a/lib/biju/parser.rb b/lib/biju/parser.rb index 900be5c..885ffdf 100644 --- a/lib/biju/parser.rb +++ b/lib/biju/parser.rb @@ -12,7 +12,8 @@ module Biju rule(:prefix) { str('AT') | str('at') } # RESPONSE - rule(:response) { cr >> crlf >> (status | command) >> crlf } + rule(:response) { cr >> crlf >> (((status | command) >> crlf) | prompt) } + rule(:prompt) { str('> ') } rule(:command) { mgl | pms | mgf | mserror } rule(:mserror) { str('+CMS ERROR').as(:cmd) >> str(': ') >> message } diff --git a/spec/biju/parser_spec.rb b/spec/biju/parser_spec.rb index 1d17641..d71edc7 100644 --- a/spec/biju/parser_spec.rb +++ b/spec/biju/parser_spec.rb @@ -15,6 +15,13 @@ describe Biju::ATParser do end context "response" do + it "parses cmgs prompt" do + mgs = "AT+CMGS=18\r\r\n> " + + expect { Biju::ATTransform.new.apply( + Biju::ATParser.new.parse(mgs)) }.not_to raise_error + end + it "parses messages list" do messages = "AT+CMGL=1\r\r\n" << "+CMGL: 0,1,,23\r\n" <<