Hi everyone.
My goal is to lock the parameters I need via a script, then add that script to autorun and apply it after a reconnect. I reviewed this page: https://help.mikrotik.com/docs/spaces/ROS/pages/30146563/LTE+5G and I also used Gemini and ChatGPT since I’m not a developer, but for the past 3 hours, after creating the script, I keep getting an Invalid status. I tried different syntax, I tried adding the script both via terminal and via Winbox (System > Scripts). I tried setting different permissions, or setting it so that permissions aren’t required.
Also, the script does run - I get an “OK” status. Could it be that the LTE interface lte1 is active, meaning the cell lock must be applied when the modem is “not running”, i.e., via modem-init?
Please help me write a correct script.
I won’t post all the non-working versions, but the latest ones looked like this:
/system script set [find name="lte_cell_guard"] dont-require-permissions=yes
:local iface "lte1";
:local targetPci 392;
:local targetEarfcn 1344;
:local dq "\"";
:log info ("LTE guard: enforce lock EARFCN=" . $targetEarfcn . " PCI=" . $targetPci);
:local cmd ("AT+QNWLOCK=" . $dq . "common/4g" . $dq . ",1," . $targetEarfcn . "," . $targetPci);
/interface lte at-chat $iface input=$cmd;
and
/system script add name=lte_cell_guard policy=read,write,policy,test,sensitive dont-require-permissions=yes source={
:local iface "lte1"
:local tPci 392
:local tEarfcn 1344
:local m [/interface lte monitor $iface once as-value]
:local cPci ($m->"phy-cellid")
:local cEarfcn ($m->"earfcn")
:if ($cPci > 0 && $cEarfcn > 0) do={
:if ($cPci != $tPci || $cEarfcn != $tEarfcn) do={
:log warning ("LTE Guard: Fix start. PCI " . $cPci . " -> " . $tPci)
/interface lte at-chat $iface input=("AT+QNWLOCK=\"common/4g\",1," . $tEarfcn . "," . $tPci)
}
}
}
As you can see, neither of the two versions worked. I’d like to do it in a “soft” way so that, if needed, I can revert everything using the "restore_band" command.
Could someone please help create a script with my data that definitely works?
ATL R16
RouterOS 7.20.6