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.

How to control the KNX bus via SMS and send notices via SMS?
#41
If you want to use API why not use Telegram instead? It's free and easy to configure. See this: https://forum.logicmachine.net/showthrea...1#pid17111
Reply
#42
Hello,

with the instruction and files in post 3 I am now able to receive and send sms. THX!
I also managed to reboot via SMS and get back some information (e.g. IP) when sending a sms with "status" as content to LM.

I now want to get back the signal status of the modem via sms.
ASFAIK the AT-Command "AT+CSQ" delivers this information but unfortunately I have no clue how to implement this (my lua and AT-Command skills are not the best Smile ).

Can anyone help?

Thx in advance!
Reply
#43
1. Modify the user library send function so it returns the command reply/result:
Code:
-- send command to terminal
function AT:send(cmd)
  local res, err = self.port:write(cmd .. '\r\n')
  local reply

  -- write ok, get local echo
  if res then
    res, err = self:readuntil(cmd)
    reply = self:read()
  end

  return res, err, reply
end

2. Add before handler = function(sms) in the resident script:
Code:
readcsq = function()
    local res, err, reply = modem:send('AT+CSQ')
    local rssi

    if reply then
      rssi = reply:match('%+CSQ:%s+(%d+),(%d+)')
    end

    rssi = tonumber(rssi) or 0

    if 2 <= rssi and rssi <= 9 then
      quality = 'marginal'
    elseif 10 <= rssi and rssi <= 14 then
      quality = 'ok'
    elseif 15 <= rssi and rssi <= 19 then
      quality = 'good'
    elseif 20 <= rssi and rssi <= 30 then
      quality = 'excellent'
    else
      quality = 'unknown'
    end
  end

  csqtime = os.time()

3. Add before udphandler(server) in the resident script:
Code:
now = os.time()
    delta = math.abs(now - csqtime)

    if delta >= 15 then
      csqtime = now
      readcsq()
    end

This will read the signal quality every 15 seconds and will set global variable quality that you can use in the SMS reply message.
Reply
#44
Works perfect - THX!
Reply
#45
Is it possible to change APN via SMS and reconnect to the new APN? I am sure it is but my skills ...

I need this to connect to my LM in case the VPN is down.
Normally I use the APN "internet.telekom, tm ,tm" and do not want to change this default setting (bacause of security reasons) - with this APN you get a private WAN-IP like 10.x.x.x and AFAIK you can not connect to private IPs.
With the APN "internet.t-d1.de, internet, t-d1" you get a non private IP like 32.x.x.x and you can connect to it.

Another point: In the resident script the PIN code needs to be set - either as a number or a object-variable. Is it also possible to get the PIN code out of the system preferences where it usually also has to be set?

THX in advance!
Reply
#46
Hi Daniel
I have the LM5 RIO with buildin LTE modem, and I am now trying to get the SMS to work with no luck. It should be used only for SMS, and the existing Ethernet should still be used for IP traffic.

I have added a new user library called sms with the contents shown here https://kb.logicmachine.net/notifications/sms/
I have added a resident script from the same page and I am using ttyUSB2 - I do not know if that is the correct one to use.

I have disabled 3G/4G connection in System config and I have added these lines to the init script to only use SMS
io.writefile('/sys/class/gpio/export', 8)
io.writefile('/sys/class/gpio/export', 71)

io.writefile('/sys/class/gpio/gpio8/direction', 'high')
os.sleep(1)
io.writefile('/sys/class/gpio/gpio8/direction', 'low')

io.writefile('/sys/class/gpio/gpio71/direction', 'high')

This is from this post https://forum.logicmachine.net/showthread.php?tid=5123 where it was recommended to do if you only need SMS.

I have power recycled my Logic Machine and verified everything is still there after power up again. There is no messages in the error logs, and nothing happens when I try to send or receive a SMS. The pin code on the sim card is disabled.

I am searching for debugging tools to help identify the problem. Is the sim card correct mounted, what is the comport and more. I hope you can assist with tools or things I can try.

Thanks in advance. Smile
Reply
#47
Check System config > Status > System Log and System config > Status > System status > Serial ports. What do you have there after LM starts?

Disable the SMS script and run this, then post what you get in Logs: https://forum.logicmachine.net/showthrea...0#pid34700
Reply
#48
(08.08.2025, 11:34)admin Wrote: Check System config > Status > System Log and System config > Status > System status > Serial ports. What do you have there after LM starts?

Disable the SMS script and run this, then post what you get in Logs: https://forum.logicmachine.net/showthrea...0#pid34700

Thanks for your reply. I have tried your suggestion, but unfortunately I do not know how to enclose a screen copy to this post. Instead, I am writing the response in text.

System log
After a reboot it wrote that GSM modem was detected. And after that several lines in the log on the same second where it states "...now attached to ttyUSB0" and continue with several connection until stopping at "ttyUSB4".

Script log - newest at the top
Network: Greental (which is my mobile operator)
Sim: OK
Signal: 26
Reply
#49
Modify SMS script library as mentioned here: https://forum.logicmachine.net/showthrea...4#pid39004
Run the SMS script and post what you have in Logs.

To attach a screenshot click New reply, attachments will be under the text input box.
Reply
#50
Thanks for quick reply - I have uploaded screen shot of the log.

Attached Files Thumbnail(s)
   
Reply
#51
Try specifying the phone number in full format starting with + then county code.
Reply
#52
[attachment=4447 Wrote:         admin pid='39571' dateline='1754663100']Try specifying the phone number in full format starting with + then county code.

Done.

At the operator this SIM card is only open for SMS and no data ip traffic. I do not know if it means anything, but I would like to be transparent about this.
Reply
#53
Unfortunately the modern does not provide any useful error information. Have you tried sending messages using this SIM from a phone? Script only supports 7 bit alphabet so make sure that your message only contains latin letters without diacritics.
Reply
#54
(08.08.2025, 14:40)admin Wrote: Unfortunately the modern does not provide any useful error information. Have you tried sending messages using this SIM from a phone? Script only supports 7 bit alphabet so make sure that your message only contains latin letters without diacritics.

I borrowed an ordinay SIM card from a friend which is using another mobile operator and with all features open - both data, talk and SMS. That worked fine for sending SMS, so it must be something with the SIM card or operator settings. Nothings happens when I am trying to send a SMS to the modem to change a GA though, but I will deal with that later. Now I must return the borrowed SIM card and talk to operator about settings for my current SIM card.

Thanks for all your support, which is much appreciatedĀ  Heart
Reply
#55
Check Alerts tab for incoming message notification. Most likely the allowed phone number format is incorrect. Use the the same format as in the alert.
Reply


Forum Jump: