From b65178642727536972d0c04e53b2310be58beb2e Mon Sep 17 00:00:00 2001 From: fulup Date: Fri, 11 Aug 2017 19:44:21 +0200 Subject: Almost working version with Json Config, Lua script and sharelib callbacks. --- conf.d/cmake/config.cmake | 4 +- conf.d/ctl-rules/onload-control-policy.json | 109 +++++++++++++++------------- conf.d/ctl-rules/onload-control-script.lua | 9 ++- 3 files changed, 66 insertions(+), 56 deletions(-) (limited to 'conf.d') diff --git a/conf.d/cmake/config.cmake b/conf.d/cmake/config.cmake index 63c83b8..e70fb62 100644 --- a/conf.d/cmake/config.cmake +++ b/conf.d/cmake/config.cmake @@ -56,7 +56,7 @@ set (gcc_minimal_version 4.9) # PKG_CONFIG required packages # ----------------------------- set (PKG_REQUIRED_LIST - alsa + alsa>=1.1.2 libsystemd>=222 libmicrohttpd>=0.9.55 afb-daemon @@ -71,7 +71,7 @@ set (PKG_REQUIRED_LIST add_compile_options(-DCONTROL_CONFIG_FILE="onload-control-policy.json") add_compile_options(-DCONTROL_CONFIG_PATH="${CMAKE_SOURCE_DIR}/conf.d:${CMAKE_INSTALL_PREFIX}/${PROJECT_NAME}/config") - add_compile_options(-DCONTROL_LUA_PATH="${CMAKE_SOURCE_DIR}/data:/etc/default/${PROJECT_NAME}/lua:${CMAKE_INSTALL_PREFIX}/${PROJECT_NAME}/lua") + add_compile_options(-DCONTROL_LUA_PATH="${CMAKE_SOURCE_DIR}/conf.d:/etc/default/${PROJECT_NAME}/lua:${CMAKE_INSTALL_PREFIX}/${PROJECT_NAME}/lua") set (CTL_PLUGIN_PRE "audio-") diff --git a/conf.d/ctl-rules/onload-control-policy.json b/conf.d/ctl-rules/onload-control-policy.json index 5c0c232..b5d4503 100644 --- a/conf.d/ctl-rules/onload-control-policy.json +++ b/conf.d/ctl-rules/onload-control-policy.json @@ -13,8 +13,11 @@ { "label": "onload-sample-cb", "info": "Call control sharelib install entrypoint", - "callback": "SamplePolicyInstall", - "args": {"arg1" : "first_arg", "nextarg": "second arg value"} + "callback": "SamplePolicyInit", + "args": { + "arg1": "first_arg", + "nextarg": "second arg value" + } }, { "label": "onload-sample-api", "info": "Assert AlsaCore Presence", @@ -30,70 +33,76 @@ ] }, "controls": - [{ + [ + { "label": "multimedia", "actions": [ { "label": "multimedia-control-cb", "info": "Call Sharelib Sample Callback", - "callback": "samplePolicyCB", + "callback": "sampleControlMultimedia", "args": { - "arg1": "snoopy", - "arg2": "toto" + "arg1": "snoopy", + "arg2": "toto" } }, { "label": "multimedia-control-ucm", "info": "Subcall AlSA UCM navigation", "api": "alsacore", - "verb": "ucmset", + "verb": "ping", "args": { - "verb": "multimedia" + "select": "multimedia" } - } - ] - }, - { - "label":"navigation", - "action" : { - "api": "alsacore", - "verb": "ucmset", - "args": { - "verb": "navigation" - }, - "optional": true, - "timeout": 100 - } + }] + }, { + "label": "navigation", + "actions": [ { + "label": "multimedia-control-cb", + "info": "Call Sharelib Sample Callback", + "callback": "sampleControlNavigation", + "args": { + "arg1": "snoopy", + "arg2": "toto" + } + }, { + "label": "navigation-control-ucm", + "api": "alsacore", + "verb": "ping", + "args": { + "select": "navigation" + } + }] }, { - "label":"emergency", - "action": { - "api": "alsacore", - "verb": "ucmset", + "label": "emergency", + "actions": [{ + "label": "emergency-control-ucm", + "api": "alsacore", + "verb": "ping", + "args": { + "select": "emergency" + } + }] + } + ], + "events": + { + "label": "SampleEvent", + "info": "define action when receiving a given event", + "actions": [ + { + "label": "Event Callback-1", + "callback": "SampleControlEvent", "args": { - "verb": "emergency" + "arg": "action-1" + } + }, { + "label": "Event Callback-2", + "callback": "SampleControlEvent", + "args": { + "arg": "action-2" } } - }] - , - "events": [ - { - "label": "SampleEvent", - "comment": "define action when receiving a given event", - "actions": [ - { - "info": "Event Callback-1", - "callback": "ProcessEventCB", - "args": { - "arg": "action-1" - } - }, { - "info": "Event Callback-2", - "callback": "ProcessEventCB", - "args": { - "arg": "action-2" - } - } - ] - } - ] + ] + } } diff --git a/conf.d/ctl-rules/onload-control-script.lua b/conf.d/ctl-rules/onload-control-script.lua index f50bf7a..6cc85fa 100644 --- a/conf.d/ctl-rules/onload-control-script.lua +++ b/conf.d/ctl-rules/onload-control-script.lua @@ -78,8 +78,10 @@ function Test_Binder_Call_Sync () end -function Ping_Test(...) +function Test_Lua_Engine(request, ...) + + AFB:NOTICE ("In est_Lua_Engine"); print ("Ping_Test script arguments:"); for i,v in ipairs(arg) @@ -87,9 +89,8 @@ function Ping_Test(...) print(" -- ", tostring(v)) end - -- push response to client - AFB:success (true, 1234, "ABCD"); - + -- return OK + return 0 end -- cgit 1.2.3-korg