Hello
Is there a way to make mikrotik make a sound/music when wifi device connet and disconnect?
for example i connect phone by wifi to mikrotik and he play beep song
i disconnect and play sad song (mario die)
its will be awesome :)
wireless,info MikroTik: EA:XX:XX:92:EB:0E@wlan: connected, signal strength -80
:global run
:local loginfo
:local prevlog
:while ($run=1) do={
:set loginfo [/log find time>([/system clock get time] - 2s) topics~"wireless" message~": connected"]
if ($loginfo!=$prevlog and [:len $prevlog]=0) do={
:beep frequency=10000 length=1s
}
:set prevlog $loginfo
:delay 1
}
:global run "1"
:global run "0"
:global run
:local LogInfo
:local LogLength
:local LogTopic
:local LogMessage
:local PrevLogLength 99999
:while ($run=1) do={
:set LogInfo [:toarray [:log find ]]
:set LogLength ([:len $LogInfo]-1)
if ($PrevLogLength<$LogLength) do={
:for Loop from ($PrevLogLength+1) to $LogLength do={
:set LogTopic [:log get [:pick $LogInfo $Loop] topics]
:set LogMessage [:log get [:pick $LogInfo $Loop] message]
# Test section
# ------------
# Test if Wifi going up
:if ($LogTopic~"wireless" and $LogMessage~": connected") do={
:put "wifi connected"
}
# Test if Wifi going down
:if ($LogTopic~"wireless" and $LogMessage~": disconnected") do={
:put "wifi disconnected"
}
# Test if eth going up
:if ($LogTopic~"interface" and $LogMessage~"up") do={
:put "ethernet up"
}
# Test if eth going down
:if ($LogTopic~"interface" and $LogMessage~"down") do={
:put "ethernet down"
}
# ----------------
# End Test section
}
}
:set PrevLogLength $LogLength
:delay 1s
}
:global run 1
{:global run
:local LogInfo
:local LogLength
:local LogTopic
:local LogMessage
:local PrevLogLength 99999
:while ($run=1) do={
:set LogInfo [:toarray [:log find ]]
:set LogLength ([:len $LogInfo]-1)
if ($PrevLogLength<$LogLength) do={
:for Loop from ($PrevLogLength+1) to $LogLength do={
:set LogTopic [:log get [:pick $LogInfo $Loop] topics]
:set LogMessage [:log get [:pick $LogInfo $Loop] message]
# Test section
# ------------
# Test if Wifi going up
:if ($LogTopic~"wireless" and $LogMessage~": connected") do={
:put "wifi connected"
}
# Test if Wifi going down
:if ($LogTopic~"wireless" and $LogMessage~": disconnected") do={
:put "wifi disconnected"
}
# Test if eth going up
:if ($LogTopic~"interface" and $LogMessage~"up") do={
:put "ethernet up"
:beep frequency=770 length=100ms;
:delay 550ms;
:beep frequency=380 length=100ms;
:delay 575ms;
}
# Test if eth going down
:if ($LogTopic~"interface" and $LogMessage~"down") do={
:put "ethernet down"
:beep frequency=660 length=100ms;
:delay 150ms;
}
# ----------------
# End Test section
}
}
:set PrevLogLength $LogLength
:delay 1s
}}
# Test if eth going down
:if ($LogTopic~"interface" and $LogMessage~"down") do={
:put "ethernet down"
:beep frequency=660 length=100ms;
:delay 150ms;
{:global run
:local LogInfo
:local LogLength
:local LogTopic
:local LogMessage
:local PrevLogLength 99999
:while ($run=1) do={
:set LogInfo [:toarray [:log find ]]
:set LogLength ([:len $LogInfo]-1)
if ($PrevLogLength<$LogLength) do={
:for Loop from ($PrevLogLength+1) to $LogLength do={
:set LogTopic [:log get [:pick $LogInfo $Loop] topics]
:set LogMessage [:log get [:pick $LogInfo $Loop] message]
# Test section
# ------------
# Test if Wifi going up
:if ($LogTopic~"wireless" and $LogMessage~": connected") do={
:put "wifi connected"
:beep frequency=660 length=100ms;
:delay 150ms;
:beep frequency=960 length=100ms;
:delay 300ms;
}
# Test if Wifi going down
:if ($LogTopic~"wireless" and $LogMessage~": disconnected") do={
:put "wifi disconnected"
:beep frequency=960 length=100ms;
:delay 150ms;
:beep frequency=660 length=100ms;
:delay 300ms;
}
# Test if eth going up
:if ($LogTopic~"interface" and $LogMessage~"up") do={
:put "ethernet up"
:beep frequency=260 length=100ms;
:delay 150ms;
:beep frequency=660 length=100ms;
:delay 300ms;
}
# Test if eth going down
:if ($LogTopic~"interface" and $LogMessage~"down") do={
:put "ethernet down"
:beep frequency=660 length=100ms;
:delay 150ms;
:beep frequency=260 length=100ms;
:delay 300ms;
}
# ----------------
# End Test section
}
}
:set PrevLogLength $LogLength
:delay 1ms
}}
:delay 1ms
Warning: value of delay-time was rounded down to 0s
16 devices connected - so its have some "load"Warning!!!
Try paste this command line:You will get a warning like this:Code: Select all:delay 1ms
And this is not a good thing. Look at CPU load. My router goes from 0-1% to 25% CPU usage.Code: Select allWarning: value of delay-time was rounded down to 0s