summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--README.md3
m---------conf.d/app-templates0
-rwxr-xr-xconf.d/autobuild/agl/autobuild21
-rwxr-xr-xconf.d/autobuild/linux/autobuild21
-rw-r--r--conf.d/config.cmake2
-rw-r--r--conf.d/openapi/openapi-schema.json (renamed from conf.d/openapi-schema.json)0
-rw-r--r--data/CMakeLists.txt12
-rw-r--r--htdocs/AFB-websock.js7
-rw-r--r--htdocs/AudioBinding.js72
-rw-r--r--htdocs/UNICENS.html43
-rw-r--r--htdocs/Ucs2Binding.css7
-rw-r--r--htdocs/Ucs2Binding.js162
-rw-r--r--nbproject/configurations.xml409
-rw-r--r--ucs2-afb/CMakeLists.txt28
-rw-r--r--ucs2-afb/ucs_apidef.h98
-rw-r--r--ucs2-afb/ucs_apidef.json56
-rw-r--r--ucs2-afb/ucs_apihat.c55
-rw-r--r--ucs2-afb/ucs_apihat.h48
-rw-r--r--ucs2-afb/ucs_binding.c92
-rw-r--r--ucs2-afb/ucs_binding.h9
m---------ucs2-lib/unicens0
21 files changed, 872 insertions, 273 deletions
diff --git a/README.md b/README.md
index 877f14c..109d260 100644
--- a/README.md
+++ b/README.md
@@ -6,9 +6,8 @@ Cloning Audio-Binding from Git
-------------------------------------------------------
```
-git clone https://github.com/iotbzh/unicens2-binding
+git clone --recurse-submodules https://github.com/iotbzh/unicens2-binding
cd unicens2-binding
-git submodule update --recursive --init
```
AFB_daemon dependency on Standard Linux Distributions
diff --git a/conf.d/app-templates b/conf.d/app-templates
-Subproject 3e30ff523d1f55f68f66d41ddff29a309abdfa4
+Subproject 8f3bc0b6f25a5560a308078342a8ed3cc6dba13
diff --git a/conf.d/autobuild/agl/autobuild b/conf.d/autobuild/agl/autobuild
index 31e29f7..759f6be 100755
--- a/conf.d/autobuild/agl/autobuild
+++ b/conf.d/autobuild/agl/autobuild
@@ -16,10 +16,24 @@
THISFILE := $(lastword $(MAKEFILE_LIST))
BUILD_DIR := $(abspath $(dir $(THISFILE)/../../../../..)/build)
+DEST := ${BUILD_DIR}/target
-.PHONY: all clean distclean configure build package
+.PHONY: all clean distclean configure build package help
-all: build
+all: help
+
+help:
+ @echo "List of targets available:"
+ @echo ""
+ @echo "- all"
+ @echo "- clean"
+ @echo "- distclean"
+ @echo "- configure"
+ @echo "- build"
+ @echo "- package"
+ @echo ""
+ @echo "Usage: ./conf.d/autobuild/agl/autobuild package DEST=${HOME}/opt"
+ @echo "Don't use your build dir as DEST as wgt file is generated at this location"
clean:
@([ -d ${BUILD_DIR} ] && make -C ${BUILD_DIR} clean) || echo Nothing to clean
@@ -38,9 +52,8 @@ package: build
@mkdir -p ${BUILD_DIR}/$@/lib
@mkdir -p ${BUILD_DIR}/$@/htdocs
@mkdir -p ${BUILD_DIR}/$@/data
- @[ "${DEST}" ] && mkdir -p ${DEST}
@cmake --build ${BUILD_DIR} --target widget
- @[ "${DEST}" ] && cp ${BUILD_DIR}/*wgt ${DEST}
+ @mkdir -p ${DEST} && cp ${BUILD_DIR}/*wgt ${DEST}
${BUILD_DIR}/Makefile:
@[ -d ${BUILD_DIR} ] || mkdir -p ${BUILD_DIR}
diff --git a/conf.d/autobuild/linux/autobuild b/conf.d/autobuild/linux/autobuild
index 31e29f7..759f6be 100755
--- a/conf.d/autobuild/linux/autobuild
+++ b/conf.d/autobuild/linux/autobuild
@@ -16,10 +16,24 @@
THISFILE := $(lastword $(MAKEFILE_LIST))
BUILD_DIR := $(abspath $(dir $(THISFILE)/../../../../..)/build)
+DEST := ${BUILD_DIR}/target
-.PHONY: all clean distclean configure build package
+.PHONY: all clean distclean configure build package help
-all: build
+all: help
+
+help:
+ @echo "List of targets available:"
+ @echo ""
+ @echo "- all"
+ @echo "- clean"
+ @echo "- distclean"
+ @echo "- configure"
+ @echo "- build"
+ @echo "- package"
+ @echo ""
+ @echo "Usage: ./conf.d/autobuild/agl/autobuild package DEST=${HOME}/opt"
+ @echo "Don't use your build dir as DEST as wgt file is generated at this location"
clean:
@([ -d ${BUILD_DIR} ] && make -C ${BUILD_DIR} clean) || echo Nothing to clean
@@ -38,9 +52,8 @@ package: build
@mkdir -p ${BUILD_DIR}/$@/lib
@mkdir -p ${BUILD_DIR}/$@/htdocs
@mkdir -p ${BUILD_DIR}/$@/data
- @[ "${DEST}" ] && mkdir -p ${DEST}
@cmake --build ${BUILD_DIR} --target widget
- @[ "${DEST}" ] && cp ${BUILD_DIR}/*wgt ${DEST}
+ @mkdir -p ${DEST} && cp ${BUILD_DIR}/*wgt ${DEST}
${BUILD_DIR}/Makefile:
@[ -d ${BUILD_DIR} ] || mkdir -p ${BUILD_DIR}
diff --git a/conf.d/config.cmake b/conf.d/config.cmake
index 5dfb013..a386fe7 100644
--- a/conf.d/config.cmake
+++ b/conf.d/config.cmake
@@ -74,6 +74,8 @@ add_compile_options()
# ---------------------------------------------------------
add_compile_options(-DCONTROL_CDEV_TX="/dev/inic-usb-ctx")
add_compile_options(-DCONTROL_CDEV_RX="/dev/inic-usb-crx")
+add_compile_options(-DUCS2_CFG_PATH="/etc/default/ucs:./data")
+
# LANG Specific compile flags set for all build types
set(CMAKE_C_FLAGS "")
diff --git a/conf.d/openapi-schema.json b/conf.d/openapi/openapi-schema.json
index 6629c7c..6629c7c 100644
--- a/conf.d/openapi-schema.json
+++ b/conf.d/openapi/openapi-schema.json
diff --git a/data/CMakeLists.txt b/data/CMakeLists.txt
index d49221d..7963474 100644
--- a/data/CMakeLists.txt
+++ b/data/CMakeLists.txt
@@ -23,18 +23,22 @@
##################################################
PROJECT_TARGET_ADD(ucs2_config)
- file(GLOB SOURCE_FILES "*.xml")
+ file(GLOB XML_FILES "*.xml")
+ set(XML_SCHEMA unicens.xsd)
add_custom_target(${TARGET_NAME}
DEPENDS ${CMAKE_CURRENT_BINARY_DIR}/${TARGET_NAME}
)
+ # check XML schema before pushing config
add_custom_command(
- DEPENDS ${SOURCE_FILES}
+ DEPENDS ${XML_FILES}
OUTPUT ${CMAKE_CURRENT_BINARY_DIR}/${TARGET_NAME}
+ WORKING_DIRECTORY ${CMAKE_CURRENT_SOURCE_DIR}
+ COMMAND xmllint -schema ${XML_SCHEMA} ${XML_FILES} --noout
COMMAND mkdir -p ${CMAKE_CURRENT_BINARY_DIR}/${TARGET_NAME}
- COMMAND touch ${CMAKE_CURRENT_BINARY_DIR}/${TARGET_NAME}
- COMMAND cp -r ${SOURCE_FILES} ${CMAKE_CURRENT_BINARY_DIR}/${TARGET_NAME}
+ COMMAND touch ${CMAKE_CURRENT_BINARY_DIR}/${TARGET_NAME}
+ COMMAND cp -r ${XML_FILES} ${CMAKE_CURRENT_BINARY_DIR}/${TARGET_NAME}
)
SET_TARGET_PROPERTIES(${TARGET_NAME} PROPERTIES
diff --git a/htdocs/AFB-websock.js b/htdocs/AFB-websock.js
index 08a7ffe..99ab3b8 100644
--- a/htdocs/AFB-websock.js
+++ b/htdocs/AFB-websock.js
@@ -1,7 +1,10 @@
+var urlws;
+var urlhttp;
+
AFB = function(base, initialtoken){
-var urlws = "ws://"+window.location.host+"/"+base;
-var urlhttp = "http://"+window.location.host+"/"+base;
+urlws = "ws://"+window.location.host+"/"+base;
+urlhttp = "http://"+window.location.host+"/"+base;
/*********************************************/
/**** ****/
diff --git a/htdocs/AudioBinding.js b/htdocs/AudioBinding.js
deleted file mode 100644
index 5f9ea24..0000000
--- a/htdocs/AudioBinding.js
+++ /dev/null
@@ -1,72 +0,0 @@
- var afb = new AFB("api", "mysecret");
- var ws;
- var evtidx=0;
-
- function getParameterByName(name, url) {
- if (!url) {
- url = window.location.href;
- }
- name = name.replace(/[\[\]]/g, "\\$&");
- var regex = new RegExp("[?&]" + name + "(=([^&#]*)|&|#|$)"),
- results = regex.exec(url);
- if (!results) return null;
- if (!results[2]) return '';
- return decodeURIComponent(results[2].replace(/\+/g, " "));
- }
-
- // default soundcard is "PCH"
- var devid=getParameterByName("devid");
- if (!devid) devid="hw:0";
-
- var sndname=getParameterByName("sndname");
- if (!sndname) sndname="PCH";
-
- var quiet=getParameterByName("quiet");
- if (!quiet) quiet="99";
-
- function init() {
- ws = new afb.ws(onopen, onabort);
- }
-
- function onopen() {
- document.getElementById("main").style.visibility = "visible";
- document.getElementById("connected").innerHTML = "Binder WS Active";
- document.getElementById("connected").style.background = "lightgreen";
- ws.onevent("*", gotevent);
- }
-
- function onabort() {
- document.getElementById("main").style.visibility = "hidden";
- document.getElementById("connected").innerHTML = "Connected Closed";
- document.getElementById("connected").style.background = "red";
-
- }
-
- function replyok(obj) {
- console.log("replyok:" + JSON.stringify(obj));
- document.getElementById("output").innerHTML = "OK: "+JSON.stringify(obj);
- }
-
- function replyerr(obj) {
- console.log("replyerr:" + JSON.stringify(obj));
- document.getElementById("output").innerHTML = "ERROR: "+JSON.stringify(obj);
- }
-
- function gotevent(obj) {
- console.log("gotevent:" + JSON.stringify(obj));
- document.getElementById("outevt").innerHTML = (evtidx++) +": "+JSON.stringify(obj);
- }
-
- function send(message) {
- var api = document.getElementById("api").value;
- var verb = document.getElementById("verb").value;
- document.getElementById("question").innerHTML = "subscribe: "+api+"/"+verb + " (" + JSON.stringify(message) +")";
- ws.call(api+"/"+verb, {data:message}).then(replyok, replyerr);
- }
-
-
- function callbinder(api, verb, query) {
- console.log ("subscribe api="+api+" verb="+verb+" query=" +query);
- document.getElementById("question").innerHTML = "apicall: " + api+"/"+verb +" ("+ JSON.stringify(query)+")";
- ws.call(api+"/"+verb, query).then(replyok, replyerr);
- }
diff --git a/htdocs/UNICENS.html b/htdocs/UNICENS.html
index 73c1b66..fc13d34 100644
--- a/htdocs/UNICENS.html
+++ b/htdocs/UNICENS.html
@@ -1,33 +1,38 @@
<html>
<head>
- <title>Hello world test</title>
+ <title>Unicens Simple Test</title>
+ <link rel="stylesheet" href="Ucs2Binding.css">
<script type="text/javascript" src="AFB-websock.js"></script>
- <script type="text/javascript" src="AudioBinding.js"></script>
+ <script type="text/javascript" src="Ucs2Binding.js"></script>
-
-<body onload="init();">
- <h1>Hello world test</h1>
- <button id="connected" onclick="init()">Binder WS Fail</button></li>
+<body onload="init('ucs2_config','unicens', 'listconfig');">
+ <h1>Unicens Simple Test</h1>
+
+ <button id="connected" onclick="init('ucs2_config','unicens', 'listconfig')">Binder WS Fail</button>
+ <br><br>
+ <b>Selected HAL </b>
+ <select id='ucs2_config'></select>
<br>
+
<ol>
- <li><button onclick="callbinder('UNICENS','initialise', {filename:'data/config_multichannel_audio_kit.xml'})">Parse XML and Start UNICENS</button></li>
- <li><button onclick="callbinder('UNICENS','setvol', {channel:'master', volume: 255})">Set Master Volume to 255</button></li>
- <li><button onclick="callbinder('unicens','setvol', {channel:'master', volume: 230})">Set Master Volume to 230</button></li>
- <li><button onclick="callbinder('unicens','setvol', {channel:'master', volume: 215})">Set Master Volume to 215</button></li>
- <li><button onclick="callbinder('unicens','setvol', {channel:'master', volume: 200})">Set Master Volume to 200</button></li>
- <li><button onclick="callbinder('unicens','setvol', {channel:'master', volume: 185})">Set Master Volume to 185</button></li>
- <li><button onclick="callbinder('unicens','setvol', {channel:'master', volume: 0})">Set Master Volume to 0</button></li>
+ <li><button onclick="callbinder('UNICENS','initialise', {filename:ucs2_config})">Parse XML and Start UNICENS</button></li>
+ <li><button onclick="callbinder('UNICENS','volume', {channel:'master', volume: 255})">Set Master Volume to 255</button></li>
+ <li><button onclick="callbinder('unicens','volume', {channel:'master', volume: 230})">Set Master Volume to 230</button></li>
+ <li><button onclick="callbinder('unicens','volume', {channel:'master', volume: 215})">Set Master Volume to 215</button></li>
+ <li><button onclick="callbinder('unicens','volume', {channel:'master', volume: 200})">Set Master Volume to 200</button></li>
+ <li><button onclick="callbinder('unicens','volume', {channel:'master', volume: 185})">Set Master Volume to 185</button></li>
+ <li><button onclick="callbinder('unicens','volume', {channel:'master', volume: 0})">Set Master Volume to 0</button></li>
<br>
- <li><button onclick="callbinder('UNICENS','setvol', [[0,200], [1,255]])">Set left=200 right=250</button></li>
- <li><button onclick="callbinder('UNICENS','setvol', [[0,255], [1,200]])">Set right=250 left=200</button></li>
- <li><button onclick="callbinder('UNICENS','setvol', [[0,255], [1,255]])">Set right=255 left=255</button></li>
+ <li><button onclick="callbinder('UNICENS','volume', [[0,200], [1,255]])">Set left=200 right=250</button></li>
+ <li><button onclick="callbinder('UNICENS','volume', [[0,255], [1,200]])">Set right=250 left=200</button></li>
+ <li><button onclick="callbinder('UNICENS','volume', [[0,255], [1,255]])">Set right=255 left=255</button></li>
</ol>
<br>
<div id="main" style="visibility:hidden">
<ol>
- <li>Question <div id="question"></div>
- <li>Response <div id="output"></div>
- <li>Events: <div id="outevt"></div>
+ <li>Question <pre id="question"></pre>
+ <li>Response <pre id="output"></pre>
+ <li>Events: <pre id="outevt"></pre>
</ol>
</div>
diff --git a/htdocs/Ucs2Binding.css b/htdocs/Ucs2Binding.css
new file mode 100644
index 0000000..1052aa7
--- /dev/null
+++ b/htdocs/Ucs2Binding.css
@@ -0,0 +1,7 @@
+pre {outline: 1px solid #ccc; padding: 5px; margin: 5px; }
+.string { color: green; }
+.number { color: darkorange; }
+.boolean { color: blue; }
+.null { color: magenta; }
+.key { color: red; }
+
diff --git a/htdocs/Ucs2Binding.js b/htdocs/Ucs2Binding.js
new file mode 100644
index 0000000..11b8a1a
--- /dev/null
+++ b/htdocs/Ucs2Binding.js
@@ -0,0 +1,162 @@
+ var afb = new AFB("api", "mysecret");
+ var ws;
+ var ucs2_config="ConfigNotSelected";
+ var evtidx=0;
+ var numid=0;
+
+ function syntaxHighlight(json) {
+ if (typeof json !== 'string') {
+ json = JSON.stringify(json, undefined, 2);
+ }
+ json = json.replace(/&/g, '&amp;').replace(/</g, '&lt;').replace(/>/g, '&gt;');
+ return json.replace(/("(\\u[a-zA-Z0-9]{4}|\\[^u]|[^\\"])*"(\s*:)?|\b(true|false|null)\b|-?\d+(?:\.\d*)?(?:[eE][+\-]?\d+)?)/g, function (match) {
+ var cls = 'number';
+ if (/^"/.test(match)) {
+ if (/:$/.test(match)) {
+ cls = 'key';
+ } else {
+ cls = 'string';
+ }
+ } else if (/true|false/.test(match)) {
+ cls = 'boolean';
+ } else if (/null/.test(match)) {
+ cls = 'null';
+ }
+ return '<span class="' + cls + '">' + match + '</span>';
+ });
+ }
+
+ function basename(path) {
+ return path.split('/').reverse()[0];
+ }
+
+ function getParameterByName(name, url) {
+ if (!url) {
+ url = window.location.href;
+ }
+ name = name.replace(/[\[\]]/g, "\\$&");
+ var regex = new RegExp("[?&]" + name + "(=([^&#]*)|&|#|$)"),
+ results = regex.exec(url);
+ if (!results) return null;
+ if (!results[2]) return '';
+ return decodeURIComponent(results[2].replace(/\+/g, " "));
+ }
+
+ // default soundcard is "PCH"
+ var devid=getParameterByName("devid");
+ if (!devid) devid="hw:1";
+
+ var haldev=getParameterByName("haldev");
+ if (!haldev) haldev="scarlett-usb";
+
+ var sndname=getParameterByName("sndname");
+ if (!sndname) sndname="PCH";
+
+ var mode=getParameterByName("mode");
+ if (!mode) mode="0";
+
+
+
+
+ function replyok(obj) {
+ console.log("replyok:" + JSON.stringify(obj));
+ document.getElementById("output").innerHTML = "OK: "+ syntaxHighlight(obj);
+ }
+
+ function replyerr(obj) {
+ console.log("replyerr:" + JSON.stringify(obj));
+ document.getElementById("output").innerHTML = "ERROR: "+ syntaxHighlight(obj);
+ }
+
+ function gotevent(obj) {
+ console.log("gotevent:" + JSON.stringify(obj));
+ document.getElementById("outevt").innerHTML = (evtidx++) +": "+JSON.stringify(obj);
+ }
+
+ function send(message) {
+ var api = document.getElementById("api").value;
+ var verb = document.getElementById("verb").value;
+ document.getElementById("question").innerHTML = "subscribe: "+api+"/"+verb + " (" + JSON.stringify(message) +")";
+ ws.call(api+"/"+verb, {data:message}).then(replyok, replyerr);
+ }
+
+
+ // On button click from HTML page
+ function callbinder(api, verb, query) {
+ console.log ("subscribe api="+api+" verb="+verb+" query=" +query);
+ var question = urlws +"/" +api +"/" +verb + "?query=" + JSON.stringify(query);
+ document.getElementById("question").innerHTML = syntaxHighlight(question);
+ ws.call(api+"/"+verb, query).then(replyok, replyerr);
+ }
+
+
+ // Retreive Select value and Text from the binder
+ // Note: selection of value/text for a given context is huggly!!!
+ function querySelectList (elemid, api, verb, query) {
+
+ console.log("querySelectList elemid=%s api=%s verb=%s query=%s", elemid, api, verb, query);
+
+ var selectobj = document.getElementById(elemid);
+ if (!selectobj) {
+ console.log ("****** elemid=%s does not exit in HTML page ****", elemid);
+ return;
+ }
+
+ // onlick update selected HAL api
+ selectobj.onclick=function(){
+ ucs2_config= this.value;
+ console.log ("Default Selection=" + ucs2_config);
+ };
+
+ function gotit (result) {
+
+ // display response as for normal onclick action
+ replyok(result);
+ var response=result.response;
+
+ // fulfill select with avaliable active HAL
+ for (idx=0; idx<response.length; idx++) {
+ var opt = document.createElement('option');
+ var basename = response[idx].basename;
+ var dirpath = response[idx].dirpath;
+ var ext= basename.split('.').pop();
+
+ // Only propose XML files
+ if (ext.toLowerCase() === "xml") {
+ opt.text = basename;
+ opt.value = dirpath + "/" + basename;
+ selectobj.appendChild(opt);
+ }
+ }
+
+ ucs2_config= selectobj.value;
+ }
+
+ var question = urlws +"/"+api +"/" +verb + "?query=" + JSON.stringify(query);
+ document.getElementById("question").innerHTML = syntaxHighlight(question);
+
+ // request lowlevel ALSA to get API list
+ ws.call(api+"/"+verb, query).then(gotit, replyerr);
+ }
+
+
+ function init(elemid, api, verb, query) {
+
+ function onopen() {
+ // check for active HALs
+ querySelectList (elemid, api, verb, query);
+
+ document.getElementById("main").style.visibility = "visible";
+ document.getElementById("connected").innerHTML = "Binder WS Active";
+ document.getElementById("connected").style.background = "lightgreen";
+ ws.onevent("*", gotevent);
+ }
+
+ function onabort() {
+ document.getElementById("main").style.visibility = "hidden";
+ document.getElementById("connected").innerHTML = "Connected Closed";
+ document.getElementById("connected").style.background = "red";
+
+ }
+ ws = new afb.ws(onopen, onabort);
+ }
diff --git a/nbproject/configurations.xml b/nbproject/configurations.xml
index 4ff307d..79192e1 100644
--- a/nbproject/configurations.xml
+++ b/nbproject/configurations.xml
@@ -42,6 +42,7 @@
<df name="ucs2-interface">
<df name="ucs-xml">
<in>UcsXml.c</in>
+ <in>UcsXml_Private.c</in>
</df>
<in>ucs_lib_interf.c</in>
<in>ucs_vol_interf.c</in>
@@ -105,6 +106,63 @@
<in>ucs_xrm_res.c</in>
<in>ucs_xrmpool.c</in>
</df>
+ <df name="unicens">
+ <df name="src">
+ <in>ucs_alm.c</in>
+ <in>ucs_amd.c</in>
+ <in>ucs_ams.c</in>
+ <in>ucs_amsmessage.c</in>
+ <in>ucs_amspool.c</in>
+ <in>ucs_amtp.c</in>
+ <in>ucs_attach.c</in>
+ <in>ucs_base.c</in>
+ <in>ucs_bc_diag.c</in>
+ <in>ucs_class.c</in>
+ <in>ucs_cmd.c</in>
+ <in>ucs_dec.c</in>
+ <in>ucs_dl.c</in>
+ <in>ucs_eh.c</in>
+ <in>ucs_encoder.c</in>
+ <in>ucs_epm.c</in>
+ <in>ucs_exc.c</in>
+ <in>ucs_factory.c</in>
+ <in>ucs_fsm.c</in>
+ <in>ucs_gpio.c</in>
+ <in>ucs_i2c.c</in>
+ <in>ucs_inic.c</in>
+ <in>ucs_inic_res.c</in>
+ <in>ucs_jobs.c</in>
+ <in>ucs_lldpool.c</in>
+ <in>ucs_message.c</in>
+ <in>ucs_mgr.c</in>
+ <in>ucs_misc.c</in>
+ <in>ucs_net.c</in>
+ <in>ucs_nodedis.c</in>
+ <in>ucs_nodeobserver.c</in>
+ <in>ucs_nsm.c</in>
+ <in>ucs_obs.c</in>
+ <in>ucs_pmchannel.c</in>
+ <in>ucs_pmcmd.c</in>
+ <in>ucs_pmevent.c</in>
+ <in>ucs_pmfifo.c</in>
+ <in>ucs_pmfifos.c</in>
+ <in>ucs_pmp.c</in>
+ <in>ucs_pool.c</in>
+ <in>ucs_prog.c</in>
+ <in>ucs_rsm.c</in>
+ <in>ucs_rtm.c</in>
+ <in>ucs_scheduler.c</in>
+ <in>ucs_segmentation.c</in>
+ <in>ucs_smm.c</in>
+ <in>ucs_sys_diag.c</in>
+ <in>ucs_telqueue.c</in>
+ <in>ucs_timer.c</in>
+ <in>ucs_transceiver.c</in>
+ <in>ucs_xrm.c</in>
+ <in>ucs_xrm_res.c</in>
+ <in>ucs_xrmpool.c</in>
+ </df>
+ </df>
</df>
<df name="ucs2-vol">
<df name="src">
@@ -141,7 +199,8 @@
<flagsDictionary>
<element flagsID="0" commonFlags="-fPIC -fPIC"/>
<element flagsID="1" commonFlags="-g -fPIC -fPIC -g"/>
- <element flagsID="2" commonFlags="-mtune=generic -march=x86-64 -g -g -fPIC"/>
+ <element flagsID="2" commonFlags="-g -fPIC -fPIC -g -ggdb"/>
+ <element flagsID="3" commonFlags="-mtune=generic -march=x86-64 -g -g -fPIC"/>
</flagsDictionary>
<codeAssistance>
<includeAdditional>true</includeAdditional>
@@ -202,35 +261,24 @@
</folder>
<folder path="0/ucs2-afb">
<cTool>
- <incDir>
- <pElem>../../../opt/include</pElem>
- <pElem>/usr/include/json-c</pElem>
- <pElem>ucs2-interface</pElem>
- <pElem>ucs2-lib/inc</pElem>
- <pElem>ucs2-lib/cfg</pElem>
- <pElem>ucs2-lib/src/ucs-xml</pElem>
- <pElem>ucs2-vol/inc</pElem>
- <pElem>ucs2-vol/cfg</pElem>
- <pElem>ucs2-vol/src/ucs-xml</pElem>
- <pElem>build/ucs2-afb</pElem>
- </incDir>
<preprocessorList>
<Elem>CONTROL_CDEV_RX="/dev/inic-usb-crx"</Elem>
<Elem>CONTROL_CDEV_TX="/dev/inic-usb-ctx"</Elem>
<Elem>_REENTRANT</Elem>
<Elem>_THREAD_SAFE</Elem>
+ <Elem>ucs2_afb_EXPORTS</Elem>
</preprocessorList>
</cTool>
</folder>
<folder path="0/ucs2-interface">
<cTool>
<incDir>
- <pElem>../../../opt/include</pElem>
<pElem>/usr/include/json-c</pElem>
+ <pElem>../../../opt/include</pElem>
+ <pElem>/usr/include/p11-kit-1</pElem>
<pElem>ucs2-interface</pElem>
- <pElem>ucs2-lib/inc</pElem>
- <pElem>ucs2-lib/cfg</pElem>
- <pElem>ucs2-lib/src/ucs-xml</pElem>
+ <pElem>ucs2-lib/unicens/inc</pElem>
+ <pElem>ucs2-lib/cfg_agl</pElem>
<pElem>ucs2-vol/inc</pElem>
<pElem>ucs2-vol/cfg</pElem>
<pElem>ucs2-vol/src/ucs-xml</pElem>
@@ -239,6 +287,8 @@
<preprocessorList>
<Elem>CONTROL_CDEV_RX="/dev/inic-usb-crx"</Elem>
<Elem>CONTROL_CDEV_TX="/dev/inic-usb-ctx"</Elem>
+ <Elem>NDEBUG</Elem>
+ <Elem>UCS2_CFG_PATH="/etc/default/ucs:./data"</Elem>
<Elem>_REENTRANT</Elem>
<Elem>_THREAD_SAFE</Elem>
</preprocessorList>
@@ -262,62 +312,116 @@
</preprocessorList>
</cTool>
</folder>
+ <folder path="0/ucs2-lib/unicens">
+ <cTool>
+ <incDir>
+ <pElem>/usr/include/p11-kit-1</pElem>
+ <pElem>ucs2-lib/unicens/inc</pElem>
+ <pElem>ucs2-lib/cfg_agl</pElem>
+ <pElem>build/ucs2-lib</pElem>
+ </incDir>
+ <preprocessorList>
+ <Elem>UCS2_CFG_PATH="/etc/default/ucs:./data"</Elem>
+ </preprocessorList>
+ </cTool>
+ </folder>
<folder path="0/ucs2-vol">
<ccTool>
<incDir>
- <pElem>../../../opt/include</pElem>
<pElem>/usr/include/json-c</pElem>
+ <pElem>../../../opt/include</pElem>
+ <pElem>/usr/include/p11-kit-1</pElem>
<pElem>ucs2-vol/inc</pElem>
<pElem>ucs2-vol/cfg</pElem>
<pElem>ucs2-vol/src/ucs-xml</pElem>
- <pElem>ucs2-lib/inc</pElem>
- <pElem>ucs2-lib/cfg</pElem>
- <pElem>ucs2-lib/src/ucs-xml</pElem>
+ <pElem>ucs2-lib/unicens/inc</pElem>
+ <pElem>ucs2-lib/cfg_agl</pElem>
<pElem>build/ucs2-vol/src</pElem>
</incDir>
<preprocessorList>
<Elem>CONTROL_CDEV_RX="/dev/inic-usb-crx"</Elem>
<Elem>CONTROL_CDEV_TX="/dev/inic-usb-ctx"</Elem>
+ <Elem>UCS2_CFG_PATH="/etc/default/ucs:./data"</Elem>
<Elem>_REENTRANT</Elem>
<Elem>_THREAD_SAFE</Elem>
</preprocessorList>
</ccTool>
</folder>
<item path="ucs2-afb/ucs_apihat.c" ex="false" tool="0" flavor2="3">
- <cTool flags="1">
+ <cTool flags="2">
+ <incDir>
+ <pElem>/usr/include/json-c</pElem>
+ <pElem>../../../opt/include</pElem>
+ <pElem>/usr/include/p11-kit-1</pElem>
+ <pElem>ucs2-interface</pElem>
+ <pElem>ucs2-lib/unicens/inc</pElem>
+ <pElem>ucs2-lib/cfg_agl</pElem>
+ <pElem>ucs2-vol/inc</pElem>
+ <pElem>ucs2-vol/cfg</pElem>
+ <pElem>ucs2-vol/src/ucs-xml</pElem>
+ <pElem>build/ucs2-afb</pElem>
+ </incDir>
<preprocessorList>
- <Elem>ucs2_EXPORTS</Elem>
+ <Elem>UCS2_CFG_PATH="/etc/default/ucs:./data"</Elem>
</preprocessorList>
</cTool>
</item>
<item path="ucs2-afb/ucs_binding.c" ex="false" tool="0" flavor2="3">
- <cTool flags="1">
+ <cTool flags="2">
+ <incDir>
+ <pElem>/usr/include/json-c</pElem>
+ <pElem>../../../opt/include</pElem>
+ <pElem>/usr/include/p11-kit-1</pElem>
+ <pElem>ucs2-interface</pElem>
+ <pElem>ucs2-lib/unicens/inc</pElem>
+ <pElem>ucs2-lib/cfg_agl</pElem>
+ <pElem>ucs2-vol/inc</pElem>
+ <pElem>ucs2-vol/cfg</pElem>
+ <pElem>ucs2-vol/src/ucs-xml</pElem>
+ <pElem>build/ucs2-afb</pElem>
+ </incDir>
<preprocessorList>
- <Elem>ucs2_EXPORTS</Elem>
+ <Elem>UCS2_CFG_PATH="/etc/default/ucs:./data"</Elem>
</preprocessorList>
</cTool>
</item>
<item path="ucs2-afb/ucs_binding.new.c" ex="false" tool="0" flavor2="2">
<cTool flags="1">
- <preprocessorList>
- <Elem>ucs2_afb_EXPORTS</Elem>
- </preprocessorList>
+ <incDir>
+ <pElem>../../../opt/include</pElem>
+ <pElem>/usr/include/json-c</pElem>
+ <pElem>ucs2-interface</pElem>
+ <pElem>ucs2-lib/inc</pElem>
+ <pElem>ucs2-lib/cfg</pElem>
+ <pElem>ucs2-lib/src/ucs-xml</pElem>
+ <pElem>ucs2-vol/inc</pElem>
+ <pElem>ucs2-vol/cfg</pElem>
+ <pElem>ucs2-vol/src/ucs-xml</pElem>
+ <pElem>build/ucs2-afb</pElem>
+ </incDir>
</cTool>
</item>
- <item path="ucs2-interface/ucs-xml/UcsXml.c" ex="false" tool="0" flavor2="0">
- <cTool flags="1">
+ <item path="ucs2-interface/ucs-xml/UcsXml.c" ex="false" tool="0" flavor2="2">
+ <cTool flags="2">
+ </cTool>
+ </item>
+ <item path="ucs2-interface/ucs-xml/UcsXml_Private.c"
+ ex="false"
+ tool="0"
+ flavor2="0">
+ <cTool flags="2">
</cTool>
</item>
<item path="ucs2-interface/ucs_lib_interf.c" ex="false" tool="0" flavor2="3">
- <cTool flags="1">
+ <cTool flags="2">
</cTool>
</item>
<item path="ucs2-interface/ucs_vol_interf.c" ex="false" tool="0" flavor2="3">
- <cTool flags="1">
+ <cTool flags="2">
</cTool>
</item>
<item path="ucs2-lib/src/ucs-xml/UcsXml.c" ex="false" tool="0" flavor2="3">
- <cTool flags="2">
+ <cTool flags="3">
</cTool>
</item>
<item path="ucs2-lib/src/ucs_alm.c" ex="false" tool="0" flavor2="3">
@@ -532,6 +636,245 @@
<cTool flags="1">
</cTool>
</item>
+ <item path="ucs2-lib/unicens/src/ucs_alm.c" ex="false" tool="0" flavor2="0">
+ <cTool flags="2">
+ </cTool>
+ </item>
+ <item path="ucs2-lib/unicens/src/ucs_amd.c" ex="false" tool="0" flavor2="0">
+ <cTool flags="2">
+ </cTool>
+ </item>
+ <item path="ucs2-lib/unicens/src/ucs_ams.c" ex="false" tool="0" flavor2="0">
+ <cTool flags="2">
+ </cTool>
+ </item>
+ <item path="ucs2-lib/unicens/src/ucs_amsmessage.c"
+ ex="false"
+ tool="0"
+ flavor2="0">
+ <cTool flags="2">
+ </cTool>
+ </item>
+ <item path="ucs2-lib/unicens/src/ucs_amspool.c" ex="false" tool="0" flavor2="0">
+ <cTool flags="2">
+ </cTool>
+ </item>
+ <item path="ucs2-lib/unicens/src/ucs_amtp.c" ex="false" tool="0" flavor2="0">
+ <cTool flags="2">
+ </cTool>
+ </item>
+ <item path="ucs2-lib/unicens/src/ucs_attach.c" ex="false" tool="0" flavor2="0">
+ <cTool flags="2">
+ </cTool>
+ </item>
+ <item path="ucs2-lib/unicens/src/ucs_base.c" ex="false" tool="0" flavor2="0">
+ <cTool flags="2">
+ </cTool>
+ </item>
+ <item path="ucs2-lib/unicens/src/ucs_bc_diag.c" ex="false" tool="0" flavor2="0">
+ <cTool flags="2">
+ </cTool>
+ </item>
+ <item path="ucs2-lib/unicens/src/ucs_class.c" ex="false" tool="0" flavor2="0">
+ <cTool flags="2">
+ </cTool>
+ </item>
+ <item path="ucs2-lib/unicens/src/ucs_cmd.c" ex="false" tool="0" flavor2="0">
+ <cTool flags="2">
+ </cTool>
+ </item>
+ <item path="ucs2-lib/unicens/src/ucs_dec.c" ex="false" tool="0" flavor2="0">
+ <cTool flags="2">
+ </cTool>
+ </item>
+ <item path="ucs2-lib/unicens/src/ucs_dl.c" ex="false" tool="0" flavor2="0">
+ <cTool flags="2">
+ </cTool>
+ </item>
+ <item path="ucs2-lib/unicens/src/ucs_eh.c" ex="false" tool="0" flavor2="0">
+ <cTool flags="2">
+ </cTool>
+ </item>
+ <item path="ucs2-lib/unicens/src/ucs_encoder.c" ex="false" tool="0" flavor2="0">
+ <cTool flags="2">
+ </cTool>
+ </item>
+ <item path="ucs2-lib/unicens/src/ucs_epm.c" ex="false" tool="0" flavor2="0">
+ <cTool flags="2">
+ </cTool>
+ </item>
+ <item path="ucs2-lib/unicens/src/ucs_exc.c" ex="false" tool="0" flavor2="0">
+ <cTool flags="2">
+ </cTool>
+ </item>
+ <item path="ucs2-lib/unicens/src/ucs_factory.c" ex="false" tool="0" flavor2="0">
+ <cTool flags="2">
+ </cTool>
+ </item>
+ <item path="ucs2-lib/unicens/src/ucs_fsm.c" ex="false" tool="0" flavor2="0">
+ <cTool flags="2">
+ </cTool>
+ </item>
+ <item path="ucs2-lib/unicens/src/ucs_gpio.c" ex="false" tool="0" flavor2="0">
+ <cTool flags="2">
+ </cTool>
+ </item>
+ <item path="ucs2-lib/unicens/src/ucs_i2c.c" ex="false" tool="0" flavor2="0">
+ <cTool flags="2">
+ </cTool>
+ </item>
+ <item path="ucs2-lib/unicens/src/ucs_inic.c" ex="false" tool="0" flavor2="0">
+ <cTool flags="2">
+ </cTool>
+ </item>
+ <item path="ucs2-lib/unicens/src/ucs_inic_res.c"
+ ex="false"
+ tool="0"
+ flavor2="0">
+ <cTool flags="2">
+ </cTool>
+ </item>
+ <item path="ucs2-lib/unicens/src/ucs_jobs.c" ex="false" tool="0" flavor2="0">
+ <cTool flags="2">
+ </cTool>
+ </item>
+ <item path="ucs2-lib/unicens/src/ucs_lldpool.c" ex="false" tool="0" flavor2="0">
+ <cTool flags="2">
+ </cTool>
+ </item>
+ <item path="ucs2-lib/unicens/src/ucs_message.c" ex="false" tool="0" flavor2="0">
+ <cTool flags="2">
+ </cTool>
+ </item>
+ <item path="ucs2-lib/unicens/src/ucs_mgr.c" ex="false" tool="0" flavor2="0">
+ <cTool flags="2">
+ </cTool>
+ </item>
+ <item path="ucs2-lib/unicens/src/ucs_misc.c" ex="false" tool="0" flavor2="0">
+ <cTool flags="2">
+ </cTool>
+ </item>
+ <item path="ucs2-lib/unicens/src/ucs_net.c" ex="false" tool="0" flavor2="0">
+ <cTool flags="2">
+ </cTool>
+ </item>
+ <item path="ucs2-lib/unicens/src/ucs_nodedis.c" ex="false" tool="0" flavor2="0">
+ <cTool flags="2">
+ </cTool>
+ </item>
+ <item path="ucs2-lib/unicens/src/ucs_nodeobserver.c"
+ ex="false"
+ tool="0"
+ flavor2="0">
+ <cTool flags="2">
+ </cTool>
+ </item>
+ <item path="ucs2-lib/unicens/src/ucs_nsm.c" ex="false" tool="0" flavor2="0">
+ <cTool flags="2">
+ </cTool>
+ </item>
+ <item path="ucs2-lib/unicens/src/ucs_obs.c" ex="false" tool="0" flavor2="0">
+ <cTool flags="2">
+ </cTool>
+ </item>
+ <item path="ucs2-lib/unicens/src/ucs_pmchannel.c"
+ ex="false"
+ tool="0"
+ flavor2="0">
+ <cTool flags="2">
+ </cTool>
+ </item>
+ <item path="ucs2-lib/unicens/src/ucs_pmcmd.c" ex="false" tool="0" flavor2="0">
+ <cTool flags="2">
+ </cTool>
+ </item>
+ <item path="ucs2-lib/unicens/src/ucs_pmevent.c" ex="false" tool="0" flavor2="0">
+ <cTool flags="2">
+ </cTool>
+ </item>
+ <item path="ucs2-lib/unicens/src/ucs_pmfifo.c" ex="false" tool="0" flavor2="0">
+ <cTool flags="2">
+ </cTool>
+ </item>
+ <item path="ucs2-lib/unicens/src/ucs_pmfifos.c" ex="false" tool="0" flavor2="0">
+ <cTool flags="2">
+ </cTool>
+ </item>
+ <item path="ucs2-lib/unicens/src/ucs_pmp.c" ex="false" tool="0" flavor2="0">
+ <cTool flags="2">
+ </cTool>
+ </item>
+ <item path="ucs2-lib/unicens/src/ucs_pool.c" ex="false" tool="0" flavor2="0">
+ <cTool flags="2">
+ </cTool>
+ </item>
+ <item path="ucs2-lib/unicens/src/ucs_prog.c" ex="false" tool="0" flavor2="0">
+ <cTool flags="2">
+ </cTool>
+ </item>
+ <item path="ucs2-lib/unicens/src/ucs_rsm.c" ex="false" tool="0" flavor2="0">
+ <cTool flags="2">
+ </cTool>
+ </item>
+ <item path="ucs2-lib/unicens/src/ucs_rtm.c" ex="false" tool="0" flavor2="0">
+ <cTool flags="2">
+ </cTool>
+ </item>
+ <item path="ucs2-lib/unicens/src/ucs_scheduler.c"
+ ex="false"
+ tool="0"
+ flavor2="0">
+ <cTool flags="2">
+ </cTool>
+ </item>
+ <item path="ucs2-lib/unicens/src/ucs_segmentation.c"
+ ex="false"
+ tool="0"
+ flavor2="0">
+ <cTool flags="2">
+ </cTool>
+ </item>
+ <item path="ucs2-lib/unicens/src/ucs_smm.c" ex="false" tool="0" flavor2="0">
+ <cTool flags="2">
+ </cTool>
+ </item>
+ <item path="ucs2-lib/unicens/src/ucs_sys_diag.c"
+ ex="false"
+ tool="0"
+ flavor2="0">
+ <cTool flags="2">
+ </cTool>
+ </item>
+ <item path="ucs2-lib/unicens/src/ucs_telqueue.c"
+ ex="false"
+ tool="0"
+ flavor2="0">
+ <cTool flags="2">
+ </cTool>
+ </item>
+ <item path="ucs2-lib/unicens/src/ucs_timer.c" ex="false" tool="0" flavor2="0">
+ <cTool flags="2">
+ </cTool>
+ </item>
+ <item path="ucs2-lib/unicens/src/ucs_transceiver.c"
+ ex="false"
+ tool="0"
+ flavor2="0">
+ <cTool flags="2">
+ </cTool>
+ </item>
+ <item path="ucs2-lib/unicens/src/ucs_xrm.c" ex="false" tool="0" flavor2="0">
+ <cTool flags="2">
+ </cTool>
+ </item>
+ <item path="ucs2-lib/unicens/src/ucs_xrm_res.c" ex="false" tool="0" flavor2="0">
+ <cTool flags="2">
+ </cTool>
+ </item>
+ <item path="ucs2-lib/unicens/src/ucs_xrmpool.c" ex="false" tool="0" flavor2="0">
+ <cTool flags="2">
+ </cTool>
+ </item>
<item path="ucs2-vol/src/callbacks.cpp" ex="false" tool="1" flavor2="4">
<ccTool flags="0">
</ccTool>
diff --git a/ucs2-afb/CMakeLists.txt b/ucs2-afb/CMakeLists.txt
index ee5099e..9bac628 100644
--- a/ucs2-afb/CMakeLists.txt
+++ b/ucs2-afb/CMakeLists.txt
@@ -16,28 +16,44 @@
# limitations under the License.
###########################################################################
+
+# Generate API-v2 hat from OpenAPI json definition
+macro(SET_TARGET_GENSKEL TARGET_NAME API_DEF_NAME)
+ add_custom_command(OUTPUT ${API_DEF_NAME}.h
+ WORKING_DIRECTORY ${CMAKE_CURRENT_SOURCE_DIR}
+ DEPENDS ${API_DEF_NAME}.json
+ COMMAND afb-genskel ${API_DEF_NAME}.json >${API_DEF_NAME}.h
+ )
+ add_custom_target(${API_DEF_NAME}_OPENAPI DEPENDS ${API_DEF_NAME}.h)
+ add_dependencies(${TARGET_NAME} ${API_DEF_NAME}_OPENAPI)
+
+endmacro(SET_TARGET_GENSKEL)
+
# Add target to project dependency list
-PROJECT_TARGET_ADD(ucs2)
+PROJECT_TARGET_ADD(ucs2-afb)
# Define project Targets
- ADD_LIBRARY(ucs2 MODULE ucs_binding.c ucs_apihat.c)
+ ADD_LIBRARY(${TARGET_NAME} MODULE ucs_apihat.c ucs_binding.c )
+
+ # Generate API-v2 hat from OpenAPI json definition
+ SET_TARGET_GENSKEL(${TARGET_NAME} ucs_apidef)
# Binder exposes a unique public entry point
- SET_TARGET_PROPERTIES(ucs2 PROPERTIES
+ SET_TARGET_PROPERTIES(${TARGET_NAME} PROPERTIES
PREFIX "afb-"
LABELS "BINDING"
LINK_FLAGS ${BINDINGS_LINK_FLAG}
- OUTPUT_NAME ${TARGET_NAME}
+ OUTPUT_NAME ucs2
)
# Library dependencies (include updates automatically)
- TARGET_LINK_LIBRARIES(ucs2
+ TARGET_LINK_LIBRARIES(${TARGET_NAME}
ucs2-inter
${link_libraries}
)
# installation directory
- INSTALL(TARGETS ucs2
+ INSTALL(TARGETS ${TARGET_NAME}
LIBRARY DESTINATION ${BINDINGS_INSTALL_DIR})
diff --git a/ucs2-afb/ucs_apidef.h b/ucs2-afb/ucs_apidef.h
new file mode 100644
index 0000000..c23f066
--- /dev/null
+++ b/ucs2-afb/ucs_apidef.h
@@ -0,0 +1,98 @@
+
+static const char _afb_description_v2_UNICENS[] =
+ "{\"openapi\":\"3.0.0\",\"$schema\":\"http:iot.bzh/download/openapi/schem"
+ "a-3.0/default-schema.json\",\"info\":{\"description\":\"\",\"title\":\"u"
+ "cs2\",\"version\":\"1.0\",\"x-binding-c-generator\":{\"api\":\"UNICENS\""
+ ",\"version\":2,\"prefix\":\"ucs2_\",\"postfix\":\"\",\"start\":null,\"on"
+ "event\":null,\"init\":null,\"scope\":\"\",\"private\":false}},\"servers\""
+ ":[{\"url\":\"ws://{host}:{port}/api/monitor\",\"description\":\"Unicens2"
+ " API.\",\"variables\":{\"host\":{\"default\":\"localhost\"},\"port\":{\""
+ "default\":\"1234\"}},\"x-afb-events\":[{\"$ref\":\"#/components/schemas/"
+ "afb-event\"}]}],\"components\":{\"schemas\":{\"afb-reply\":{\"$ref\":\"#"
+ "/components/schemas/afb-reply-v2\"},\"afb-event\":{\"$ref\":\"#/componen"
+ "ts/schemas/afb-event-v2\"},\"afb-reply-v2\":{\"title\":\"Generic respons"
+ "e.\",\"type\":\"object\",\"required\":[\"jtype\",\"request\"],\"properti"
+ "es\":{\"jtype\":{\"type\":\"string\",\"const\":\"afb-reply\"},\"request\""
+ ":{\"type\":\"object\",\"required\":[\"status\"],\"properties\":{\"status"
+ "\":{\"type\":\"string\"},\"info\":{\"type\":\"string\"},\"token\":{\"typ"
+ "e\":\"string\"},\"uuid\":{\"type\":\"string\"},\"reqid\":{\"type\":\"str"
+ "ing\"}}},\"response\":{\"type\":\"object\"}}},\"afb-event-v2\":{\"type\""
+ ":\"object\",\"required\":[\"jtype\",\"event\"],\"properties\":{\"jtype\""
+ ":{\"type\":\"string\",\"const\":\"afb-event\"},\"event\":{\"type\":\"str"
+ "ing\"},\"data\":{\"type\":\"object\"}}}},\"x-permissions\":{\"config\":{"
+ "\"permission\":\"urn:AGL:permission:UNICENS:public:initialise\"},\"monit"
+ "or\":{\"permission\":\"urn:AGL:permission:UNICENS:public:monitor\"}},\"r"
+ "esponses\":{\"200\":{\"description\":\"A complex object array response\""
+ ",\"content\":{\"application/json\":{\"schema\":{\"$ref\":\"#/components/"
+ "schemas/afb-reply\"}}}}}},\"paths\":{\"/listconfig\":{\"description\":\""
+ "List Config Files\",\"get\":{\"x-permissions\":{\"$ref\":\"#/components/"
+ "x-permissions/config\"},\"parameters\":[{\"in\":\"query\",\"name\":\"cfg"
+ "path\",\"required\":false,\"schema\":{\"type\":\"string\"}}],\"responses"
+ "\":{\"200\":{\"$ref\":\"#/components/responses/200\"}}}},\"/initialise\""
+ ":{\"description\":\"configure Unicens2 lib from NetworkConfig.XML.\",\"g"
+ "et\":{\"x-permissions\":{\"$ref\":\"#/components/x-permissions/config\"}"
+ ",\"parameters\":[{\"in\":\"query\",\"name\":\"filename\",\"required\":tr"
+ "ue,\"schema\":{\"type\":\"string\"}}],\"responses\":{\"200\":{\"$ref\":\""
+ "#/components/responses/200\"}}}},\"/volume\":{\"description\":\"Set Mast"
+ "er Volume.\",\"get\":{\"x-permissions\":{\"$ref\":\"#/components/x-permi"
+ "ssions/monitor\"},\"parameters\":[{\"in\":\"query\",\"name\":\"value\",\""
+ "required\":true,\"schema\":{\"type\":\"integer\"}}],\"responses\":{\"200"
+ "\":{\"$ref\":\"#/components/responses/200\"}}}},\"/monitor\":{\"descript"
+ "ion\":\"Subscribe to Unicens Event.\",\"get\":{\"x-permissions\":{\"$ref"
+ "\":\"#/components/x-permissions/monitor\"},\"responses\":{\"200\":{\"$re"
+ "f\":\"#/components/responses/200\"}}}}}}"
+;
+
+static const struct afb_auth _afb_auths_v2_UNICENS[] = {
+ { .type = afb_auth_Permission, .text = "urn:AGL:permission:UNICENS:public:initialise" },
+ { .type = afb_auth_Permission, .text = "urn:AGL:permission:UNICENS:public:monitor" }
+};
+
+ void ucs2_listconfig(struct afb_req req);
+ void ucs2_initialise(struct afb_req req);
+ void ucs2_volume(struct afb_req req);
+ void ucs2_monitor(struct afb_req req);
+
+static const struct afb_verb_v2 _afb_verbs_v2_UNICENS[] = {
+ {
+ .verb = "listconfig",
+ .callback = ucs2_listconfig,
+ .auth = &_afb_auths_v2_UNICENS[0],
+ .info = NULL,
+ .session = AFB_SESSION_NONE_V2
+ },
+ {
+ .verb = "initialise",
+ .callback = ucs2_initialise,
+ .auth = &_afb_auths_v2_UNICENS[0],
+ .info = NULL,
+ .session = AFB_SESSION_NONE_V2
+ },
+ {
+ .verb = "volume",
+ .callback = ucs2_volume,
+ .auth = &_afb_auths_v2_UNICENS[1],
+ .info = NULL,
+ .session = AFB_SESSION_NONE_V2
+ },
+ {
+ .verb = "monitor",
+ .callback = ucs2_monitor,
+ .auth = &_afb_auths_v2_UNICENS[1],
+ .info = NULL,
+ .session = AFB_SESSION_NONE_V2
+ },
+ { .verb = NULL }
+};
+
+const struct afb_binding_v2 afbBindingV2 = {
+ .api = "UNICENS",
+ .specification = _afb_description_v2_UNICENS,
+ .info = NULL,
+ .verbs = _afb_verbs_v2_UNICENS,
+ .preinit = NULL,
+ .init = NULL,
+ .onevent = NULL,
+ .noconcurrency = 0
+};
+
diff --git a/ucs2-afb/ucs_apidef.json b/ucs2-afb/ucs_apidef.json
index 5aa33a2..c200f74 100644
--- a/ucs2-afb/ucs_apidef.json
+++ b/ucs2-afb/ucs_apidef.json
@@ -1,6 +1,6 @@
{
"openapi": "3.0.0",
- "$schema": "file:///home/fulup/Workspace/AGL-AppFW/unicens2rc-afb/etc/openapi-schema.json",
+ "$schema": "http:iot.bzh/download/openapi/schema-3.0/default-schema.json",
"info": {
"description": "",
"title": "ucs2",
@@ -13,8 +13,8 @@
"start": null ,
"onevent": null,
"init": null,
- "scope": "static",
- "private": true
+ "scope": "",
+ "private": false
}
},
"servers": [
@@ -39,12 +39,12 @@
"components": {
"schemas": {
"afb-reply": {
- "$ref": "#/components/schemas/afb-reply-v1"
+ "$ref": "#/components/schemas/afb-reply-v2"
},
"afb-event": {
- "$ref": "#/components/schemas/afb-event-v1"
+ "$ref": "#/components/schemas/afb-event-v2"
},
- "afb-reply-v1": {
+ "afb-reply-v2": {
"title": "Generic response.",
"type": "object",
"required": [ "jtype", "request" ],
@@ -67,7 +67,7 @@
"response": { "type": "object" }
}
},
- "afb-event-v1": {
+ "afb-event-v2": {
"type": "object",
"required": [ "jtype", "event" ],
"properties": {
@@ -102,8 +102,27 @@
}
},
"paths": {
+ "/listconfig": {
+ "description": "List Config Files",
+ "get": {
+ "x-permissions": {
+ "$ref": "#/components/x-permissions/config"
+ },
+ "parameters": [
+ {
+ "in": "query",
+ "name": "cfgpath",
+ "required": false,
+ "schema": { "type": "string" }
+ }
+ ],
+ "responses": {
+ "200": {"$ref": "#/components/responses/200"}
+ }
+ }
+ },
"/initialise": {
- "description": "Initialise Unicens2 lib from NetworkConfig.XML.",
+ "description": "configure Unicens2 lib from NetworkConfig.XML.",
"get": {
"x-permissions": {
"$ref": "#/components/x-permissions/config"
@@ -121,8 +140,27 @@
}
}
},
+ "/volume": {
+ "description": "Set Master Volume.",
+ "get": {
+ "x-permissions": {
+ "$ref": "#/components/x-permissions/monitor"
+ },
+ "parameters": [
+ {
+ "in": "query",
+ "name": "value",
+ "required": true,
+ "schema": { "type": "integer" }
+ }
+ ],
+ "responses": {
+ "200": {"$ref": "#/components/responses/200"}
+ }
+ }
+ },
"/monitor": {
- "description": "Subscribe to Unicens2 Events.",
+ "description": "Subscribe to Unicens Event.",
"get": {
"x-permissions": {
"$ref": "#/components/x-permissions/monitor"
diff --git a/ucs2-afb/ucs_apihat.c b/ucs2-afb/ucs_apihat.c
index fd5d88f..9a6abd9 100644
--- a/ucs2-afb/ucs_apihat.c
+++ b/ucs2-afb/ucs_apihat.c
@@ -16,59 +16,8 @@
*/
#define _GNU_SOURCE
-#include <stdio.h>
-#include <string.h>
-#include <unistd.h>
-#include <errno.h>
-#include <netdb.h>
-#include <fcntl.h>
-#include <math.h>
-#include <sys/time.h>
-#include <sys/types.h>
#include "ucs_binding.h"
-const struct afb_binding_interface *afbIface;
-struct afb_service afbSrv;
-
-/*
- * array of the verbs exported to afb-daemon
- */
-static const struct afb_verb_desc_v1 binding_verbs[] = {
- /* VERB'S NAME SESSION MANAGEMENT FUNCTION TO CALL SHORT DESCRIPTION */
- { .name= "initialise", .session= AFB_SESSION_NONE, .callback= ucs2Init, .info= "Parse XML & initialise Unicens " },
- { .name= "setvol" , .session= AFB_SESSION_NONE, .callback= ucs2SetVol, .info= "Set Volume" },
- // { .name= "monitor" , .session= AFB_SESSION_NONE, .callback= ucs2Monitor, .info= "Subscribe to network error" },
-
-
- { .name= NULL } /* marker for end of the array */
-};
-
-/*
- * description of the binding for afb-daemon
- */
-static const struct afb_binding binding_description = {
- /* description conforms to VERSION 1 */
- .type= AFB_BINDING_VERSION_1,
- .v1= {
- .prefix= "UNICENS",
- .info= "UNICENS MOST Control API",
- .verbs = binding_verbs
- }
-};
-
-// this is call when after all bindings are loaded
- int afbBindingV1ServiceInit(struct afb_service service) {
- afbSrv = service;
- return (0);
-}
-
-/*
- * activation function for registering the binding called by afb-daemon
- */
- const struct afb_binding *afbBindingV1Register(const struct afb_binding_interface *itf) {
- afbIface= itf;
-
- return &binding_description; /* returns the description of the binding */
-}
-
+// include code generated from afb-genskel
+#include "ucs_apidef.h"
diff --git a/ucs2-afb/ucs_apihat.h b/ucs2-afb/ucs_apihat.h
deleted file mode 100644
index 8926344..0000000
--- a/ucs2-afb/ucs_apihat.h
+++ /dev/null
@@ -1,48 +0,0 @@
-/*
- * AlsaLibMapping -- provide low level interface with AUDIO lib (extracted from alsa-json-gateway code)
- * Copyright (C) 2015,2016,2017, 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.
- */
-
-#ifndef UCS2BINDING_H
-#define UCS2BINDING_H
-
-#ifndef PUBLIC
- #define PUBLIC
-#endif
-#define STATIC static
-
-#include <json-c/json.h>
-#include <afb/afb-binding.h>
-#include <afb/afb-service-itf.h>
-
-#include "ucs_interface.h"
-
-#ifndef CONTROL_CDEV_TX
-#error FATAL: CONTROL_CDEV_TX missing (check ./etc/config.cmake + rerun cmake)
-#endif
-#ifndef CONTROL_CDEV_RX
-#error FATAL: CONTROL_CDEV_RX missing (check ./etc/config.cmake + rerun cmake)
-#endif
-
-// import from AlsaAfbBinding
-extern const struct afb_binding_interface *afbIface;
-extern struct afb_service afbSrv;
-
-// API verbs prototype
-PUBLIC void initUcs2 (struct afb_req request);
-
-
-#endif /* UCS2BINDING_H */
-
diff --git a/ucs2-afb/ucs_binding.c b/ucs2-afb/ucs_binding.c
index 59e1532..c0a9fcf 100644
--- a/ucs2-afb/ucs_binding.c
+++ b/ucs2-afb/ucs_binding.c
@@ -34,6 +34,7 @@
#include <time.h>
#include <assert.h>
#include <errno.h>
+#include <dirent.h>
#include "ucs_binding.h"
#include "ucs_interface.h"
@@ -65,11 +66,18 @@ typedef struct {
static ucsContextT *ucsContextS;
PUBLIC void UcsXml_CB_OnError(const char format[], uint16_t vargsCnt, ...) {
- /*DEBUG (afbIface, format, args); */
+ /*AFB_DEBUG (afbIface, format, args); */
va_list args;
va_start (args, vargsCnt);
vfprintf (stderr, format, args);
va_end(args);
+
+ va_list argptr;
+ char outbuf[300];
+ va_start(argptr, vargsCnt);
+ vsprintf(outbuf, format, argptr);
+ va_end(argptr);
+ AFB_WARNING (outbuf);
}
PUBLIC uint16_t UCSI_CB_OnGetTime(void *pTag) {
@@ -99,8 +107,8 @@ STATIC int onTimerCB (sd_event_source* source,uint64_t timer, void* pTag) {
PUBLIC void UCSI_CB_OnSetServiceTimer(void *pTag, uint16_t timeout) {
uint64_t usec;
/* set a timer with 250ms accuracy */
- sd_event_now(afb_daemon_get_event_loop(afbIface->daemon), CLOCK_BOOTTIME, &usec);
- sd_event_add_time(afb_daemon_get_event_loop(afbIface->daemon), NULL, CLOCK_MONOTONIC, usec + (timeout*1000), 250, onTimerCB, pTag);
+ sd_event_now(afb_daemon_get_event_loop(), CLOCK_BOOTTIME, &usec);
+ sd_event_add_time(afb_daemon_get_event_loop(), NULL, CLOCK_MONOTONIC, usec + (timeout*1000), 250, onTimerCB, pTag);
}
@@ -121,7 +129,7 @@ void UCSI_CB_OnUserMessage(void *pTag, bool isError, const char format[],
vsprintf(outbuf, format, argptr);
va_end(argptr);
if (isError)
- NOTICE (afbIface, outbuf);
+ AFB_NOTICE (outbuf);
}
/** UCSI_Service cannot be called directly within UNICENS context, need to service stack through mainloop */
@@ -137,7 +145,7 @@ STATIC int OnServiceRequiredCB (sd_event_source *source, uint64_t usec, void *pT
PUBLIC void UCSI_CB_OnServiceRequired(void *pTag) {
/* push an asynchronous request for loopback to call UCSI_Service */
- sd_event_add_time(afb_daemon_get_event_loop(afbIface->daemon), NULL, CLOCK_MONOTONIC, 0, 0, OnServiceRequiredCB, pTag);
+ sd_event_add_time(afb_daemon_get_event_loop(), NULL, CLOCK_MONOTONIC, 0, 0, OnServiceRequiredCB, pTag);
}
/* Callback when ever this UNICENS wants to send a message to INIC. */
@@ -173,7 +181,7 @@ PUBLIC void UCSI_CB_OnTxRequest(void *pTag, const uint8_t *pData, uint32_t len)
* \param pTag - Pointer given by the integrator by UCSI_Init
*/
void UCSI_CB_OnStop(void *pTag) {
- NOTICE (afbIface, "UNICENS stopped");
+ AFB_NOTICE ("UNICENS stopped");
}
@@ -239,7 +247,7 @@ int onReadCB (sd_event_source* src, int fileFd, uint32_t revents, void* pTag) {
return 0;
ok= UCSI_ProcessRxData(&ucsContext->ucsiData, pBuffer, (uint16_t)len);
if (!ok) {
- DEBUG (afbIface, "Buffer overrun (not handle)");
+ AFB_DEBUG ("Buffer overrun (not handle)");
/* Buffer overrun could replay pBuffer */
}
return 0;
@@ -272,7 +280,7 @@ STATIC UcsXmlVal_t* ParseFile(struct afb_req request) {
xmlBuffer[readSize] = '\0'; /* In any case, terminate it. */
if (readSize != fdStat.st_size) {
- afb_req_fail_f (request, "fileread-fail", "File to read fullfile '%s' size(%d!=%d)", filename, readSize, fdStat.st_size);
+ afb_req_fail_f (request, "fileread-fail", "File to read fullfile '%s' size(%d!=%d)", filename, (int)readSize, (int)fdStat.st_size);
goto OnErrorExit;
}
@@ -300,8 +308,8 @@ STATIC int volOnSvcCB (sd_event_source* source,uint64_t timer, void* pTag) {
/* This callback is fire each time an volume event wait in the queue */
void volumeCB (uint16_t timeout) {
uint64_t usec;
- sd_event_now(afb_daemon_get_event_loop(afbIface->daemon), CLOCK_BOOTTIME, &usec);
- sd_event_add_time(afb_daemon_get_event_loop(afbIface->daemon), NULL, CLOCK_MONOTONIC, usec + (timeout*1000), 250, volOnSvcCB, ucsContextS);
+ sd_event_now(afb_daemon_get_event_loop(), CLOCK_BOOTTIME, &usec);
+ sd_event_add_time(afb_daemon_get_event_loop(), NULL, CLOCK_MONOTONIC, usec + (timeout*1000), 250, volOnSvcCB, ucsContextS);
}
STATIC int volSndCmd (struct afb_req request, struct json_object *commandJ, ucsContextT *ucsContext) {
@@ -380,8 +388,7 @@ STATIC int volSndCmd (struct afb_req request, struct json_object *commandJ, ucsC
return 1;
}
-
-PUBLIC void ucs2SetVol (struct afb_req request) {
+PUBLIC void ucs2_volume (struct afb_req request) {
struct json_object *queryJ;
int err;
@@ -424,7 +431,7 @@ PUBLIC void ucs2SetVol (struct afb_req request) {
}
-PUBLIC void ucs2Init (struct afb_req request) {
+PUBLIC void ucs2_initialise (struct afb_req request) {
static UcsXmlVal_t *ucsConfig;
static ucsContextT ucsContext;
@@ -447,7 +454,7 @@ PUBLIC void ucs2Init (struct afb_req request) {
UCSI_Init(&ucsContext.ucsiData, &ucsContext);
/* register aplayHandle file fd into binder mainloop */
- err = sd_event_add_io(afb_daemon_get_event_loop(afbIface->daemon), &evtSource, ucsContext.rx.fileHandle, EPOLLIN, onReadCB, &ucsContext);
+ err = sd_event_add_io(afb_daemon_get_event_loop(), &evtSource, ucsContext.rx.fileHandle, EPOLLIN, onReadCB, &ucsContext);
if (err < 0) {
afb_req_fail_f (request, "register-mainloop", "Cannot hook events to mainloop");
goto OnErrorExit;
@@ -473,3 +480,60 @@ PUBLIC void ucs2Init (struct afb_req request) {
OnErrorExit:
return;
}
+
+
+// List Avaliable Configuration Files
+PUBLIC void ucs2_listconfig (struct afb_req request) {
+ struct json_object *queryJ, *tmpJ, *responseJ;
+ DIR *dirHandle;
+ char *dirPath, *dirList;
+ int error=0;
+
+ queryJ = afb_req_json(request);
+ if (queryJ && json_object_object_get_ex (queryJ, "cfgpath" , &tmpJ)) {
+ strdup (json_object_get_string(tmpJ));
+ } else {
+ dirList = strdup (UCS2_CFG_PATH);
+ AFB_NOTICE ("fgpath:missing uses UCS2_CFG_PATH=%s", UCS2_CFG_PATH);
+ }
+
+ responseJ = json_object_new_array();
+ for (dirPath= strtok(dirList, ":"); dirPath && *dirPath; dirPath=strtok(NULL,":")) {
+ struct dirent *dirEnt;
+
+ dirHandle = opendir (dirPath);
+ if (!dirHandle) {
+ AFB_NOTICE ("ucs2_listconfig dir=%s not readable", dirPath);
+ error++;
+ continue;
+ }
+
+ AFB_NOTICE ("ucs2_listconfig scanning: %s", dirPath);
+ while ((dirEnt = readdir(dirHandle)) != NULL) {
+ // Unknown type is accepted to support dump filesystems
+ if (dirEnt->d_type == DT_REG || dirEnt->d_type == DT_UNKNOWN) {
+ struct json_object *pathJ = json_object_new_object();
+ json_object_object_add(pathJ, "dirpath", json_object_new_string(dirPath));
+ json_object_object_add(pathJ, "basename", json_object_new_string(dirEnt->d_name));
+ json_object_array_add(responseJ, pathJ);
+ }
+ }
+ }
+
+ free (dirList);
+
+ if (!error) afb_req_success(request,responseJ,NULL);
+ else {
+ char info[40];
+ snprintf (info, sizeof(info), "[%d] where not scanned", error);
+ afb_req_success(request,responseJ, info);
+ }
+
+ return;
+}
+
+PUBLIC void ucs2_monitor (struct afb_req request) {
+
+ afb_req_success(request,NULL,"UNICENS-to_be_done");
+}
+
diff --git a/ucs2-afb/ucs_binding.h b/ucs2-afb/ucs_binding.h
index 5b74730..4265762 100644
--- a/ucs2-afb/ucs_binding.h
+++ b/ucs2-afb/ucs_binding.h
@@ -18,6 +18,9 @@
#ifndef UCS2BINDING_H
#define UCS2BINDING_H
+// Use Version of AGL Application Framework API
+#define AFB_BINDING_VERSION 2
+
#ifndef PUBLIC
#define PUBLIC
#endif
@@ -25,7 +28,6 @@
#include <json-c/json.h>
#include <afb/afb-binding.h>
-#include <afb/afb-service-itf.h>
#include "ucs_interface.h"
@@ -41,8 +43,9 @@ extern const struct afb_binding_interface *afbIface;
extern struct afb_service afbSrv;
// API verbs prototype
-PUBLIC void ucs2Init (struct afb_req request);
-PUBLIC void ucs2SetVol (struct afb_req request);
+PUBLIC void ucs2_configure (struct afb_req request);
+PUBLIC void ucs2_volume (struct afb_req request);
+PUBLIC void ucs2_monitor (struct afb_req request);
#endif /* UCS2BINDING_H */
diff --git a/ucs2-lib/unicens b/ucs2-lib/unicens
-Subproject 983149ad074e8a0febbf3b6bd1386f4d4da9b07
+Subproject 026fd1ff36f944e308839be387445bc836a40dc