This forum uses cookies
This forum makes use of cookies to store your login information if you are registered, and your last visit if you are not. Cookies are small text documents stored on your computer; the cookies set by this forum can only be used on this website and pose no security risk. Cookies on this forum also track the specific topics you have read and when you last read them. Please confirm that you accept these cookies being set.

SMS not received
#1
Hi,

We are using a LogicMachine5 Reactor GSM to send SMS in case of alarm of some variables. The script uses a for to send the message to multiple numbers, with a delay between them. You can see the code below (I changed the phone numbers with generic ones for security purposes).

The problem is that not every SMS is received. What could be causing this? Is there any way to check if the SMS is received?

Thank you in advance,
André Neves

Code:
1234567891011121314151617181920212223242526
require('user.sms') Nrs_Tlf={'123456789',        '987654321',      '147852369'} tab = string.split(name, ">") if value==1 then     Alarme="Alarme:\n"..tab[2].."\n"..timestamp elseif (value==2) then    Alarme="Alarme Reconhecido:\n"..tab[2].."\n"..timestamp elseif (value==3) then    Alarme="Alarme Reposto:\n"..tab[2].."\n"..timestamp end if (value<4 and value>0) then     for i = 1, 3, 1 do       sendsms(Nrs_Tlf[i],Alarme)       os.sleep(30)     end   log("SMS enviados") else   log("Out of bounds.") end
Reply
#2
See this post on how to add additional logging to the SMS script:
https://forum.logicmachine.net/showthrea...3#pid38043
Reply
#3
Hello,

I've updated the scripts as indicated on the link from @admin but some users are still not receiveing the messages. It's not always the same user, it's random.

In the alerts, the SMS handler indicate that all messages are sent but not all are received. 

Please help, the client is using this LM to check high priority alarms and with this behavior is system simply isn't reliable.

Thanks in advance.

BR,
André Neves

Attached Files Thumbnail(s)
   
Reply
#4
Restart the SMS script after making changes to the library.
Reply
#5
Did a reboot to the LM. There are still some SMS that get lost in the process.
Reply
#6
Check that you have replaced AT:read() in the library correctly. When done correctly it will log everything that the modem sends to LM.
Reply
#7
Chage AT:read with the version here https://forum.logicmachine.net/showthrea...3#pid38043



when sending SMS the log looks like the 1st image.

In standby, it's always logging 'timeout' as shown in the second image

Attached Files Thumbnail(s)
       
Reply
#8
Update the function once more, it won't spam the log with empty messages.
Code:
123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051
function AT:read(timeout)   local char, err, timeout, deftimeout, line   -- default timeout is 2 seconds, converted to 0.1 sec ticks   timeout = tonumber(timeout) or 2   timeout = timeout * 10   deftimeout = timeout   -- read until got one line or timeout occured   while timeout > 0 do     -- read 1 char     char, err = self.port:read(1, 0.1)     -- got data     if char then       -- got LF, end of line       if char == '\n' then         -- convert to string and empty buffer         line = table.concat(self.buffer)         self.buffer = {}         line = line:trim()         -- return only lines with data         if #line > 0 then           log('read line', line)           return line         -- reset timeout         else           timeout = deftimeout         end       -- ignore CR       elseif char ~= '\r' then         table.insert(self.buffer, char)       end     -- read timeout     elseif err == 'timeout' then       timeout = timeout - 1     -- other error     else       break     end   end   line = table.concat(self.buffer)   if #line > 0 then     log('read timeout', line)   end   return nil, err end

Post your logs when SMS does not reach the recipient.
Reply
#9
Users Nº1 and 4 didn't get the SMS. 

I think they'tre the ones with +CMS ERROR:665

Log in attach. 

Thank's for the quick reply

Attached Files Thumbnail(s)
           
Reply
#10
This error indicates poor network signal quality. Check this thread on how to monitor signal level: https://forum.logicmachine.net/showthrea...2#pid34692
Reply
#11
Those scripts only return 'unknown' to the group object. In the log we get +CSQ:15,99 /16,99 so we think this is not a signal quality issue. In five SMS 2 are lost on average.

I don't know if its related, but i'm not able to read objects via SMS. It's not important for this project but I'd like to give it a try.

Is there any way to take the line object to the main function (via return maybe)? My idea was to repeat the send every time we get that '+CMS ERROR: 665'
Reply
#12
Log the sending result in the resident script, it should be OK if the message is sent.
Code:
12
local res = modem:sendsms(msg:sub(1, sep - 1), msg:sub(sep + 1)) log(res)

The message can be retried several times like this:
Code:
12345678
for retry = 1, 5 do   local res = modem:sendsms(msg:sub(1, sep - 1), msg:sub(sep + 1))   if res == 'OK' then     break   else     os.sleep(5)   end end
Reply
#13
It's strange that it keeps failing some of the messages, but I think this will work with this safety. We hope to avoid the problem.

I've added an alert if all the retrys fail just to let the user know via LM that someone didn't get the text.

Thank you for your assist.
Reply


Forum Jump: