From 77105b180a1af58f1d20d95fbc4889ca6c7d714a Mon Sep 17 00:00:00 2001 From: Guillaume DOTT Date: Thu, 3 Oct 2013 11:07:45 +0200 Subject: [PATCH] Ignore PDU message lines in response when sending SMS Tested with TP-LINK MA180. It returns the PDU message when sending a message with a length greater than 56 (i don't really know why for now). These lines are ignored and only the last one with the status is parsed. --- lib/biju/hayes.rb | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/lib/biju/hayes.rb b/lib/biju/hayes.rb index 70dc9fd..2304e89 100644 --- a/lib/biju/hayes.rb +++ b/lib/biju/hayes.rb @@ -113,7 +113,12 @@ module Biju if result[:prompt] modem.write("#{sms.to_pdu}#{26.chr}") - hayes_to_obj(modem.wait(length: 8).lstrip) + res = '' + loop do + res = modem.wait(length: 8) + break unless res.match(/\A[0-9A-Fa-f]+\r\n\z/) + end + hayes_to_obj(res.lstrip) end end