Differences
This shows you the differences between two versions of the page.
Both sides previous revision Previous revision Next revision | Previous revision | ||
livebox:hah_plugboard_v2 [2012/05/12 19:05] – [Basics] minerva9 | livebox:hah_plugboard_v2 [2015/01/20 00:37] (current) – [BSC] Explain input/output direction values. brett | ||
---|---|---|---|
Line 70: | Line 70: | ||
===== Basics ===== | ===== Basics ===== | ||
- | The first thing to note is that using the plugboard generally takes a little personal effort. There are sample scripts available to help get you going, but it is assumed that you can prepare a script, get it onto the HAH and run it. Being familiar with tools such as FTP & vi, together with a basic knowledge of some Unix commands will make your work with the plugboard a lot easier. Best of all, once you get the basic knowledge under your belt, there is a whole world of possibility for rule based processing and actioning. | + | The first thing to note is that using the plugboard generally takes a little personal effort. There are sample scripts available to help get you going, but it is assumed that you can prepare a script, get it onto the HAH and run it. Being familiar with tools such as FTP & vi, together with a basic knowledge of some Unix commands will make your work with the plugboard a lot easier. Familiarity of how [[http:// |
There are only two calls that are needed to build an xAP Lua application. | There are only two calls that are needed to build an xAP Lua application. | ||
^^ **Return Type** ^^ **Method** ^^ **Description** ^^ | ^^ **Return Type** ^^ **Method** ^^ **Description** ^^ | ||
- | || void|| xap.init(source, | + | || void|| xap.init(source, |
+ | || void|| xap.init{vendorid=, | ||
|| void|| xap.process() || Enter the xAP processing loop || | || void|| xap.process() || Enter the xAP processing loop || | ||
|| void|| xap.send(msg) || Send RAW data on the well known xAP UDP port 3639 || | || void|| xap.send(msg) || Send RAW data on the well known xAP UDP port 3639 || | ||
|| String || xap.expandShortMsg(msg) || Inject/ | || String || xap.expandShortMsg(msg) || Inject/ | ||
|| void|| xap.sendShort(msg) || A shortcut for send(expandShortMsg(msg)) || | || void|| xap.sendShort(msg) || A shortcut for send(expandShortMsg(msg)) || | ||
+ | || String || xap.buildXapAdddress{vendorid=, | ||
+ | || String || xap.getDeviceID() || Returns the resolved deviceid, either hostname or / | ||
In its most simplistic form a basic application would look like this; It wouldn' | In its most simplistic form a basic application would look like this; It wouldn' | ||
Line 85: | Line 88: | ||
<code lua> | <code lua> | ||
require(" | require(" | ||
- | xap.init("dbzoo.lua.simple"," | + | xap.init{instance=" |
xap.process() | xap.process() | ||
</ | </ | ||
When building plugboard applets these calls won't need to be made as the plugboard engine will take care of it. They will be needed if writing standalone Lua applications something you'll do whilst in development/ | When building plugboard applets these calls won't need to be made as the plugboard engine will take care of it. They will be needed if writing standalone Lua applications something you'll do whilst in development/ | ||
- | |||
===== Frame ===== | ===== Frame ===== | ||
Line 165: | Line 167: | ||
^^ **Return Type** ^^ **Method** ^^ **Description** ^^ | ^^ **Return Type** ^^ **Method** ^^ **Description** ^^ | ||
|| Filter || xap.Filter(filter) || Constructor || | || Filter || xap.Filter(filter) || Constructor || | ||
+ | || void || < | ||
|| void || < | || void || < | ||
+ | || void || < | ||
|| void || < | || void || < | ||
Line 186: | Line 190: | ||
The constructor can also accept a set of filter patterns directly; these are equivalent. | The constructor can also accept a set of filter patterns directly; these are equivalent. | ||
- | < | + | < |
filter = xap.Filter() | filter = xap.Filter() | ||
filter: | filter: | ||
Line 227: | Line 231: | ||
end | end | ||
- | xap.init("dbzoo.lua.test"," | + | xap.init{instance=" |
f = xap.Filter() | f = xap.Filter() | ||
f: | f: | ||
Line 254: | Line 258: | ||
<code lua> | <code lua> | ||
+ | require " | ||
elapsed = 0 | elapsed = 0 | ||
- | function tick(self) | + | function tick(self, userdata) |
elapsed = elapsed + self.interval | elapsed = elapsed + self.interval | ||
print(" | print(" | ||
if elapsed > 10 then | if elapsed > 10 then | ||
- | print(self.userdata) | + | print(userdata) |
self:stop() | self:stop() | ||
end | end | ||
Line 266: | Line 271: | ||
xap.Timer(tick, | xap.Timer(tick, | ||
+ | xap.process() | ||
</ | </ | ||
Line 318: | Line 324: | ||
end | end | ||
- | xap.init("dbzoo.lua.socket"," | + | xap.init{instance=" |
print(" | print(" | ||
Line 368: | Line 374: | ||
^^ **Return Type** ^^ **Method** ^^ **Description** ^^ | ^^ **Return Type** ^^ **Method** ^^ **Description** ^^ | ||
|| Endpoint || Endpoint(table) || Constructor: | || Endpoint || Endpoint(table) || Constructor: | ||
+ | || nil || < | ||
|| nil || < | || nil || < | ||
|| nil || < | || nil || < | ||
Line 382: | Line 389: | ||
More about the Endpoint(table) constructor. | More about the Endpoint(table) constructor. | ||
- | **name**: | + | **name** : Append |
- | **direction**: | + | **instance**: |
+ | |||
+ | **direction**: | ||
**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 405: | 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: | ||
**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 428: | Line 435: | ||
end | end | ||
- | xap.init("dbzoo.livebox.test"," | + | xap.init{instance=" |
+ | -- Form 1 : Constructed using the xAP address from xap.init() | ||
+ | -- creates -> dbzoo.livebox.test: | ||
bsc.Endpoint{name=" | bsc.Endpoint{name=" | ||
bsc.Endpoint{name=" | bsc.Endpoint{name=" | ||
bsc.Endpoint{name=" | bsc.Endpoint{name=" | ||
+ | |||
+ | -- Form 2 : vendorid and deviceid default, remaining from instance is appended | ||
+ | -- creates -> dbzoo.livebox.my: | ||
+ | bsc.Endpoint{instance=" | ||
+ | |||
+ | -- Form 3 : vendorid defaults, override deviceid. | ||
+ | -- creates -> dbzoo.test.my: | ||
+ | bsc.Endpoint{deviceid=" | ||
+ | |||
+ | -- Form 4 : full override all keys | ||
+ | -- creates -> hello.test.my: | ||
+ | bsc.Endpoint{vendorid=" | ||
+ | |||
+ | -- Form 5 : Shorter way of doing form 4. | ||
+ | -- creates -> helloworld.test.my: | ||
+ | bsc.Endpoint{source=" | ||
xap.process() | xap.process() | ||
Line 460: | Line 485: | ||
function init() | function init() | ||
- | local e = bsc.Endpoint{source="dbzoo.livebox.Plugboard: | + | |
+ | | ||
xap.Timer(update, | xap.Timer(update, | ||
end | end | ||
Line 504: | Line 530: | ||
require(" | require(" | ||
- | xap.init("dbzoo.livebox.test"," | + | xap.init{instance=" |
bsc.sendState(" | bsc.sendState(" | ||
Line 533: | 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 / | + | **To be automatically loaded they must be placed in the / |
* hbeatWatchdogApplet.lua | * hbeatWatchdogApplet.lua | ||
* bindRelaysApplet.lua | * bindRelaysApplet.lua | ||
Line 557: | Line 583: | ||
end | end | ||
- | xap.init("dbzoo.lua.example"," | + | xap.init{instance=" |
init() | init() | ||
xap.process() | xap.process() |