diff options
-rw-r--r-- | afb-source/CMakeLists.txt | 2 | ||||
-rw-r--r-- | afb-source/ctl-apidef.h | 119 | ||||
-rw-r--r-- | afb-source/ctl-apidef.json | 191 | ||||
-rw-r--r-- | afb-source/ctl-binding.c | 13 | ||||
-rw-r--r-- | conf.d/cmake/config.cmake | 2 | ||||
-rw-r--r-- | nbproject/configurations.xml | 56 |
6 files changed, 232 insertions, 151 deletions
diff --git a/afb-source/CMakeLists.txt b/afb-source/CMakeLists.txt index 4720f29..40469dc 100644 --- a/afb-source/CMakeLists.txt +++ b/afb-source/CMakeLists.txt @@ -28,7 +28,7 @@ else(CONTROL_SUPPORT_LUA) endif(CONTROL_SUPPORT_LUA) # Add target to project dependency list -PROJECT_TARGET_ADD(control-afb) +PROJECT_TARGET_ADD(controller) # Define project Targets ADD_LIBRARY(${TARGET_NAME} MODULE ctl-binding.c ctl-timer.c ctl-dispatch.c ${CTL_LUA_SOURCE}) diff --git a/afb-source/ctl-apidef.h b/afb-source/ctl-apidef.h index 9ce9e05..5738f64 100644 --- a/afb-source/ctl-apidef.h +++ b/afb-source/ctl-apidef.h @@ -1,18 +1,18 @@ -static const char _afb_description_v2_control[] = +static const char _afb_description_v2_aaaa[] = "{\"openapi\":\"3.0.0\",\"$schema\":\"http:iot.bzh/download/openapi/schem" "a-3.0/default-schema.json\",\"info\":{\"description\":\"\",\"title\":\"c" - "ontroler\",\"version\":\"1.0\",\"x-binding-c-generator\":{\"api\":\"cont" - "rol\",\"version\":2,\"prefix\":\"ctlapi_\",\"postfix\":\"\",\"start\":nu" - "ll,\"onevent\":\"DispatchOneEvent\",\"init\":\"CtlBindingInit\",\"scope\"" - ":\"\",\"private\":false}},\"servers\":[{\"url\":\"ws://{host}:{port}/api" - "/polctl\",\"description\":\"Unicens2 API.\",\"variables\":{\"host\":{\"d" - "efault\":\"localhost\"},\"port\":{\"default\":\"1234\"}},\"x-afb-events\"" - ":[{\"$ref\":\"#/components/schemas/afb-event\"}]}],\"components\":{\"sch" - "emas\":{\"afb-reply\":{\"$ref\":\"#/components/schemas/afb-reply-v2\"},\"" - "afb-event\":{\"$ref\":\"#/components/schemas/afb-event-v2\"},\"afb-reply" - "-v2\":{\"title\":\"Generic response.\",\"type\":\"object\",\"required\":" - "[\"jtype\",\"request\"],\"properties\":{\"jtype\":{\"type\":\"string\",\"" + "ontroler\",\"version\":\"1.0\",\"x-binding-c-generator\":{\"api\":\"aaaa" + "\",\"version\":2,\"prefix\":\"ctlapi_\",\"postfix\":\"\",\"start\":null," + "\"onevent\":\"DispatchOneEvent\",\"init\":\"CtlBindingInit\",\"scope\":\"" + "\",\"private\":false}},\"servers\":[{\"url\":\"ws://{host}:{port}/api/po" + "lctl\",\"description\":\"Unicens2 API.\",\"variables\":{\"host\":{\"defa" + "ult\":\"localhost\"},\"port\":{\"default\":\"1234\"}},\"x-afb-events\":[" + "{\"$ref\":\"#/components/schemas/afb-event\"}]}],\"components\":{\"schem" + "as\":{\"afb-reply\":{\"$ref\":\"#/components/schemas/afb-reply-v2\"},\"a" + "fb-event\":{\"$ref\":\"#/components/schemas/afb-event-v2\"},\"afb-reply-" + "v2\":{\"title\":\"Generic response.\",\"type\":\"object\",\"required\":[" + "\"jtype\",\"request\"],\"properties\":{\"jtype\":{\"type\":\"string\",\"" "const\":\"afb-reply\"},\"request\":{\"type\":\"object\",\"required\":[\"" "status\"],\"properties\":{\"status\":{\"type\":\"string\"},\"info\":{\"t" "ype\":\"string\"},\"token\":{\"type\":\"string\"},\"uuid\":{\"type\":\"s" @@ -20,70 +20,85 @@ static const char _afb_description_v2_control[] = "ct\"}}},\"afb-event-v2\":{\"type\":\"object\",\"required\":[\"jtype\",\"" "event\"],\"properties\":{\"jtype\":{\"type\":\"string\",\"const\":\"afb-" "event\"},\"event\":{\"type\":\"string\"},\"data\":{\"type\":\"object\"}}" - "}},\"x-permissions\":{\"monitor\":{\"permission\":\"urn:AGL:permission:a" - "udio:public:monitor\"},\"multimedia\":{\"permission\":\"urn:AGL:permissi" - "on:audio:public:monitor\"},\"navigation\":{\"permission\":\"urn:AGL:perm" - "ission:audio:public:monitor\"},\"emergency\":{\"permission\":\"urn:AGL:p" - "ermission:audio:public:emergency\"}},\"responses\":{\"200\":{\"descripti" - "on\":\"A complex object array response\",\"content\":{\"application/json" - "\":{\"schema\":{\"$ref\":\"#/components/schemas/afb-reply\"}}}}}},\"path" - "s\":{\"/monitor\":{\"description\":\"Subcribe Audio Agent Policy Control" - " End\",\"get\":{\"x-permissions\":{\"$ref\":\"#/components/x-permissions" - "/monitor\"},\"parameters\":[{\"in\":\"query\",\"name\":\"event_patern\"," - "\"required\":true,\"schema\":{\"type\":\"string\"}}],\"responses\":{\"20" - "0\":{\"$ref\":\"#/components/responses/200\"}}}},\"/dispatch\":{\"descri" - "ption\":\"Request Access to Navigation Audio Channel.\",\"get\":{\"x-per" - "missions\":{\"$ref\":\"#/components/x-permissions/navigation\"},\"parame" - "ters\":[{\"in\":\"query\",\"name\":\"zone\",\"required\":false,\"schema\"" - ":{\"type\":\"string\"}}],\"responses\":{\"200\":{\"$ref\":\"#/components" - "/responses/200\"}}}},\"/request\":{\"description\":\"Execute LUA string " - "script.\",\"get\":{\"x-permissions\":{\"$ref\":\"#/components/x-permissi" - "ons/navigation\"},\"parameters\":[{\"in\":\"query\",\"name\":\"func\",\"" - "required\":true,\"schema\":{\"type\":\"string\"}},{\"in\":\"query\",\"na" - "me\":\"args\",\"required\":false,\"schema\":{\"type\":\"array\"}}],\"res" - "ponses\":{\"200\":{\"$ref\":\"#/components/responses/200\"}}}},\"/debugl" - "ua\":{\"description\":\"Execute LUA string script.\",\"get\":{\"x-permis" - "sions\":{\"$ref\":\"#/components/x-permissions/navigation\"},\"parameter" - "s\":[{\"in\":\"query\",\"name\":\"filename\",\"required\":true,\"schema\"" - ":{\"type\":\"string\"}}],\"responses\":{\"200\":{\"$ref\":\"#/components" - "/responses/200\"}}}}}}" + "}},\"x-permissions\":{\"control\":{\"permission\":\"urn:AGL:permission:a" + "udio:public:control\"},\"dispatch\":{\"permission\":\"urn:AGL:permission" + ":audio:public:dispatch\"},\"request\":{\"permission\":\"urn:AGL:permissi" + "on:audio:public:request\"},\"debug\":{\"permission\":\"urn:AGL:permissio" + "n:audio:public:debug\"}},\"responses\":{\"200\":{\"description\":\"A com" + "plex object array response\",\"content\":{\"application/json\":{\"schema" + "\":{\"$ref\":\"#/components/schemas/afb-reply\"}}}}}},\"paths\":{\"/ping" + "\":{\"description\":\"Ping Binding\",\"get\":{\"x-permissions\":{\"$ref\"" + ":\"#/components/x-permissions/control\"},\"parameters\":[{\"in\":\"query" + "\",\"name\":\"args\",\"required\":false,\"schema\":{\"type\":\"json\"}}]" + ",\"responses\":{\"200\":{\"$ref\":\"#/components/responses/200\"}}}},\"/" + "subscribe\":{\"description\":\"Subcribe Audio Agent Policy Control End\"" + ",\"get\":{\"x-permissions\":{\"$ref\":\"#/components/x-permissions/contr" + "ol\"},\"parameters\":[{\"in\":\"query\",\"name\":\"event_patern\",\"requ" + "ired\":true,\"schema\":{\"type\":\"string\"}}],\"responses\":{\"200\":{\"" + "$ref\":\"#/components/responses/200\"}}}},\"/dispatch\":{\"description\"" + ":\"Request Access to Navigation Audio Channel.\",\"get\":{\"x-permission" + "s\":{\"$ref\":\"#/components/x-permissions/dispatch\"},\"parameters\":[{" + "\"in\":\"query\",\"name\":\"zone\",\"required\":false,\"schema\":{\"type" + "\":\"string\"}}],\"responses\":{\"200\":{\"$ref\":\"#/components/respons" + "es/200\"}}}},\"/request\":{\"description\":\"Execute LUA string script.\"" + ",\"get\":{\"x-permissions\":{\"$ref\":\"#/components/x-permissions/reque" + "st\"},\"parameters\":[{\"in\":\"query\",\"name\":\"func\",\"required\":t" + "rue,\"schema\":{\"type\":\"string\"}},{\"in\":\"query\",\"name\":\"args\"" + ",\"required\":false,\"schema\":{\"type\":\"array\"}}],\"responses\":{\"2" + "00\":{\"$ref\":\"#/components/responses/200\"}}}},\"/debuglua\":{\"descr" + "iption\":\"Execute LUA string script.\",\"get\":{\"x-permissions\":{\"$r" + "ef\":\"#/components/x-permissions/debug\"},\"parameters\":[{\"in\":\"que" + "ry\",\"name\":\"filename\",\"required\":true,\"schema\":{\"type\":\"stri" + "ng\"}}],\"responses\":{\"200\":{\"$ref\":\"#/components/responses/200\"}" + "}}}}}" ; -static const struct afb_auth _afb_auths_v2_control[] = { - { .type = afb_auth_Permission, .text = "urn:AGL:permission:audio:public:monitor" } +static const struct afb_auth _afb_auths_v2_aaaa[] = { + { .type = afb_auth_Permission, .text = "urn:AGL:permission:audio:public:control" }, + { .type = afb_auth_Permission, .text = "urn:AGL:permission:audio:public:dispatch" }, + { .type = afb_auth_Permission, .text = "urn:AGL:permission:audio:public:request" }, + { .type = afb_auth_Permission, .text = "urn:AGL:permission:audio:public:debug" } }; - void ctlapi_monitor(struct afb_req req); + void ctlapi_ping(struct afb_req req); + void ctlapi_subscribe(struct afb_req req); void ctlapi_dispatch(struct afb_req req); void ctlapi_request(struct afb_req req); void ctlapi_debuglua(struct afb_req req); -static const struct afb_verb_v2 _afb_verbs_v2_control[] = { +static const struct afb_verb_v2 _afb_verbs_v2_aaaa[] = { { - .verb = "monitor", - .callback = ctlapi_monitor, - .auth = &_afb_auths_v2_control[0], + .verb = "ping", + .callback = ctlapi_ping, + .auth = &_afb_auths_v2_aaaa[0], + .info = NULL, + .session = AFB_SESSION_NONE_V2 + }, + { + .verb = "subscribe", + .callback = ctlapi_subscribe, + .auth = &_afb_auths_v2_aaaa[0], .info = NULL, .session = AFB_SESSION_NONE_V2 }, { .verb = "dispatch", .callback = ctlapi_dispatch, - .auth = &_afb_auths_v2_control[0], + .auth = &_afb_auths_v2_aaaa[1], .info = NULL, .session = AFB_SESSION_NONE_V2 }, { .verb = "request", .callback = ctlapi_request, - .auth = &_afb_auths_v2_control[0], + .auth = &_afb_auths_v2_aaaa[2], .info = NULL, .session = AFB_SESSION_NONE_V2 }, { .verb = "debuglua", .callback = ctlapi_debuglua, - .auth = &_afb_auths_v2_control[0], + .auth = &_afb_auths_v2_aaaa[3], .info = NULL, .session = AFB_SESSION_NONE_V2 }, @@ -91,10 +106,10 @@ static const struct afb_verb_v2 _afb_verbs_v2_control[] = { }; const struct afb_binding_v2 afbBindingV2 = { - .api = "control", - .specification = _afb_description_v2_control, + .api = "aaaa", + .specification = _afb_description_v2_aaaa, .info = NULL, - .verbs = _afb_verbs_v2_control, + .verbs = _afb_verbs_v2_aaaa, .preinit = NULL, .init = CtlBindingInit, .onevent = DispatchOneEvent, diff --git a/afb-source/ctl-apidef.json b/afb-source/ctl-apidef.json index e2207d0..a8b433e 100644 --- a/afb-source/ctl-apidef.json +++ b/afb-source/ctl-apidef.json @@ -97,17 +97,17 @@ } }, "x-permissions": { - "monitor": { - "permission": "urn:AGL:permission:audio:public:monitor" + "control": { + "permission": "urn:AGL:permission:audio:public:control" }, - "multimedia": { - "permission": "urn:AGL:permission:audio:public:monitor" + "dispatch": { + "permission": "urn:AGL:permission:audio:public:dispatch" }, - "navigation": { - "permission": "urn:AGL:permission:audio:public:monitor" + "request": { + "permission": "urn:AGL:permission:audio:public:request" }, - "emergency": { - "permission": "urn:AGL:permission:audio:public:emergency" + "debug": { + "permission": "urn:AGL:permission:audio:public:debug" } }, "responses": { @@ -124,22 +124,20 @@ } }, "paths": { - "/monitor": { - "description": "Subcribe Audio Agent Policy Control End", + "/ping": { + "description": "Ping Binding", "get": { "x-permissions": { - "$ref": "#/components/x-permissions/monitor" + "$ref": "#/components/x-permissions/control" }, - "parameters": [ - { - "in": "query", - "name": "event_patern", - "required": true, - "schema": { - "type": "string" - } + "parameters": [{ + "in": "query", + "name": "args", + "required": false, + "schema": { + "type": "json" } - ], + }], "responses": { "200": { "$ref": "#/components/responses/200" @@ -147,82 +145,105 @@ } } }, - "/dispatch": { - "description": "Request Access to Navigation Audio Channel.", - "get": { - "x-permissions": { - "$ref": "#/components/x-permissions/navigation" - }, - "parameters": [ - { - "in": "query", - "name": "zone", - "required": false, - "schema": { - "type": "string" + "/subscribe": { + "description": "Subcribe Audio Agent Policy Control End", + "get": { + "x-permissions": { + "$ref": "#/components/x-permissions/control" + }, + "parameters": [ + { + "in": "query", + "name": "event_patern", + "required": true, + "schema": { + "type": "string" + } + } + ], + "responses": { + "200": { + "$ref": "#/components/responses/200" } - } - ], - "responses": { - "200": { - "$ref": "#/components/responses/200" } } - } - }, - "/request": { - "description": "Execute LUA string script.", - "get": { - "x-permissions": { - "$ref": "#/components/x-permissions/navigation" - }, - "parameters": [ - { - "in": "query", - "name": "func", - "required": true, - "schema": { - "type": "string" - } + }, + "/dispatch": { + "description": "Request Access to Navigation Audio Channel.", + "get": { + "x-permissions": { + "$ref": "#/components/x-permissions/dispatch" }, - { - "in": "query", - "name": "args", - "required": false, - "schema": { - "type": "array" + "parameters": [ + { + "in": "query", + "name": "zone", + "required": false, + "schema": { + "type": "string" + } + } + ], + "responses": { + "200": { + "$ref": "#/components/responses/200" } - } - ], - "responses": { - "200": { - "$ref": "#/components/responses/200" } } - } - }, - "/debuglua": { - "description": "Execute LUA string script.", - "get": { - "x-permissions": { - "$ref": "#/components/x-permissions/navigation" - }, - "parameters": [ - { - "in": "query", - "name": "filename", - "required": true, - "schema": { - "type": "string" + }, + "/request": { + "description": "Execute LUA string script.", + "get": { + "x-permissions": { + "$ref": "#/components/x-permissions/request" + }, + "parameters": [ + { + "in": "query", + "name": "func", + "required": true, + "schema": { + "type": "string" + } + }, + { + "in": "query", + "name": "args", + "required": false, + "schema": { + "type": "array" + } + } + ], + "responses": { + "200": { + "$ref": "#/components/responses/200" } } - ], - "responses": { - "200": { - "$ref": "#/components/responses/200" + } + }, + "/debuglua": { + "description": "Execute LUA string script.", + "get": { + "x-permissions": { + "$ref": "#/components/x-permissions/debug" + }, + "parameters": [ + { + "in": "query", + "name": "filename", + "required": true, + "schema": { + "type": "string" + } + } + ], + "responses": { + "200": { + "$ref": "#/components/responses/200" + } } } } } - } } diff --git a/afb-source/ctl-binding.c b/afb-source/ctl-binding.c index 4f6ecd3..6840b5c 100644 --- a/afb-source/ctl-binding.c +++ b/afb-source/ctl-binding.c @@ -22,13 +22,20 @@ #include "ctl-binding.h" - - // Include Binding Stub generated from Json OpenAPI #include "ctl-apidef.h" +PUBLIC void ctlapi_ping (afb_req request) { + static int count=0; + + count++; + AFB_NOTICE ("Controller:ping count=%d", count); + afb_req_success(request,json_object_new_int(count), NULL); + + return; +} -PUBLIC void ctlapi_monitor (afb_req request) { +PUBLIC void ctlapi_subscribe (afb_req request) { // subscribe Client to event int err = afb_req_subscribe(request, TimerEvtGet()); diff --git a/conf.d/cmake/config.cmake b/conf.d/cmake/config.cmake index b97cb7a..72f2f15 100644 --- a/conf.d/cmake/config.cmake +++ b/conf.d/cmake/config.cmake @@ -18,7 +18,7 @@ # Project Info # ------------------ -set(PROJECT_NAME Controller-binding) +set(PROJECT_NAME afb-controller) set(PROJECT_VERSION "1.0") set(PROJECT_PRETTY_NAME "Controller Binding for AGL Application Framework") set(PROJECT_DESCRIPTION "Create controls that could be mapped to LUA functions, callback or API/VERB methods.") diff --git a/nbproject/configurations.xml b/nbproject/configurations.xml index d427c2c..71d6f6a 100644 --- a/nbproject/configurations.xml +++ b/nbproject/configurations.xml @@ -30,6 +30,9 @@ <in>feature_tests.cxx</in> </df> </df> + <df name="ctl-plugin"> + <in>ctl-plugin-sample.c</in> + </df> </df> <logicalFolder name="ExternalFiles" displayName="Important Files" @@ -53,7 +56,8 @@ <rebuildPropChanged>false</rebuildPropChanged> </toolsSet> <flagsDictionary> - <element flagsID="0" commonFlags="-mtune=generic -march=x86-64 -g -fPIC"/> + <element flagsID="0" commonFlags="-g -fPIC -fPIC"/> + <element flagsID="1" commonFlags="-mtune=generic -march=x86-64 -g -fPIC"/> </flagsDictionary> <codeAssistance> <includeAdditional>true</includeAdditional> @@ -79,14 +83,32 @@ <item path="afb-source/ctl-binding.c" ex="false" tool="0" flavor2="3"> <cTool flags="0"> <incDir> - <pElem>../../../opt/include/afb</pElem> - <pElem>afb-source</pElem> + <pElem>/usr/include/json-c</pElem> + <pElem>../../../opt/include</pElem> + <pElem>/usr/include/p11-kit-1</pElem> + <pElem>/usr/include/lua5.3</pElem> + <pElem>afb-utilities</pElem> <pElem>build/afb-source</pElem> </incDir> + <preprocessorList> + <Elem>CONTROL_CONFIG_PATH="/home/fulup/Workspace/AGL-AppFW/afb-controller/conf.d/project/json.d:/home/fulup/opt/Controller-binding/json.d"</Elem> + <Elem>CONTROL_CONFIG_POST="control"</Elem> + <Elem>CONTROL_CONFIG_PRE="onload"</Elem> + <Elem>CONTROL_DOSCRIPT_PRE="doscript"</Elem> + <Elem>CONTROL_LUA_EVENT="luaevt"</Elem> + <Elem>CONTROL_LUA_PATH="/home/fulup/Workspace/AGL-AppFW/afb-controller/conf.d/project/lua.d:/home/fulup/opt/controller-plugins/ctl-lua.d"</Elem> + <Elem>CONTROL_MAXPATH_LEN=255</Elem> + <Elem>CONTROL_ONLOAD_PROFILE="onload-default"</Elem> + <Elem>CONTROL_PLUGIN_PATH="/home/fulup/Workspace/AGL-AppFW/afb-controller/build:/home/fulup/opt/Controller-binding/lib/controller-plugins:/usr/lib/afb/controller-plugins/ctlplug"</Elem> + <Elem>CONTROL_SUPPORT_LUA</Elem> + <Elem>CTL_PLUGIN_MAGIC=2468013579</Elem> + <Elem>NATIVE_LINUX</Elem> + <Elem>control_afb_EXPORTS</Elem> + </preprocessorList> </cTool> </item> <item path="afb-source/ctl-dispatch.c" ex="false" tool="0" flavor2="3"> - <cTool flags="0"> + <cTool flags="1"> <incDir> <pElem>../../../opt/include/afb</pElem> <pElem>afb-source</pElem> @@ -99,7 +121,7 @@ </cTool> </item> <item path="afb-source/ctl-lua.c" ex="false" tool="0" flavor2="3"> - <cTool flags="0"> + <cTool flags="1"> <incDir> <pElem>../../../opt/include/afb</pElem> <pElem>afb-source</pElem> @@ -112,7 +134,7 @@ </cTool> </item> <item path="afb-source/ctl-plugin-sample.c" ex="false" tool="0" flavor2="3"> - <cTool flags="0"> + <cTool flags="1"> <incDir> <pElem>../../../opt/include/afb</pElem> <pElem>afb-source</pElem> @@ -130,7 +152,7 @@ </cTool> </item> <item path="afb-source/ctl-timer.c" ex="false" tool="0" flavor2="3"> - <cTool flags="0"> + <cTool flags="1"> <incDir> <pElem>../../../opt/include/afb</pElem> <pElem>afb-source</pElem> @@ -154,7 +176,7 @@ </cTool> </item> <item path="afb-utilities/filescan-utils.c" ex="false" tool="0" flavor2="3"> - <cTool flags="0"> + <cTool flags="1"> <incDir> <pElem>../../../opt/include/afb</pElem> <pElem>afb-utilities</pElem> @@ -164,7 +186,7 @@ </cTool> </item> <item path="afb-utilities/wrap-json.c" ex="false" tool="0" flavor2="3"> - <cTool flags="0"> + <cTool flags="1"> <incDir> <pElem>afb-utilities</pElem> <pElem>/usr/include/json-c</pElem> @@ -186,6 +208,10 @@ </item> <item path="build/CMakeFiles/feature_tests.cxx" ex="false" tool="1" flavor2="4"> </item> + <item path="ctl-plugin/ctl-plugin-sample.c" ex="false" tool="0" flavor2="3"> + <cTool flags="1"> + </cTool> + </item> <folder path="0/build"> <cTool> <incDir> @@ -193,6 +219,18 @@ </incDir> </cTool> </folder> + <folder path="0/ctl-plugin"> + <cTool> + <incDir> + <pElem>../../../opt/include/afb</pElem> + <pElem>ctl-plugin</pElem> + <pElem>/usr/include/json-c</pElem> + <pElem>/usr/include/lua5.3</pElem> + <pElem>afb-source</pElem> + <pElem>build/ctl-plugin</pElem> + </incDir> + </cTool> + </folder> </conf> </confs> </configurationDescriptor> |