aboutsummaryrefslogtreecommitdiffstats
path: root/conf.d
diff options
context:
space:
mode:
authorfulup <fulup.arfoll@iot.bzh>2017-08-14 00:58:57 +0200
committerfulup <fulup.arfoll@iot.bzh>2017-08-14 00:58:57 +0200
commit96f0057d65fbb90d9faa02a3ae4ae37b357094db (patch)
treee5343b6feaef5296a86cfdd0597405565b79490e /conf.d
parent9777a02c7540fdec145feb948b4bbf1cd44c3352 (diff)
Work in Progress
Diffstat (limited to 'conf.d')
-rw-r--r--conf.d/cmake/config.cmake1
-rw-r--r--conf.d/project/config.d/onload-audio-control.json6
-rw-r--r--conf.d/project/lua.d/doscript-helloworld.lua36
-rw-r--r--conf.d/project/lua.d/onload-audio-controls.lua (renamed from conf.d/project/lua.d/onload-audio-policy.lua)13
-rw-r--r--conf.d/project/lua.d/onload-audio-oncall.lua88
-rw-r--r--conf.d/project/lua.d/onload-audio-samples.lua93
-rw-r--r--conf.d/project/lua.d/onload-audio-utils.lua (renamed from conf.d/project/lua.d/helloworld-lua-script.lua)35
7 files changed, 150 insertions, 122 deletions
diff --git a/conf.d/cmake/config.cmake b/conf.d/cmake/config.cmake
index 510eb70..ff8bf38 100644
--- a/conf.d/cmake/config.cmake
+++ b/conf.d/cmake/config.cmake
@@ -69,6 +69,7 @@ set (PKG_REQUIRED_LIST
# ---------------------------------------------------------
add_compile_options(-DCONTROL_ONLOAD_DEFAULT="onload-default")
add_compile_options(-DCONTROL_MAXPATH_LEN=255)
+ add_compile_options(-DCONTROL_DOSCRIPT_PRE="doscript")
add_compile_options(-DCONTROL_CONFIG_PRE="onload")
add_compile_options(-DCONTROL_CONFIG_POST="control" )
add_compile_options(-DCONTROL_CONFIG_PATH="${CMAKE_SOURCE_DIR}/conf.d/project/config.d:${CMAKE_INSTALL_PREFIX}/controler/config.d")
diff --git a/conf.d/project/config.d/onload-audio-control.json b/conf.d/project/config.d/onload-audio-control.json
index aecf1b3..c8f9be2 100644
--- a/conf.d/project/config.d/onload-audio-control.json
+++ b/conf.d/project/config.d/onload-audio-control.json
@@ -39,7 +39,7 @@
"actions": [{
"label": "multimedia-control-lua",
"info": "Call Lua Script function Test_Lua_Engin",
- "lua": "Audio_Set_Use_Case_Multimedia",
+ "lua": "Audio_Set_Multimedia",
}]
}, {
"label": "navigation",
@@ -61,13 +61,13 @@
}, {
"label": "navigation-control-lua",
"info": "Call Lua Script to set Navigation",
- "lua": "Audio_Set_Use_Case_Navigation",
+ "lua": "Audio_Set_Navigation",
}]
}, {
"label": "emergency",
"actions": [{
"label": "emergency-control-ucm",
- "lua": "Audio_Set_Use_Case_Emergency",
+ "lua": "Audio_Set_Emergency",
}]
}
],
diff --git a/conf.d/project/lua.d/doscript-helloworld.lua b/conf.d/project/lua.d/doscript-helloworld.lua
new file mode 100644
index 0000000..b70ba8d
--- /dev/null
+++ b/conf.d/project/lua.d/doscript-helloworld.lua
@@ -0,0 +1,36 @@
+--[[
+ 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.
+
+
+ Simple API script to be use with AGL control LuaDoCall API
+ - After the script is loaded by lua_docall
+ - Controller start function=xxxx where xxxx is taken from script filename doscript-xxxx-anything
+
+--]]
+
+function helloworld (request, query)
+
+ AFB:notice ("LUA HelloWorld: simple test query=%s", query);
+
+ if (query == nil) then
+ AFB:error ("LUA HelloWorld:FX query should not be empty");
+ AFB:fail (request, "LUA HelloWorld: query should not be empty");
+ else
+ AFB:error ("LUA HelloWorld:OK query=%s", query);
+ AFB:sucess (request, {arg0="Demat", arg1="Bonjours", arg2="Gootentag", arg3="Morning"});
+ end
+
+end \ No newline at end of file
diff --git a/conf.d/project/lua.d/onload-audio-policy.lua b/conf.d/project/lua.d/onload-audio-controls.lua
index 0b7c358..eb6a61b 100644
--- a/conf.d/project/lua.d/onload-audio-policy.lua
+++ b/conf.d/project/lua.d/onload-audio-controls.lua
@@ -37,10 +37,15 @@ end
function Audio_Set_Navigation(args, query)
- AFB:notice ("--LUA:Audio_Set_Use_Case args=%s query=%s", args, query, {myint=1234, mystring="abcd"});
- -- Print_Table("args", args)
-
-
+ AFB:notice ("--LUA:Audio_Set_Use_Case args=%s query=%s", args, query);
+
+ -- synchronous call to alsacore service
+ local error,data= AFB:callsync ('alsacore', 'ping', {})
+ if (error) then
+ AFB:error ("--LUA:Audio_Set_Use_Case FAIL args=%s", args)
+ else
+ AFB:notice ("--LUA:Audio_Set_Use_Case DONE args=%s response=%s", args, data["response"])
+ end
-- return OK
return 0
diff --git a/conf.d/project/lua.d/onload-audio-oncall.lua b/conf.d/project/lua.d/onload-audio-oncall.lua
new file mode 100644
index 0000000..22cba85
--- /dev/null
+++ b/conf.d/project/lua.d/onload-audio-oncall.lua
@@ -0,0 +1,88 @@
+--[[
+ 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.
+
+
+ Provide sample LUA routines to be used with AGL control "lua_docall" API
+--]]
+
+-- global counter to keep track of calls
+count=0
+
+-- Adjust Volume function of vehicle speed
+function Oncall_Helloworld (request, args)
+ count=count+1
+
+ AFB:notice("LUA OnCall Helloworld count=%d args=%s", count, args);
+ AFB:success (request, {"count"=count})
+end
+
+function Test_Async_CB (request, result, context)
+
+ AFB:notice ("Test_Async_CB result=%s context=%s", result, context)
+ AFB:success (request, {"response"=result, "context"=context})
+end
+
+function Test_Call_Async (request, args)
+ local context={
+ "value1"="abcd",
+ "value2"=1234
+ }
+
+ AFB:notice ("Test_Call_Async args=%s", args)
+ AFB:service("alsacore","ping", args, "Test_Async_CB", context)
+end
+
+function Test_Call_Sync (request, args)
+
+ AFB:notice ("Test_Call_Sync args=%s", args)
+ local err, response= AFB:service_sync ("alsacore","ping", args)
+ if (err) then
+ AFB:fail ("AFB:service_call_sync fail");
+ else
+ AFB:success (request, response)
+ end
+end
+
+-- create a new event name
+function Test_Event_Make (request, args)
+
+ AFB:notice ("Test_Event_Make args=%s", args)
+ local err eventFD AFB:event (args["evtname"])
+ if (err) then
+ AFB:fail ("AFB:Test_Event_Make fail event=%s", args["evtname"]);
+ else
+ AFB:success (request, {})
+ end
+
+ local evtData = {
+ val1="My 1st private Event",
+ val2=5678
+ }
+
+ AFB:notify (eventFD, evtData)
+end
+
+-- send an event on default binder event
+function Test_Event_Notify (request, args)
+
+ AFB:notice ("Test_Event_Notify args=%s", args)
+ local err AFB:notify (args)
+ if (err) then
+ AFB:fail ("AFB:Test_Event_Make fail event=%s", args["evtname"]);
+ else
+ AFB:success (request, {})
+ end
+end
diff --git a/conf.d/project/lua.d/onload-audio-samples.lua b/conf.d/project/lua.d/onload-audio-samples.lua
deleted file mode 100644
index 055a15d..0000000
--- a/conf.d/project/lua.d/onload-audio-samples.lua
+++ /dev/null
@@ -1,93 +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.
-
-
- Provide sample policy function for AGL Advance Audio Agent
---]]
-
-count=0
-
--- Adjust Volume function of vehicle speed
-function Adjust_Volume_Speed (request, speed_meters_second)
-
- AFB:notice("In Adjust_Volume_Speed speed=%d", speed_meters_second);
-
- print (string.format("*****(From Lua) Adjust_Volume_Speed speed=%d count=%d", speed_meters_second, count));
-
- -- compute volume
- volume = speed_meters_second * 2
- count=count+1
-
- AFB:success (request, 1234, volume, count, 5678)
-end
-
-
-function Test_Binder_CB (result, context)
-
- local myTable= { ["arg1"] = "myString", ["arg2"] = 1234, ["arg4"] = true, ["arg5"] = 3.1416 }
-
- AFB:notice ("In Test_Binder_CB", result, context)
-
- AFB:success (1234, "ABCD", myTable, 5678)
-
-end
-
-function Test_Binder_Call_Async ()
-
- local query= {
- ["arg1"] = "myString",
- ["arg2"] = 1234,
- ["arg4"] = true,
- ["arg5"] = 3.1416,
- }
-
- AFB:service("alsacore","ping", query, Test_Binder_CB, "myContext")
-
-end
-
-function Test_Binder_Call_Sync ()
-
- local query= {
- ["arg1"] = "myString",
- ["arg2"] = 1234,
- ["arg4"] = true,
- ["arg5"] = 3.1416,
- }
-
- err= AFB:service_sync ("alsacore","ping", query)
-
- if (err) then
- AFB:fail ("AFB:service_call_sync fail");
- else
- AFB:success (1234, "ABCD", myTable)
- end
-
-
-end
-
--- return serialised version of printable table
-function Dump_Table(o)
- if type(o) == 'table' then
- local s = '{ '
- for k,v in pairs(o) do
- if type(k) ~= 'number' then k = '"'..k..'"' end
- s = s .. '['..k..'] = ' .. Dump_Table(v) .. ','
- end
- return s .. '} '
- else
- return tostring(o)
- end
-end
diff --git a/conf.d/project/lua.d/helloworld-lua-script.lua b/conf.d/project/lua.d/onload-audio-utils.lua
index 7dd0459..40ef8a3 100644
--- a/conf.d/project/lua.d/helloworld-lua-script.lua
+++ b/conf.d/project/lua.d/onload-audio-utils.lua
@@ -14,28 +14,19 @@
See the License for the specific language governing permissions and
limitations under the License.
-
- Simple API script
--]]
- -- retrieve calling arguments
- args= ...
-
- print ("Helloworld script arguments:")
-
-
- for key,value in pairs(args)
- do
- print("args: ", key,value)
- end
-
- -- loop on script arguments
- --for i=1,#args
- --do
- -- print(" -- ", i, args[i])
- --end
-
-
- -- return two arguments on top of status
- return true, 1234, "ABCD", 5678
+-- return serialised version of printable table
+function Dump_Table(o)
+ if type(o) == 'table' then
+ local s = '{ '
+ for k,v in pairs(o) do
+ if type(k) ~= 'number' then k = '"'..k..'"' end
+ s = s .. '['..k..'] = ' .. Dump_Table(v) .. ','
+ end
+ return s .. '} '
+ else
+ return tostring(o)
+ end
+end