Community discussions

MikroTik App
 
andyh747
newbie
Topic Author
Posts: 28
Joined: Wed Jun 12, 2019 6:12 pm

SMS on LTE loss & Reboot

Sun Oct 11, 2020 12:54 pm

Hi,
I have an LHG unit deployed which is having an odd issue where internet is lost but the LTE interface remains connected. Not sure of the reason but may be related to an IP address allocated on CGNAT becoming inactive but the LHG doesn't recognise the failure. A reboot solves the problem.

I'm looking for a script which will monitor the LTE connection for internet and on failure reboot the unit or simply disable/enable the LTE interface. I'd also like an SMS sent to alert me to the fact the unit has lost internet - as the LTE interface is still connected, it should still be able to send an SMS. It would also be useful to have a further SMS when the connection is returned.

Any suggestions for a suitable script? I tried the Netwatch tool with an UP and DOWN SMS script but this kept sending an UP text at the set interval. I only want it sent on reconnection not constantly.
 
User avatar
SiB
Forum Guru
Forum Guru
Posts: 1191
Joined: Sun Jan 06, 2013 11:19 pm
Location: Poland

Re: SMS on LTE loss & Reboot

Sun Oct 11, 2020 2:04 pm

MTCNA + MTCRE + MTCINE | ~600 users at ~150 RouterBoards in EMEA | Telegram: @SiB_PL
WinBox Tip: F6 works as ALT+TAB | Gliffy.com - free network schematic | prnt.sc - free ScreenShot software
I will be at MUMEUROPE Prague on ?? ?? 202?
 
andyh747
newbie
Topic Author
Posts: 28
Joined: Wed Jun 12, 2019 6:12 pm

Re: SMS on LTE loss & Reboot

Sun Oct 11, 2020 2:30 pm

Yes have read those posts and helpful in analysing LTE connection but nothing about sending an SMS for a down connection and another for an up connection. Also the issue I'm seeing is solved with just a disable/enable LTE interface command so no requirement to reboot. This script seems to work well for looking for active internet and then enable/disable if no internet detected:
:if ([/ping 8.8.8.8 count=5 size=64 interval=2s]=0) do={
:interface lte set lte1 disabled=yes
:delay 5s
:interface lte set lte1 disabled=no
}
I then set a scheduler to run this every few minutes rather than use Netwatch - reports it isn't reliable.
viewtopic.php?t=137744

I just need to adapt the script to send an SMS if internet down and then send an SMS when the internet comes back up. Any suggestions for adding that to the above script and ensuring only single SMS sent on UP connection? When I tried using Netwatch for SMS it kept sending an SMS up text everytime the script runs.
 
andyh747
newbie
Topic Author
Posts: 28
Joined: Wed Jun 12, 2019 6:12 pm

Re: SMS on LTE loss & Reboot

Sun Oct 11, 2020 4:09 pm

Ok revised script below which seems to work well. It's sending a text when the LTE goes down then disables/enables the connection again. The only thing I'm missing is the sending of an SMS when the connection comes back up. If I add that to this script which is run in scheduler every 2mins then it will text me everytime the script runs with an SMS to say the interface is up won't it???
:if ([/ping 8.8.8.8 count=5 size=64 interval=2s]=0) do={
:tool sms send lte1 "<mobilenumber>" message="LTE Connection Down"
:delay 10s
:interface lte set lte1 disabled=yes
:delay 5s
:interface lte set lte1 disabled=no
}
 
User avatar
SiB
Forum Guru
Forum Guru
Posts: 1191
Joined: Sun Jan 06, 2013 11:19 pm
Location: Poland

Re: SMS on LTE loss & Reboot

Sun Oct 11, 2020 5:02 pm

I not like that loop working.
As you can see in my Advance Watchdog I use netwatch feature only for checking if internet is work or not... and
* when internet works I remove all fixed schedulers bcs they are no needed anymore
* when internet is down then I do few stuff
** fix problem with adding scheduler like +10m when the we crossing 24:00 and scheduler just not work as 00:0x new day
** next you can do many actions like
+1m re-enable
+3m usb power reset
+5m disable cell-lock
+7m enable all bands
+9m enable 3g and 2g
+11m send SMS that problem is hard to solve
+12m switch to other sim slot
+15m reboot

etc. That way I can do many stuff then offline exist.
This not must be netwatch base... you can do a scheduler who will be works as ping checking watchdog and do proper stuff for future.

Scripting give you a many ways of manage with problems with ISP/LTE.

PS. Good practice is to send all new SMS 2 e-mail !.
MTCNA + MTCRE + MTCINE | ~600 users at ~150 RouterBoards in EMEA | Telegram: @SiB_PL
WinBox Tip: F6 works as ALT+TAB | Gliffy.com - free network schematic | prnt.sc - free ScreenShot software
I will be at MUMEUROPE Prague on ?? ?? 202?
 
andyh747
newbie
Topic Author
Posts: 28
Joined: Wed Jun 12, 2019 6:12 pm

Re: SMS on LTE loss & Reboot

Mon Oct 12, 2020 6:04 pm

Yes I agree the loop isn't ideal. I shall look through your script and see if I can incorporate that instead.

Thanks for the information.
 
andyh747
newbie
Topic Author
Posts: 28
Joined: Wed Jun 12, 2019 6:12 pm

Re: SMS on LTE loss & Reboot

Thu Oct 29, 2020 8:18 pm

Quick update on this issue. Turns out the drops were down to a poor connection on the ethernet from the patch panel to the switch. The fault was with the patch panel and once bypassed all worked perfectly for two weeks without a single drop.

However the logs which I get emailed to me are showing odd repetitive entries over the last few days. I've had not complaints about the internet dropping but can someone tell me what these mean? Only started in last few days.
15:45:16 lte,async,event lte1: +CNEMIU: 0
15:45:16 lte,async,event lte1: +CNEMS1: 1
15:45:51 lte,async,event lte1: +CNEMIU: 0
15:45:51 lte,async,event lte1: +CNEMS1: 1
15:52:22 lte,async,event lte1: +CNEMIU: 0
15:52:22 lte,async,event lte1: +CNEMS1: 1
15:52:42 lte,async,event lte1: +CNEMIU: 0
15:52:42 lte,async,event lte1: +CNEMS1: 1
16:10:21 lte,async,event lte1: +CNEMIU: 0
16:10:21 lte,async,event lte1: +CNEMS1: 1
16:10:41 lte,async,event lte1: +CNEMIU: 0
16:10:41 lte,async,event lte1: +CNEMS1: 1
16:17:22 lte,async,event lte1: +CNEMIU: 0
16:17:22 lte,async,event lte1: +CNEMS1: 1
16:19:36 lte,async,event lte1: +CNEMIU: 0
16:19:36 lte,async,event lte1: +CNEMS1: 1
16:35:37 lte,async,event lte1: +CNEMIU: 0
16:35:37 lte,async,event lte1: +CNEMS1: 1
16:36:05 lte,async,event lte1: +CNEMIU: 0
16:36:05 lte,async,event lte1: +CNEMS1: 1
16:39:26 lte,async,event lte1: +CNEMIU: 0
16:39:26 lte,async,event lte1: +CNEMS1: 1
16:39:38 lte,async,event lte1: +CNEMIU: 0
16:39:38 lte,async,event lte1: +CNEMS1: 1
16:47:15 lte,async,event lte1: +CNEMIU: 0
16:47:15 lte,async,event lte1: +CNEMS1: 1
16:47:30 lte,async,event lte1: +CNEMIU: 0
16:47:30 lte,async,event lte1: +CNEMS1: 1
16:52:51 lte,async,event lte1: +CNEMIU: 0
16:52:51 lte,async,event lte1: +CNEMS1: 1
16:53:22 lte,async,event lte1: +CNEMIU: 0
16:53:22 lte,async,event lte1: +CNEMS1: 1
16:54:43 lte,async,event lte1: +CNEMIU: 0
16:54:43 lte,async,event lte1: +CNEMS1: 1
16:55:18 lte,async,event lte1: +CNEMIU: 0
16:55:18 lte,async,event lte1: +CNEMS1: 1
17:08:45 lte,async,event lte1: +CNEMIU: 0
17:08:45 lte,async,event lte1: +CNEMS1: 1
17:08:51 lte,async,event lte1: +CNEMIU: 0
17:08:51 lte,async,event lte1: +CNEMS1: 1
17:10:25 lte,async,event lte1: +CNEMIU: 0
17:10:25 lte,async,event lte1: +CNEMS1: 1
17:10:31 lte,async,event lte1: +CNEMIU: 0
17:10:31 lte,async,event lte1: +CNEMS1: 1
17:41:57 lte,async,event lte1: +CNEMIU: 0
17:41:57 lte,async,event lte1: +CNEMS1: 1
17:43:18 lte,async,event lte1: +CNEMIU: 0
17:43:18 lte,async,event lte1: +CNEMS1: 1
17:45:57 lte,async,event lte1: +CNEMIU: 0
17:45:57 lte,async,event lte1: +CNEMS1: 1
17:47:20 lte,async,event lte1: +CNEMIU: 0
17:47:20 lte,async,event lte1: +CNEMS1: 1
17:47:35 lte,async,event lte1: +CNEMIU: 0
17:47:35 lte,async,event lte1: +CNEMS1: 1
17:50:43 lte,async,event lte1: +CNEMIU: 0
17:50:43 lte,async,event lte1: +CNEMS1: 1
17:52:43 lte,async,event lte1: +CNEMIU: 0
17:52:43 lte,async,event lte1: +CNEMS1: 1
17:52:51 lte,async,event lte1: +CNEMIU: 0
17:52:51 lte,async,event lte1: +CNEMS1: 1
17:54:51 lte,async,event lte1: +CNEMIU: 0
17:54:51 lte,async,event lte1: +CNEMS1: 1
17:55:24 lte,async,event lte1: +CNEMIU: 0
17:55:24 lte,async,event lte1: +CNEMS1: 1
 
User avatar
SiB
Forum Guru
Forum Guru
Posts: 1191
Joined: Sun Jan 06, 2013 11:19 pm
Location: Poland

Re: SMS on LTE loss & Reboot

Thu Oct 29, 2020 10:35 pm

We not have publishted from MikroTik the AT Command manuals but google say:

ETSI TS 127 007 V13.7.0 (2018-04) PDF:
7.33 Network emergency bearer services support +CNEM

Description
Set command enables reporting of changes in the emergency bearer services support indicators with the unsolicited
result code +CNEMIU: <emb_Iu_supp> according to the network feature support information element, see
3GPP TS 24.008 [8] subclause 10.5.5.23 and the unsolicited result code +CNEMS1: <emb_S1_supp> according to
the EPS network feature support information element, see 3GPP TS 24.301 [83] subclause 9.9.3.12A. Refer
subclause 9.2 for possible <err> values.
Read command returns current command setting and if enabled, the settings of the emergency bearer services support
indicator in Iu mode and the emergency bearer services support indicator in S1 mode for the network where the UE is
attached.
Test command returns values supported as a compound value.
Defined values
<reporting>: integer type
0 Reporting not enabled
1 Reporting enabled
<emb_Iu_supp>: integer type. Emergency bearer services support indicator for Iu mode (See NOTE).
0 Emergency bearer services in Iu mode and A/Gb mode not supported
1 Emergency bearer services supported in Iu mode, but not supported in A/Gb mode
<emb_S1_supp>: integer type. Emergency bearer services support indicator for S1 mode (See NOTE).
0 Emergency bearer services in S1 mode not supported
1 Emergency bearer services in S1 mode supported
NOTE: The indicators <emb_Iu_supp> and <emb_S1_supp> are only set to supported when explicitly
signalled from the network. When an emergency bearer services support indicator is not signalled from
the network or if no network is available, this is interpreted as "Emergency bearer services not
supported".

And probably you can disable this by at+cnem=0
MTCNA + MTCRE + MTCINE | ~600 users at ~150 RouterBoards in EMEA | Telegram: @SiB_PL
WinBox Tip: F6 works as ALT+TAB | Gliffy.com - free network schematic | prnt.sc - free ScreenShot software
I will be at MUMEUROPE Prague on ?? ?? 202?
 
andyh747
newbie
Topic Author
Posts: 28
Joined: Wed Jun 12, 2019 6:12 pm

Re: SMS on LTE loss & Reboot

Fri Oct 30, 2020 11:50 am

Thanks for finding that information.

A little strange it just started happening though. I would be interested to know why this suddenly started and why it appears to flip flop constantly according to the logs.

I'll try to disable it even though I'm still unsure what it actually does.
 
AlexRodac
just joined
Posts: 22
Joined: Tue Jun 30, 2020 6:37 pm

Re: SMS on LTE loss & Reboot

Thu Nov 12, 2020 4:54 pm

Hello, I have an LtAP LTE device, it is configured with two sims of three sims, it only sends sms through slot one, that is, sim one, however I still cannot receive an SMS response from the device with the execution of a created script. How can I tell the device that when you received a text message, it responds to that text?


I have this now until, but i feel lack a thing

:global messageStore [/tool sms inbox print as-value]
:global lastMessageIdx ([:len $messageStore] - 1)
:put ([:pick $messageStore $lastMessageIdx]->"phone")
/system gps monitor once do={
:set $lat $("latitude")
:set $lon $("longitude")
}

/tool sms send lte1 message="ANSWER 1 - Your location is $lat $lon - PRUEBA ONE" phone-number=([:pick $messageStore $lastMessageIdx]->"phone")





If you may help me, thanks.

I want know how send sms to the device to answer me .
 
User avatar
SiB
Forum Guru
Forum Guru
Posts: 1191
Joined: Sun Jan 06, 2013 11:19 pm
Location: Poland

Re: SMS on LTE loss & Reboot

Mon Nov 16, 2020 1:12 am

AlexRodac
Hello, I have an LtAP LTE device, ...How can I tell the device that when you received a text message, it responds to that text?
First, SMS feature works with ONE SIM cart at time.
When you want check INBOX or SEND SMS then you must check what interface is currectly use and change it or not.
/tool sms set port=lteX is your friend !


Check My SMS2MAIL script
# print action do a sorting inside inbox
tool sms inbox print
#if any SMS exist do
if ([len [tool sms inbox find ]] > 0 ) do={
  local MTKname [system identity get name]
  local SMStype [tool sms inbox get 0 type ]
  local SMStime [tool sms inbox get 0 timestamp ]
  local SMSphone [tool sms inbox get 0 phone ]
  local EMailSubject ($MTKname." | ".$SMStype." | ".$SMStime." | ".$SMSphone)
  local SMSmsg [tool sms inbox get 0 message ]
  # Send last one to e-mail, only ONE SMS.
  tool e-mail send to=username@domain.tld subject=$EMailSubject body=$SMSmsg
  delay 1s
  # I wait for e-mail status until internet is back and e-mail will be sent and then I remove that SMS who was sent via e-mail
  while ([tool e-mail get last-status] = "in-progress") do={delay 1s}
  delay 1s
  if ([tool e-mail get last-status] = "succeeded") do={/tool sms inbox remove 0}
  delay 1s
  # LOG other SMS count
  local SMSCount [len [tool sms inbox find ]]
  log info ("SMS in Inbox was left: ".$SMSCount)
  # print action do a sorting inside inbox
  tool sms inbox print
}
# print action do a sorting inside inbox
tool sms inbox print
MTCNA + MTCRE + MTCINE | ~600 users at ~150 RouterBoards in EMEA | Telegram: @SiB_PL
WinBox Tip: F6 works as ALT+TAB | Gliffy.com - free network schematic | prnt.sc - free ScreenShot software
I will be at MUMEUROPE Prague on ?? ?? 202?
 
AlexRodac
just joined
Posts: 22
Joined: Tue Jun 30, 2020 6:37 pm

Re: SMS on LTE loss & Reboot

Mon Nov 16, 2020 3:58 pm

AlexRodac
Hello, I have an LtAP LTE device, ...How can I tell the device that when you received a text message, it responds to that text?
First, SMS feature works with ONE SIM cart at time.
When you want check INBOX or SEND SMS then you must check what interface is currectly use and change it or not.
/tool sms set port=lteX is your friend !


Check My SMS2MAIL script
# print action do a sorting inside inbox
tool sms inbox print
#if any SMS exist do
if ([len [tool sms inbox find ]] > 0 ) do={
  local MTKname [system identity get name]
  local SMStype [tool sms inbox get 0 type ]
  local SMStime [tool sms inbox get 0 timestamp ]
  local SMSphone [tool sms inbox get 0 phone ]
  local EMailSubject ($MTKname." | ".$SMStype." | ".$SMStime." | ".$SMSphone)
  local SMSmsg [tool sms inbox get 0 message ]
  # Send last one to e-mail, only ONE SMS.
  tool e-mail send to=username@domain.tld subject=$EMailSubject body=$SMSmsg
  delay 1s
  # I wait for e-mail status until internet is back and e-mail will be sent and then I remove that SMS who was sent via e-mail
  while ([tool e-mail get last-status] = "in-progress") do={delay 1s}
  delay 1s
  if ([tool e-mail get last-status] = "succeeded") do={/tool sms inbox remove 0}
  delay 1s
  # LOG other SMS count
  local SMSCount [len [tool sms inbox find ]]
  log info ("SMS in Inbox was left: ".$SMSCount)
  # print action do a sorting inside inbox
  tool sms inbox print
}
# print action do a sorting inside inbox
tool sms inbox print


Hello Sib, how are you ?, thank you for your answer.
There is something I don't understand, why are you talking about e-mial? Yes, with the / tool sms tool I can send messages through the lte1 interface, which is a modem, and with the commands that I post in the forum, it already recognizes the last number that the sms sent without saying it, and the only thing I want is that when I send you an SMS as it says on the wiki https://wiki.mikrotik.com/wiki/Manual:Tools/Sms#Syntax you respond to what I ask, that this case would be the gps coordinates of the device
 
User avatar
SiB
Forum Guru
Forum Guru
Posts: 1191
Joined: Sun Jan 06, 2013 11:19 pm
Location: Poland

Re: SMS on LTE loss & Reboot

Fri Nov 20, 2020 2:33 am

Any updates ?
MTCNA + MTCRE + MTCINE | ~600 users at ~150 RouterBoards in EMEA | Telegram: @SiB_PL
WinBox Tip: F6 works as ALT+TAB | Gliffy.com - free network schematic | prnt.sc - free ScreenShot software
I will be at MUMEUROPE Prague on ?? ?? 202?

Who is online

Users browsing this forum: No registered users and 13 guests