summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
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--htdocs/AFB-websock.js7
-rw-r--r--htdocs/AudioBinding.js72
-rw-r--r--htdocs/UNICENS.html25
-rw-r--r--htdocs/Ucs2Binding.css7
-rw-r--r--htdocs/Ucs2Binding.js162
-rw-r--r--nbproject/configurations.xml357
-rw-r--r--ucs2-afb/ucs_apidef.h44
-rw-r--r--ucs2-afb/ucs_apidef.json21
-rw-r--r--ucs2-afb/ucs_binding.c58
13 files changed, 670 insertions, 127 deletions
diff --git a/conf.d/app-templates b/conf.d/app-templates
-Subproject db6a07f636a3f2a381dfcc0f52b16f59127496f
+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/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..11746c6 100644
--- a/htdocs/UNICENS.html
+++ b/htdocs/UNICENS.html
@@ -1,17 +1,22 @@
<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','initialise', {filename:ucs2_config})">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>
@@ -26,8 +31,8 @@
<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 9bf2285..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>
@@ -214,12 +273,12 @@
<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>
@@ -228,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>
@@ -251,29 +312,43 @@
</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>
@@ -286,10 +361,13 @@
<pElem>ucs2-vol/src/ucs-xml</pElem>
<pElem>build/ucs2-afb</pElem>
</incDir>
+ <preprocessorList>
+ <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>
@@ -302,6 +380,9 @@
<pElem>ucs2-vol/src/ucs-xml</pElem>
<pElem>build/ucs2-afb</pElem>
</incDir>
+ <preprocessorList>
+ <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">
@@ -321,19 +402,26 @@
</cTool>
</item>
<item path="ucs2-interface/ucs-xml/UcsXml.c" ex="false" tool="0" flavor2="2">
- <cTool flags="1">
+ <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">
@@ -548,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/ucs_apidef.h b/ucs2-afb/ucs_apidef.h
index c8ce266..c23f066 100644
--- a/ucs2-afb/ucs_apidef.h
+++ b/ucs2-afb/ucs_apidef.h
@@ -24,19 +24,23 @@ static const char _afb_description_v2_UNICENS[] =
"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\":{\"/configure\":{\"description\":\"c"
- "onfigure Unicens2 lib from NetworkConfig.XML.\",\"get\":{\"x-permissions"
- "\":{\"$ref\":\"#/components/x-permissions/config\"},\"parameters\":[{\"i"
- "n\":\"query\",\"name\":\"filename\",\"required\":true,\"schema\":{\"type"
- "\":\"string\"}}],\"responses\":{\"200\":{\"$ref\":\"#/components/respons"
- "es/200\"}}}},\"/volume\":{\"description\":\"Set Master Volume.\",\"get\""
- ":{\"x-permissions\":{\"$ref\":\"#/components/x-permissions/monitor\"},\""
- "parameters\":[{\"in\":\"query\",\"name\":\"value\",\"required\":true,\"s"
- "chema\":{\"type\":\"integer\"}}],\"responses\":{\"200\":{\"$ref\":\"#/co"
- "mponents/responses/200\"}}}},\"/monitor\":{\"description\":\"Subscribe t"
- "o Unicens Event.\",\"get\":{\"x-permissions\":{\"$ref\":\"#/components/x"
- "-permissions/monitor\"},\"responses\":{\"200\":{\"$ref\":\"#/components/"
- "responses/200\"}}}}}}"
+ "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[] = {
@@ -44,14 +48,22 @@ static const struct afb_auth _afb_auths_v2_UNICENS[] = {
{ .type = afb_auth_Permission, .text = "urn:AGL:permission:UNICENS:public:monitor" }
};
- void ucs2_configure(struct afb_req req);
+ 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 = "configure",
- .callback = ucs2_configure,
+ .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
diff --git a/ucs2-afb/ucs_apidef.json b/ucs2-afb/ucs_apidef.json
index 274ce73..c200f74 100644
--- a/ucs2-afb/ucs_apidef.json
+++ b/ucs2-afb/ucs_apidef.json
@@ -102,7 +102,26 @@
}
},
"paths": {
- "/configure": {
+ "/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": "configure Unicens2 lib from NetworkConfig.XML.",
"get": {
"x-permissions": {
diff --git a/ucs2-afb/ucs_binding.c b/ucs2-afb/ucs_binding.c
index efb4928..1c318fa 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"
@@ -379,7 +380,6 @@ STATIC int volSndCmd (struct afb_req request, struct json_object *commandJ, ucsC
return 1;
}
-
PUBLIC void ucs2_volume (struct afb_req request) {
struct json_object *queryJ;
int err;
@@ -423,7 +423,7 @@ PUBLIC void ucs2_volume (struct afb_req request) {
}
-PUBLIC void ucs2_configure (struct afb_req request) {
+PUBLIC void ucs2_initialise (struct afb_req request) {
static UcsXmlVal_t *ucsConfig;
static ucsContextT ucsContext;
@@ -473,7 +473,59 @@ PUBLIC void ucs2_configure (struct afb_req request) {
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");
-} \ No newline at end of file
+}
+