LogicMachine Forum
problem with 4g modem - Printable Version

+- LogicMachine Forum (https://forum.logicmachine.net)
+-- Forum: LogicMachine eco-system (https://forum.logicmachine.net/forumdisplay.php?fid=1)
+--- Forum: Hardware (https://forum.logicmachine.net/forumdisplay.php?fid=12)
+--- Thread: problem with 4g modem (/showthread.php?tid=3839)

Pages: 1 2 3


RE: problem with 4g modem - admin - 01.07.2024

Post what you have in System config > Status > System log.


RE: problem with 4g modem - andrepneves@gmail.com - 01.07.2024

Hi,

Thank for the quick reply.
Here it goes.


RE: problem with 4g modem - admin - 01.07.2024

What LM hardware model are you using?


RE: problem with 4g modem - andrepneves@gmail.com - 01.07.2024

LM5p2-RIO3LTE

LM5M3CV15xA23010267


RE: problem with 4g modem - admin - 01.07.2024

Do you have 3G/4G connection enabled? If it's disabled then the on-board modem won't be initialized.


RE: problem with 4g modem - andrepneves@gmail.com - 01.07.2024

It was disabled. When we try to enable it the LM stops responding.


RE: problem with 4g modem - admin - 01.07.2024

This most likely caused by LM using mobile connection gateway instead of Ethernet.
Follow this guide if you only need SMS without 3G/4G: https://forum.logicmachine.net/showthread.php?tid=5123&pid=33127#pid33127


RE: problem with 4g modem - andrepneves@gmail.com - 01.07.2024

It worked. Thanks!

I still have a strange situation. In the alert I still get "SMS handler lost connection" but the SMS are getting through. I only happens with a card from one provider. Using a card from a different provider it doesn't happen.


RE: problem with 4g modem - admin - 01.07.2024

Modify AT:run() function in the user library as follows and post what you get in LM Logs tab.
Code:
function AT:run()   local res, err, cmd, pos, sms   res, err = self:read()   if err then     if err ~= 'timeout' then       log('run error', err)     end     return err == 'timeout'   end   -- check for incoming command   if res:sub(1, 1) ~= '+' then     return true   end   pos = res:find(':', 1, true)   if not pos then     return true   end   -- get command type   cmd = res:sub(2, pos - 1)   -- check only for incoming sms   if cmd ~= 'CMTI' then     log('run cmd', cmd)     return   end   -- read from sim   sms = self:incsms(res)   -- sms seems to be valid, pass to handler if specified   if sms and self.smshandler then     self.smshandler(sms)   end   return true end



RE: problem with 4g modem - andrepneves@gmail.com - 01.07.2024

Here goes the log.


RE: problem with 4g modem - admin - 01.07.2024

Change the same function as follows and see if it helps.
Code:
function AT:run()   local res, err, cmd, pos, sms   res, err = self:read()   if err then     return err == 'timeout'   end   -- check for incoming command   if res:sub(1, 1) ~= '+' then     return true   end   pos = res:find(':', 1, true)   if not pos then     return true   end   -- get command type   cmd = res:sub(2, pos - 1)   -- check only for incoming sms   if cmd == 'CMTI' then     -- read from sim     sms = self:incsms(res)     -- sms seems to be valid, pass to handler if specified     if sms and self.smshandler then       self.smshandler(sms)     end   end   return true end



RE: problem with 4g modem - EjvindHald - 26.09.2025

I have the LM with the built-in LTE modem. It has been configured, so it is only used for SMS, while the RJ45 port is used for all IP traffice.

I have created the standard scripts according to the guide, and I can send SMS without any problems. This works very stable. However, when I try to send a SMS to the LTE modem, then nothing happens. An example of SMS is "W 1//1/9 false" without the quotes to turn off something. I get no response on read. My sender phone number is allowed in the script, and I have tried both with and without country code.

I hope you can provide some temporary changes to the script, so I can find what I have missed.

Thanks.


RE: problem with 4g modem - admin - 26.09.2025

Do you have anything in LM Alerts tab? Messages from all numbers are logged there.


RE: problem with 4g modem - EjvindHald - 26.09.2025

Yes, there are messages. See screen shot with todays messages, where I tried off instead of false, but with same result.


RE: problem with 4g modem - admin - 26.09.2025

Make sure that the number is specified in the script the same way as in the alert between [].

Modify the handler function in the resident script as follows and post what you get in Logs tab:
Code:
handler = function(sms)   -- sms from known number, call parser   if table.contains(numbers, sms.sender) then     log('incoming sms', sms.sender, sms.data)     parser(sms.data, sms.sender)   else     log('unknown number', sms.sender)   end end

For on/off use 0/1 or true/false.


RE: problem with 4g modem - EjvindHald - 26.09.2025

I saw that the + sign in front of the country code was missing in the alert log, so I tried to remove the + sign and still country code number. That worked, and I have now for the first time received a response on a read SMS.

If I reboot the LM, and I send one SMS everything works fine. Both read and write. However, the next SMS send does not appear in the Alerts. Only if I reboot LM, it works correct for one single message. After a reboot it actually picks up the previous waiting message and responds.

I am using LM reboot functionality - no power recycle.


RE: problem with 4g modem - admin - 26.09.2025

Is the resident script configured correctly with 0 sleep time?


RE: problem with 4g modem - EjvindHald - 26.09.2025

Yes, see screen shot. The Generel Timer also shown is actually your staircase example with my own add ons.

This is my normal CPU and memory stats:


RE: problem with 4g modem - admin - 26.09.2025

In the user library add logging to the AT:run() function:
Code:
function AT:run()   local res, err, cmd, pos, sms   res, err = self:read()   log(res, err)

Then check what you get in LM Logs tab.


RE: problem with 4g modem - EjvindHald - 26.09.2025

I opened the user library and added the single line "log(res, err)" saved and tried again. Then everything worked smooth. Then I commented out that line and it still works fine with  immediate reply.

Sorry for all this - I do not know why it did not work before. But it is working fine now. And I am glad that I now know where to add a log statement to gain more info in case of future problems.

Thanks and enjoy your weekend.

Update: after a LM reboot the same faulty behavior came back with only processing one message and then it stops. I will try to get some log info.

I have now tried editing log on and off + reboot, and I cannot find a pattern in the behavior. Only thing is that it generally seems to work better when the log writing is enabled, which makes no sense to me. I cannot go with this, because the log will be flooded with messages, as it issues a timeout message every second. 

I never see any error messages in the log. Only many timeouts and now and then processing of a message. See screen shot.