aboutsummaryrefslogtreecommitdiffstats
path: root/htdocs
diff options
context:
space:
mode:
authorfulup <fulup.arfoll@iot.bzh>2017-07-25 11:37:10 +0200
committerfulup <fulup.arfoll@iot.bzh>2017-07-25 11:37:10 +0200
commit593ed6dc72274f86046aae3dc6b264c568241917 (patch)
tree32615a58bedbc0b2fcdf05db4a66d15ceafd763a /htdocs
parenta7a6ae4be87ee9178905ab784d84a4c0a8303f9b (diff)
Initial version of HAL with Set/Get operation
Diffstat (limited to 'htdocs')
-rw-r--r--htdocs/AudioBinding.js102
-rw-r--r--htdocs/alsa-core.html38
-rw-r--r--htdocs/alsa-hal.html10
3 files changed, 101 insertions, 49 deletions
diff --git a/htdocs/AudioBinding.js b/htdocs/AudioBinding.js
index e000a70..607d31c 100644
--- a/htdocs/AudioBinding.js
+++ b/htdocs/AudioBinding.js
@@ -2,6 +2,7 @@
var ws;
var sndcard="HALNotSelected";
var evtidx=0;
+ var numid=0;
function syntaxHighlight(json) {
if (typeof json !== 'string') {
@@ -48,31 +49,10 @@
if (!sndname) sndname="PCH";
var mode=getParameterByName("mode");
- if (!mode) mode="99";
+ if (!mode) mode="0";
- function init(elemid, api, verb, query) {
-
- function onopen() {
- // check for active HALs
- probeActiveHal (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);
- }
function replyok(obj) {
console.log("replyok:" + JSON.stringify(obj));
@@ -106,9 +86,17 @@
}
- // Retrieve the list of active HAL
- function probeActiveHal (elemid, api, verb, query) {
+ // 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(){
@@ -139,12 +127,72 @@
sndcard= selectobj.value;
}
-
- console.log ("subscribe api="+api+" verb="+verb+" query=" +query);
-
+
+ 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 refresh_list (self, api, verb, query) {
+ console.log("refresh_list id=%s api=%s verb=%s query=%s", self.id, api, verb, query);
+
+ if (self.value > 0) return;
+
+ // onlick update selected HAL api
+ self.onclick=function(){
+ numid = parseInt(self.value);
+ console.log ("Default numid=%d", numid);
+ };
+
+ 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');
+
+ // Alsa LowLevel selection mode
+ opt.text = response[idx].name + ' id=' + response[idx].id;
+ opt.value = response[idx].id;
+
+ self.appendChild(opt);
+ }
+ self.selectedIndex=2;
+ numid = parseInt (self.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/htdocs/alsa-core.html b/htdocs/alsa-core.html
index 9b6e214..dafd43f 100644
--- a/htdocs/alsa-core.html
+++ b/htdocs/alsa-core.html
@@ -2,19 +2,22 @@
<head>
<link rel="stylesheet" href="AudioBinding.css">
<title>Alsa Low Level Simple Test</title>
-
-
+
<script type="text/javascript" src="AFB-websock.js"></script>
<script type="text/javascript" src="AudioBinding.js"></script>
</head>
-<body onload="init('alsa_registry','alsacore', 'getinfo');">
+<body onload="init('alsa_registry','alsacore', 'getinfo')">
-<b> references</b>
- <button id="connected" onclick="init('alsa_registry','alsacore', 'getinfo')">Binder WS Fail</button>
+ <button id="connected" onclick="init('alsa_registry','alsacore', 'getinfo');">Binder WS Fail</button>
<br><br>
<b>Selected SndCard </b>
<select id='alsa_registry'></select>
+
+ <b>Select NUMID </b>
+ <select id='alsa_ctl_list' onclick="refresh_list(this, 'alsacore', 'getctl', {devid:sndcard, mode:1})">
+ <option value='-1'>Refresh NUMID list</option>
+ </select>
<b>API Verbosity </b>
<select id='api_verbosity' onclick='mode=this.value'>
@@ -22,21 +25,22 @@
<option value='1'>Compact</option>
<option value='2'>Verbose</option>
<option value='3'>Full</option>
- </select>
- <br>
-
+ </select>
+
+ <br>
<ol>
<li><button onclick="callbinder('alsacore','getctl', {devid:sndcard, mode:mode})">Get all Alsa Ctls</button></li>
- <li><button onclick="callbinder('alsacore','getctl', {devid:sndcard, mode:mode, numids:[6]})">Get Alsa Ctls numids:[6]</button></li>
- <li><button onclick="callbinder('alsacore','getctl', {devid:sndcard, mode:mode, numids:[1,2]})">Get Alsa Ctls numids:[1,2]</button></li>
- <li><button onclick="callbinder('alsacore','getctl', {devid:sndcard, mode:mode, numids:17})">Get Alsa Ctl numids:17</button></li>
- <br>
- <li><button onclick="callbinder('alsacore','setctl', {devid:sndcard, mode:mode, numids:[[17,20]]})">Set Alsa Ctl numid:[[17,20]]</button></li>
- <li><button onclick="callbinder('alsacore','setctl', {devid:sndcard, mode:mode, numids:[{id:17,val:50}]})">Set Alsa Ctl numid:[{id:17,val:50}]}</button></li>
- <li><button onclick="callbinder('alsacore','setctl', {devid:sndcard, mode:mode, numids:[[1,[20,20]]]})">Set Alsa Ctl numids:[[1,[20,20]]]</button></li>
- <li><button onclick="callbinder('alsacore','setctl', {devid:sndcard, mode:mode, numids:[{id:1,val:[50,50]}]})">Set Alsa Ctl numids:[{id:1,val:[50,50]}]</button></li>
- <li><button onclick="callbinder('alsacore','setctl', {devid:sndcard, mode:mode, numids:[{id:1,val:[50,50]}, {id:17,val:50,50}]})">Set Alsa Ctl numids:[{id:1,val:[50,50]}, {id:17,val:50,50}]</button></li>
+ <li><button onclick="callbinder('alsacore','getctl', {devid:sndcard, mode:mode, numid:[numid]})">Get Alsa Ctls [numid]</button></li>
+ <li><button onclick="callbinder('alsacore','getctl', {devid:sndcard, mode:mode, numid:[numid,numid+1]})">Get Alsa Ctls [numid,numid+1]</button></li>
+ <br>
+
+
+ <li><button onclick="callbinder('alsacore','setctl', {devid:sndcard, mode:mode, numid:[[9,20]]})">Set Alsa Ctl numid:[[9,20]]</button></li>
+ <li><button onclick="callbinder('alsacore','setctl', {devid:sndcard, mode:mode, numid:[{id:9,val:50}]})">Set Alsa Ctl numid:[{id:9,val:50}]}</button></li>
+ <li><button onclick="callbinder('alsacore','setctl', {devid:sndcard, mode:mode, numid:[[6,[20,20]]]})">Set Alsa Ctl numid:[[6,[20,20]]]</button></li>
+ <li><button onclick="callbinder('alsacore','setctl', {devid:sndcard, mode:mode, numid:[{id:6,val:[50,50]}]})">Set Alsa Ctl numid:[{id:2,val:[50,50]}]</button></li>
+ <li><button onclick="callbinder('alsacore','setctl', {devid:sndcard, mode:mode, numid:[{id:6,val:[50,50]}, {id:9,val:50,50}]})">Set Alsa Ctl numid:[{id:6,val:[50,50]}, {id:9,val:50,50}]</button></li>
<br>
<li><button onclick="callbinder('alsacore','ucmquery', {devid:sndcard, mode:mode})">List UCM verbs</button></li>
<li><button onclick="callbinder('alsacore','ucmset' , {devid:sndcard, mode:mode, verb:'HiFi'})">Set UCM HiFi</button></li>
diff --git a/htdocs/alsa-hal.html b/htdocs/alsa-hal.html
index 7a8655c..7377bd4 100644
--- a/htdocs/alsa-hal.html
+++ b/htdocs/alsa-hal.html
@@ -27,15 +27,15 @@
<br>
<ol>
- <li><button onclick="callbinder(sndcard,'listctls')">List Selected HAL Controls </button></li>
+ <li><button onclick="callbinder(sndcard,'ctl-list')">List Selected HAL Controls </button></li>
<li><button onclick="callbinder(sndcard,'ctl-get', {label:'Master_Playback_Volume'})">Get {label:'Master_Playback_Volume'}</button></li>
<li><button onclick="callbinder(sndcard,'ctl-get', [{tag:4},{tag:5}])">Get[{tag:4},{tag:5}]</button></li>
<li><button onclick="callbinder(sndcard,'ctl-get', [4,5])">Get [4,5]</button></li>
<br>
- <li><button onclick="callbinder(sndcard,'ctl-set', {label:'Master_Playback_Volume', value=[50]})">Set {label:'Master_Playback_Volume', value=[50]}</button></li>
- <li><button onclick="callbinder(sndcard,'ctl-set', [{tag:4, value:25},{tag:5, value:25}])">Set[{tag:4, value:25},{tag:5, value:25}]</button></li>
- <li><button onclick="callbinder(sndcard,'ctl-set', [{tag:4, value:[55,45]},{tag:5, value:[45,55]}])">Set[{tag:4, value:[55,45]},{tag:5, value:[45,55]}]]</button></li>
- <li><button onclick="callbinder(sndcard,'ctl-set', [4,5])">Set [4,5]</button></li>
+ <li><button onclick="callbinder(sndcard,'ctl-set', {label:'Master_Playback_Volume', val:[50]})">Set {label:'Master_Playback_Volume', value=[50]}</button></li>
+ <li><button onclick="callbinder(sndcard,'ctl-set', {tag: 4, val:5})">Set {tag: 4, val:5}</button></li>
+ <li><button onclick="callbinder(sndcard,'ctl-set', [{tag:4, val:25},{tag:5, val:25}])">Set[{tag:4, val:25},{tag:5, val:25}]</button></li>
+ <li><button onclick="callbinder(sndcard,'ctl-set', [{tag:4, val:[55,45]},{tag:5, val:[45,55]}])">Set[{tag:4, val:[55,45]},{tag:5, val:[45,55]}]]</button></li>
<br>
</ol>