-- -- Blink - Basic automaton to make a lamp blinking -- device = { info="Blinker", devType="basic.basic", vendorId="IHSEV Team", productId="blinking automaton", version="0.2", url="http://recherche.telecom-bretagne.eu/xaal/documentation/", unsupportedAttributes={}, unsupportedMethods={}, unsupportedNotifications={} } device["addr"] = xAAL_Lua_declare_device(device) -- Assume xAAL_Lua_parameter contains a table named conf -- with a period in seconds and a lamp address assert(loadstring(xAAL_Lua_parameter))() -- A filter accepting no one xAAL_Lua_filter_broadcast_by_source(device["addr"], { "00000000-0000-0000-0000-000000000000" }) -- Declare it, but empty (I do not expect messages) function xAAL_Lua_receive_callback(dev, msg) print("message!") end -- Main of the job function xAAL_Lua_alarm_callback(dev, parameter) if ( parameter == "on" ) then xAAL_Lua_write_bus(dev, "request", "on", {}, { conf["lamp"] } ) xAAL_Lua_set_alarm(conf["period"], dev, "off") else xAAL_Lua_write_bus(dev, "request", "off", {}, { conf["lamp"] } ) xAAL_Lua_set_alarm(conf["period"], dev, "on") end end -- Bootstrap xAAL_Lua_set_alarm(conf["period"], device["addr"], "on")