2018-09-26 22:18:43 +00:00
|
|
|
#!rsc
|
2018-09-10 20:15:54 +00:00
|
|
|
# RouterOS script: mode-button-event
|
|
|
|
# Copyright (c) 2018 Christian Hesse <mail@eworm.de>
|
|
|
|
#
|
|
|
|
# run on mode-button event and count button presses
|
|
|
|
|
|
|
|
:global "mode-button";
|
|
|
|
|
|
|
|
:set ($"mode-button"->"count") ($"mode-button"->"count" + 1);
|
|
|
|
|
2018-10-11 20:39:25 +00:00
|
|
|
:local scheduler [ / system scheduler find where name="mode-button-scheduler" ];
|
|
|
|
|
|
|
|
:if ([ :len $scheduler ] = 0) do={
|
|
|
|
:log info "Creating mode-button scheduler, counting presses...";
|
|
|
|
/ system scheduler add name=mode-button-scheduler on-event=mode-button-scheduler interval=3s;
|
|
|
|
} else={
|
|
|
|
:log debug "Updating mode-button-scheduler...";
|
|
|
|
/ system scheduler set $scheduler start-time=[ /system clock get time ];
|
2018-09-10 20:15:54 +00:00
|
|
|
}
|