% Example for some regular timers
% Config params, overwrite any previous settings from the
commandline
config ntp_server
ntp.nict.jp
config ntp_timezone 9
% Now the initialization, this is done once after booting
on init
do
setvar $t_prefix = "$SYS/broker/time"
setvar $tt1 = $t_prefix | "1"
setvar $tt2 = $t_prefix | "2"
setvar $tt3 = $t_prefix | "3"
setvar $tt4 = $t_prefix | "4"
% Starts, when time is synced
subscribe local $t_prefix
% Now the events, checked whenever something happens
on topic local $t_prefix
do
% Wait for sync
unsubscribe local $t_prefix
settimer 1 1000
setalarm 1 "12:00:00"
setalarm 2 "00:00:00"
on timer 1
do
% Check for full 10 minutes
if (substr($timestamp,4,4) = "0:00")
then
publish local $tt1
$timestamp
% Check for full hour
if (csvstr($timestamp,1,":") = "00") then
publish local
$tt2 $timestamp
endif
endif
settimer 1 1000
on alarm 1
do
publish local $tt3 "12:00:00"
on alarm 2
do
publish local $tt4 "00:00:00"
|