livebox:hah_plugboard_v2

Differences

This shows you the differences between two versions of the page.

Link to this comparison view

Both sides previous revision Previous revision
Next revision
Previous revision
livebox:hah_plugboard_v2 [2013/12/27 03:27] – [Basics] brettlivebox:hah_plugboard_v2 [2015/01/20 00:37] (current) – [BSC] Explain input/output direction values. brett
Line 167: Line 167:
 ^^ **Return Type** ^^ **Method** ^^ **Description** ^^ ^^ **Return Type** ^^ **Method** ^^ **Description** ^^
 || Filter || xap.Filter(filter) || Constructor || || Filter || xap.Filter(filter) || Constructor ||
 +|| void || <obj>:destroy() || Destructor ||
 || void || <obj>:add(section,key,value) || A condition matching an inbound xAP message, as many filters as needed can be added to the Filter object for matching. || || void || <obj>:add(section,key,value) || A condition matching an inbound xAP message, as many filters as needed can be added to the Filter object for matching. ||
 +|| void || <obj>:delete(section,key,value) || Removing a matching condition from a filter ||
 || void || <obj>:callback(function, userdata) || When all the filter conditions are met invoke the function, the function has a single parameter this is the FRAME matched by the filters.  The function passed will receive as parameters (frame, userdata) || || void || <obj>:callback(function, userdata) || When all the filter conditions are met invoke the function, the function has a single parameter this is the FRAME matched by the filters.  The function passed will receive as parameters (frame, userdata) ||
  
Line 229: Line 231:
 end end
  
-xap.init("dbzoo.lua.test","FF00CC00")+xap.init{instance="test",uid="FF00CC00"}
 f = xap.Filter() f = xap.Filter()
 f:add("xap-hbeat","source",xap.FILTER_ANY) f:add("xap-hbeat","source",xap.FILTER_ANY)
Line 256: Line 258:
  
 <code lua> <code lua>
 +require "xap"
 elapsed = 0 elapsed = 0
  
-function tick(self)+function tick(self, userdata)
   elapsed = elapsed + self.interval   elapsed = elapsed + self.interval
   print("Tick "..elapsed)   print("Tick "..elapsed)
   if elapsed > 10 then   if elapsed > 10 then
-    print(self.userdata)+    print(userdata)
     self:stop()     self:stop()
   end     end  
Line 268: Line 271:
  
 xap.Timer(tick, 2, "user data!"):start() xap.Timer(tick, 2, "user data!"):start()
 +xap.process()
 </code> </code>
  
Line 320: Line 324:
 end end
  
-xap.init("dbzoo.lua.socket","FF00CC00","br0")+xap.init{instance="socket",uid="FF00CC00"}
  
 print("Binding to host '" ..host.. "' and port " ..port.. "...") print("Binding to host '" ..host.. "' and port " ..port.. "...")
Line 370: Line 374:
 ^^ **Return Type** ^^ **Method** ^^ **Description** ^^ ^^ **Return Type** ^^ **Method** ^^ **Description** ^^
 || Endpoint || Endpoint(table) || Constructor: a container to hold endpoints || || Endpoint || Endpoint(table) || Constructor: a container to hold endpoints ||
 +|| nil || <obj>:destroy() || Destructor: remove the endpoint from existence ||
 || nil || <obj>:sendEvent() || Send xAPBSC.event for this endpoint || || nil || <obj>:sendEvent() || Send xAPBSC.event for this endpoint ||
 || nil || <obj>:sendInfo() || Send xAPBSC.info for this endpoint || || nil || <obj>:sendInfo() || Send xAPBSC.info for this endpoint ||
Line 384: Line 389:
 More about the Endpoint(table) constructor.  The key for the table may be one of the following: More about the Endpoint(table) constructor.  The key for the table may be one of the following:
  
-**name**: The unique, within the xAP source address, identifier for the endpoint.+**name** : Append the endpoint name. Completes the triple; vendorid.deviceid.instance(:name)
  
-**direction**: Has two possible values bsc.INPUT and bsc.OUTPUT+**instance**: xAP address for the endpoint.  Completes the triple; vendorid.deviceid.(instance) 
 + 
 +**direction**: Has two possible values bsc.INPUT and bsc.OUTPUT.  An OUTPUT endpoint will respond to xAPBSC.cmd events, INPUTS will not.
  
 **type**: BSC supports 3 endpoint types: bsc.STREAM, bsc.LEVEL and bsc.BINARY **type**: BSC supports 3 endpoint types: bsc.STREAM, bsc.LEVEL and bsc.BINARY
Line 407: Line 414:
  
 **displaytext** An additional parameter that may be include in an EVENT of INFO message, configurable with a infoEventCB callback function. **displaytext** An additional parameter that may be include in an EVENT of INFO message, configurable with a infoEventCB callback function.
- 
-**source** The fully qualified target endpoint name. Such as dbzoo.livebox.plugboard:relay.1 
  
 **uid** UID key.  If nothing is provide one will be automatically assigned based on the order of BSC endpoints created so far. **uid** UID key.  If nothing is provide one will be automatically assigned based on the order of BSC endpoints created so far.
Line 430: Line 435:
 end end
  
-xap.init("dbzoo.livebox.test","FF0CC000")+xap.init{instance="test",uid="FF0CC000"}
  
 +-- Form 1 : Constructed using the xAP address from xap.init()
 +-- creates -> dbzoo.livebox.test:lcd, dbzoo.livebox.test:relay.1 etc..
 bsc.Endpoint{name="lcd", direction=bsc.OUTPUT, type=bsc.STREAM, cmdCB=lcdCmd} bsc.Endpoint{name="lcd", direction=bsc.OUTPUT, type=bsc.STREAM, cmdCB=lcdCmd}
 bsc.Endpoint{name="relay.1", direction=bsc.OUTPUT, type=bsc.BINARY, cmdCB=relayCmd, infoEventCB=relayInfoEvent} bsc.Endpoint{name="relay.1", direction=bsc.OUTPUT, type=bsc.BINARY, cmdCB=relayCmd, infoEventCB=relayInfoEvent}
 bsc.Endpoint{name="relay.2", direction=bsc.OUTPUT, type=bsc.BINARY, cmdCB=relayCmd} bsc.Endpoint{name="relay.2", direction=bsc.OUTPUT, type=bsc.BINARY, cmdCB=relayCmd}
 +
 +-- Form 2 : vendorid and deviceid default, remaining from instance is appended
 +-- creates -> dbzoo.livebox.my:relay.3
 +bsc.Endpoint{instance="my:relay.3", direction=bsc.OUTPUT, type=bsc.BINARY, cmdCB=relayCmd}
 +
 +-- Form 3 : vendorid defaults, override deviceid.
 +-- creates -> dbzoo.test.my:relay.4
 +bsc.Endpoint{deviceid="test", instance="my:relay.4", direction=bsc.OUTPUT, type=bsc.BINARY, cmdCB=relayCmd}
 +
 +-- Form 4 : full override all keys
 +-- creates -> hello.test.my:relay.4
 +bsc.Endpoint{vendorid="hello", deviceid="test", instance="my:relay.4", direction=bsc.OUTPUT, type=bsc.BINARY, cmdCB=relayCmd}
 +
 +-- Form 5 : Shorter way of doing form 4.
 +-- creates -> helloworld.test.my:relay.5
 +bsc.Endpoint{source="hithere.test.my:relay.5", direction=bsc.OUTPUT, type=bsc.BINARY, cmdCB=relayCmd}
  
 xap.process() xap.process()
Line 462: Line 485:
  
 function init() function init()
-  local e = bsc.Endpoint{source="dbzoo.livebox.Plugboard:gc", direction=bsc.INPUT, type=bsc.STREAM}+  -- Creates:  dbzoo.livebox.Plugboard:gc 
 +  local e = bsc.Endpoint{name="gc", direction=bsc.INPUT, type=bsc.STREAM}
   xap.Timer(update, 60, e):start()   xap.Timer(update, 60, e):start()
 end end
Line 506: Line 530:
 require("xap.bsc") require("xap.bsc")
  
-xap.init("dbzoo.livebox.test","FF00AA00")+xap.init{instance="test",uid="FF00AA00"}
  
 bsc.sendState("dbzoo.livebox.Controller:relay.1", "on") bsc.sendState("dbzoo.livebox.Controller:relay.1", "on")
Line 535: Line 559:
 The **init()** function will be invoked when the applet is loaded by the plugboard.lua script. The **init()** function will be invoked when the applet is loaded by the plugboard.lua script.
  
-To be automatically loaded they must be placed in the /etc/plugboard directory and have the suffix Applet.lua.  Example file names:+**To be automatically loaded they must be placed in the /etc/plugboard directory and have the suffix Applet.lua.**  Example file names:
   * hbeatWatchdogApplet.lua   * hbeatWatchdogApplet.lua
   * bindRelaysApplet.lua   * bindRelaysApplet.lua
Line 559: Line 583:
 end end
  
-xap.init("dbzoo.lua.example","FF00DD00")+xap.init{instance="example",uid="FF00DD00"}
 init() init()
 xap.process() xap.process()
  • livebox/hah_plugboard_v2.1388114846.txt.gz
  • Last modified: 2013/12/27 03:27
  • by brett