blob: 0e1ac0d37e78df84a1ca7abd4182c9428d83cba2 (
about) (
plain) (
blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
|
#!rsc
# RouterOS script: mode-button-event
# Copyright (c) 2018-2020 Christian Hesse <mail@eworm.de>
#
# run on mode-button event and count button presses
# https://git.eworm.de/cgit/routeros-scripts/about/doc/mode-button.md
:global ModeButton;
:global LogPrintExit;
:set ($ModeButton->"count") ($ModeButton->"count" + 1);
:local Scheduler [ / system scheduler find where name="mode-button-scheduler" ];
:if ([ :len $Scheduler ] = 0) do={
$LogPrintExit info ("Creating mode-button scheduler, counting presses...") false;
/ system scheduler add name="mode-button-scheduler" \
on-event="/ system script run mode-button-scheduler;" interval=3s;
} else={
$LogPrintExit debug ("Updating mode-button-scheduler...") false;
/ system scheduler set $Scheduler start-time=[ /system clock get time ];
}
|