Created
July 10, 2021 11:40
-
-
Save L4ky/08f946cf3449c9020a5ac0f380b8a652 to your computer and use it in GitHub Desktop.
mikrotik-monitor-lte-cellid-and-notify
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# Please forgive me for the quality of this code, i worked on it very quickly. | |
# Set a schedule every 1 minute ( suggested ) in System/Scheduler | |
# Telegram Setup | |
:local botId "_YOUR_TOKEN_TELEGRAM_" | |
:local chatId _YOUR_CHAT_ID | |
# Reference Cell Setup | |
:global refCellId "_CELLID_HEX_" | |
:global refEarfcn "_EARFCN_" | |
:global refPci "_PCI_" | |
:global prevCellId | |
# Get data via AT Command | |
:local cell (:tostr(:put [/interface lte at-chat lte1 input="AT+QENG=\"servingcell\"" wait=yes as-value])); | |
:local cell [:pick $cell 0] | |
# Wait for response from LTE Module | |
:delay 2000ms; | |
# String splitting | |
:local myArray [:toarray [:pick $cell ([:find $cell "QENG"]+5) [:len $cell]]] | |
:local currentCellId [:pick $myArray 6] | |
:local currentPci [:pick $myArray 7] | |
:local currentEarfcn [:pick $myArray 8] | |
# Create Message | |
:local message "New Cell: $currentCellId - PCI: $currentPci - EARFCN: $currentEarfcn | Previous Cell: $prevCellId | Ref: $refCellId $refPci $refEarfcn" | |
:if ($currentCellId != $refCellId and $currentCellId != $prevCellId) do= { | |
:local response ([ /tool fetch url="https://api.telegram.org/bot$botId/sendMessage?chat_id=$chatId&text=$message" output=user as-value]->"data") | |
:log info $message | |
} else={:put "Cella OK"} | |
:set prevCellId ($currentCellId) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment