aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--conf.d/project/etc/sig-doors.json45
-rw-r--r--conf.d/project/etc/sources.json10
-rw-r--r--conf.d/project/lua.d/signal-composer-daemon-01-init.lua47
-rw-r--r--conf.d/project/lua.d/signal-composer-daemon-03-controls.lua48
-rw-r--r--conf.d/project/lua.d/signal-composer-daemon-04-oncall.lua16
-rw-r--r--conf.d/project/lua.d/signal-composer-daemon-10-event.lua14
-rw-r--r--signal-composer-binding/signal-composer.cpp4
7 files changed, 26 insertions, 158 deletions
diff --git a/conf.d/project/etc/sig-doors.json b/conf.d/project/etc/sig-doors.json
index 427269a..98cec4e 100644
--- a/conf.d/project/etc/sig-doors.json
+++ b/conf.d/project/etc/sig-doors.json
@@ -5,80 +5,56 @@
"uid": "rear_left_window",
"event": "low-can/messages.windows.rear_left.open",
"onReceived": {
- "function": "plugin://low-can-callbacks/isOpen",
- "args": {
- "ojoi": "pok"
- }
+ "function": "plugin://low-can-callbacks/isOpen"
}
},
{
"uid": "rear_left_door",
"event": "low-can/messages.doors.rear_left.open",
"onReceived": {
- "function": "plugin://low-can-callbacks/isOpen",
- "args": {
- "ojoi": "pok"
- }
+ "function": "plugin://low-can-callbacks/isOpen"
}
},
{
"uid": "rear_right_window",
"event": "low-can/messages.windows.rear_right.open",
"onReceived": {
- "function": "plugin://low-can-callbacks/isOpen",
- "args": {
- "ojoi": "pok"
- }
+ "function": "plugin://low-can-callbacks/isOpen"
}
},
{
"uid": "rear_right_door",
"event": "low-can/messages.doors.rear_right.open",
"onReceived": {
- "function": "plugin://low-can-callbacks/isOpen",
- "args": {
- "ojoi": "pok"
- }
+ "function": "plugin://low-can-callbacks/isOpen"
}
},
{
"uid": "front_left_window",
"event": "low-can/messages.windows.front_left.open",
"onReceived": {
- "function": "plugin://low-can-callbacks/isOpen",
- "args": {
- "ojoi": "pok"
- }
+ "function": "plugin://low-can-callbacks/isOpen"
}
},
{
"uid": "front_left_door",
"event": "low-can/messages.doors.front_left.open",
"onReceived": {
- "function": "plugin://low-can-callbacks/isOpen",
- "args": {
- "ojoi": "pok"
- }
+ "function": "plugin://low-can-callbacks/isOpen"
}
},
{
"uid": "front_right_window",
"event": "low-can/messages.windows.front_right.open",
"onReceived": {
- "function": "plugin://low-can-callbacks/isOpen",
- "args": {
- "ojoi": "pok"
- }
+ "function": "plugin://low-can-callbacks/isOpen"
}
},
{
"uid": "front_right_door",
"event": "low-can/messages.doors.front_right.open",
"onReceived": {
- "function": "plugin://low-can-callbacks/isOpen",
- "args": {
- "ojoi": "pok"
- }
+ "function": "plugin://low-can-callbacks/isOpen"
}
},
{
@@ -88,10 +64,7 @@
"rear_left_door"
],
"onReceived": {
- "function": "plugin://low-can-callbacks/isOpen",
- "args": {
- "ojoi": "pok"
- }
+ "function": "plugin://low-can-callbacks/isOpen"
}
},
{
diff --git a/conf.d/project/etc/sources.json b/conf.d/project/etc/sources.json
index 84a39fa..7da3b95 100644
--- a/conf.d/project/etc/sources.json
+++ b/conf.d/project/etc/sources.json
@@ -6,10 +6,7 @@
"api": "low-can",
"info": "Low level binding to handle CAN bus communications",
"getSignals": {
- "function": "plugin://low-can-callbacks/subscribeToLow",
- "args": {
- "arg": "first argument"
- }
+ "function": "plugin://low-can-callbacks/subscribeToLow"
}
},
{
@@ -23,10 +20,7 @@
}
},
"getSignals": {
- "function": "lua://_Simple_Echo_Args",
- "args": {
- "arg": "first argument"
- }
+ "function": "lua://_Simple_Echo_Args"
}
},
{
diff --git a/conf.d/project/lua.d/signal-composer-daemon-01-init.lua b/conf.d/project/lua.d/signal-composer-daemon-01-init.lua
deleted file mode 100644
index 0b8a923..0000000
--- a/conf.d/project/lua.d/signal-composer-daemon-01-init.lua
+++ /dev/null
@@ -1,47 +0,0 @@
---[[
- Copyright (C) 2016 "IoT.bzh"
- Author Fulup Ar Foll <fulup@iot.bzh>
-
- Licensed under the Apache License, Version 2.0 (the "License");
- you may not use this file except in compliance with the License.
- You may obtain a copy of the License at
-
- http://www.apache.org/licenses/LICENSE-2.0
-
- Unless required by applicable law or agreed to in writing, software
- distributed under the License is distributed on an "AS IS" BASIS,
- WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- See the License for the specific language governing permissions and
- limitations under the License.
---]]
-
--- Global variable SHOULD start with _
-_Global_Context={}
-
---[[
- This function is call during controller init phase as describe in onload-daemon-sample.json
- It receives two argument 1st one is the source (here on load) second one is the arguments
- as expose in config file.
-
- In this sample we create an event that take the name of args["zzzz"], the resulting handle
- is save into _Global_Context for further use.
-
- Note: init functions are not call from a client and thus do not receive query
---]]
-
-function _Sample_Controller_Init(source, control)
-
- printf ("[-- Sample_Controller_Init --] source=%d control=%s", source, Dump_Table(control))
-
- -- if no argument return now
- if (control==nil or control["zzzz"]==nil) then
- printf ("[-- Sample_Controller_Init --] no event name given")
- return
- end
-
- -- set a count to make more visible each call
- _Global_Context["counter"]=0
-
- -- just for fun create an event
- _Global_Context["event"]=AFB:evtmake(control["zzzz"])
-end
diff --git a/conf.d/project/lua.d/signal-composer-daemon-03-controls.lua b/conf.d/project/lua.d/signal-composer-daemon-03-controls.lua
deleted file mode 100644
index cc13e0f..0000000
--- a/conf.d/project/lua.d/signal-composer-daemon-03-controls.lua
+++ /dev/null
@@ -1,48 +0,0 @@
---[[
- Copyright (C) 2016 "IoT.bzh"
- Author Fulup Ar Foll <fulup@iot.bzh>
-
- Licensed under the Apache License, Version 2.0 (the "License");
- you may not use this file except in compliance with the License.
- You may obtain a copy of the License at
-
- http://www.apache.org/licenses/LICENSE-2.0
-
- Unless required by applicable law or agreed to in writing, software
- distributed under the License is distributed on an "AS IS" BASIS,
- WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- See the License for the specific language governing permissions and
- limitations under the License.
-
- Following function are called when a client activate a control with
- controller api -> APi=control VERB=dispatch
- arguments are
- - source (0) when requesting the control (-1) when releasing
- - control comme from config given with 'args' in onload-middlename-xxxxx.json
- - client is the argument part of the query as providing by client requesting the control.
-
---]]
-
-
-
--- Simple Happy(granted) Control
-function _Button_Happy(source, control, client)
-
- -- print argument to make sure we understant what we get
- printf ("[-- _Button_Happy --] source=%d control=%s client=%s", source, Dump_Table(control), Dump_Table(client))
-
- AFB:notice ("[-- _Button_Happy --] To Be Done")
-
- return 0 -- control granted
-end
-
-
--- Simple UnHappy(debu) Control
-function _Button_UnHappy(source, control, client)
-
- -- print argument to make sure we understant what we get
- printf ("[-- _Button_UnHappy --] source=%d control=%s client=%s", source, Dump_Table(client), Dump_Table(control))
-
- AFB:error ("[-- _Button_UnHappy --] To Be Done")
- return 1 -- control is refused
-end
diff --git a/conf.d/project/lua.d/signal-composer-daemon-04-oncall.lua b/conf.d/project/lua.d/signal-composer-daemon-04-oncall.lua
index 71df908..581343e 100644
--- a/conf.d/project/lua.d/signal-composer-daemon-04-oncall.lua
+++ b/conf.d/project/lua.d/signal-composer-daemon-04-oncall.lua
@@ -74,7 +74,7 @@ end
-- Display receive arguments and echo them to caller
function _Simple_Echo_Args (source, args, event)
_count=_count+1
- AFB:notice("LUA OnCall Echo Args count=%d args=%s event=%s", count, args, event)
+ AFB:notice(source, "LUA OnCall Echo Args count=%d args=%s event=%s", count, args, event)
print ("--inlua-- source=", Dump_Table(source))
print ("--inlua-- args=", Dump_Table(args))
@@ -95,7 +95,7 @@ local function Test_Async_CB (request, result, context)
["context"]=context,
}
- AFB:notice ("Test_Async_CB result=%s context=%s", result, context)
+ AFB:notice (source, "Test_Async_CB result=%s context=%s", result, context)
AFB:success (request, response)
end
@@ -105,18 +105,18 @@ function _Test_Call_Async (request, args)
["value2"]=1234
}
- AFB:notice ("Test_Call_Async args=%s cb=Test_Async_CB", args)
- AFB:service("monitor","ping", "Test_Async_CB", context)
+ AFB:notice (source, "Test_Call_Async args=%s cb=Test_Async_CB", args)
+ AFB:service(source, "monitor","ping", "Test_Async_CB", context)
end
function _Simple_Monitor_Call (request, args)
- AFB:notice ("_Simple_Server_Call args=%s", args)
- local err, result= AFB:servsync ("monitor","get", args)
+ AFB:notice (source, "_Simple_Server_Call args=%s", args)
+ local err, result= AFB:servsync (source, "monitor","get", args)
if (err) then
- AFB:fail ("AFB:service_call_sync fail");
+ AFB:fail (source, "AFB:service_call_sync fail");
else
- AFB:success (request, result["response"])
+ AFB:success(source, request, result["response"])
end
end
diff --git a/conf.d/project/lua.d/signal-composer-daemon-10-event.lua b/conf.d/project/lua.d/signal-composer-daemon-10-event.lua
index 474ebe0..7724dec 100644
--- a/conf.d/project/lua.d/signal-composer-daemon-10-event.lua
+++ b/conf.d/project/lua.d/signal-composer-daemon-10-event.lua
@@ -24,11 +24,11 @@ _MyContext={}
-- WARNING: call back are global and should start with '_'
function _Timer_Test_CB (timer, context)
- local evtinfo= AFB:timerget(timer)
+ local evtinfo= AFB:timerget(source, timer)
printf ("[-- _Timer_Test_C --] evtInfo=%s", Dump_Table(evtinfo))
--send an event an event with count as value
- AFB:evtpush (_MyContext["event"], {["label"]= evtinfo["label"], ["count"]=evtinfo["count"], ["info"]=context["info"]})
+ AFB:evtpush (source, _MyContext["event"], {["label"]= evtinfo["label"], ["count"]=evtinfo["count"], ["info"]=context["info"]})
-- note when timerCB return!=0 timer is kill
return 0
@@ -44,7 +44,7 @@ function _Simple_Timer_Test (request, client)
-- if event does not exit create it now.
if (_MyContext["event"] == nil) then
- _MyContext["event"]= AFB:evtmake(client["label"])
+ _MyContext["event"]= AFB:evtmake(source, client["label"])
end
-- if delay not defined default is 5s
@@ -59,16 +59,16 @@ function _Simple_Timer_Test (request, client)
["delay"]=client["delay"],
["count"]=client["count"],
}
- AFB:notice ("Test_Timer myTimer=%s", myTimer)
+ AFB:notice (source, "Test_Timer myTimer=%s", myTimer)
-- subscribe to event
- AFB:subscribe (request, _MyContext["event"])
+ AFB:subscribe (source, request, _MyContext["event"])
-- settimer take a table with delay+count as input (count==0 means infinite)
- AFB:timerset (myTimer, "_Timer_Test_CB", context)
+ AFB:timerset (source, myTimer, "_Timer_Test_CB", context)
-- nothing special to return send back
- AFB:success (request, myTimer)
+ AFB:success (source, request, myTimer)
return 0
end
diff --git a/signal-composer-binding/signal-composer.cpp b/signal-composer-binding/signal-composer.cpp
index 0fb3f3d..e6a2963 100644
--- a/signal-composer-binding/signal-composer.cpp
+++ b/signal-composer-binding/signal-composer.cpp
@@ -649,10 +649,6 @@ int Composer::loadConfig(const std::string& filepath)
int err= CtlLoadSections(nullptr, ctlConfig_, ctlSections_);
return err;
-
-// ctlConfig_ = CtlConfigLoad(filepath.c_str(), ctlSections_);
-// if(ctlConfig_ != nullptr) {return 0;}
-// return -1;
}
int Composer::loadSources(json_object* sourcesJ)