From 4edf6cc629af725548430ea75af25fe9ca76ed33 Mon Sep 17 00:00:00 2001 From: Frederic Marec Date: Fri, 28 Jun 2019 11:22:11 +0200 Subject: Initial commit Bug-AGL: SPEC-2020 Create README.md add git submodule from app-templates Change-Id: I091f4e527a9713772356bdb2cf6e89e2ea5267a4 Signed-off-by: Stephane Desneux add sources and CMakelists Change-Id: I6b54d16764435c166e6ae261f48d1d6df34fdcad Signed-off-by: Stephane Desneux CMakelists: fix config.cmake path Change-Id: I87d774cb09d41b4f83a1ebea92feef27791dfadc Signed-off-by: Stephane Desneux conf.d: move to master branch Change-Id: Idd92d6aa5e136b1fd193ad4774204535bb423964 Signed-off-by: Stephane Desneux Add build instruction in README Signed-off-by: Sebastien Douheret Add gitignore Signed-off-by: Sebastien Douheret move config.cmake to subdir conf.d Change-Id: I329f858f0d5a56f6db4c7441cb9e8e2fa0a1a5f0 Signed-off-by: Stephane Desneux conf.d/default: add submodule to app-templates Change-Id: I201a35efe3ea9679d39f3f5e9e28e47bf88481ab Signed-off-by: Stephane Desneux CMakeLists: fix path to use conf.d/default Change-Id: Ic6d5b467baa0e871466d893073687a396a2d0ccf Signed-off-by: Stephane Desneux config.cmake: fix app-templates path Change-Id: I9e5c7cd0648a23c006642b4031cee5394551579f Signed-off-by: Stephane Desneux config.cmake: update content entry point and mimetype Change-Id: I671633e3b10c540aa38c8ab160136be971d575a4 Signed-off-by: Stephane Desneux update gitignore for vim Change-Id: I7925ef65d3e35fd6458be58ec7e1130e74d02af1 Signed-off-by: Stephane Desneux README: updated Change-Id: I8af6297184c1633aa07dda4dcd5f37b261795e6b Signed-off-by: Stephane Desneux bump app-templates Change-Id: I88353abd15bade3df0538e47a332b5ef10606587 Signed-off-by: Stephane Desneux config: add custom widget config; bump app-templates Change-Id: I1407d99ea9eced4f653c3b9ef78b5064266843a1 Signed-off-by: Stephane Desneux add RPM specfile; bump app-templates; fix conf.d/* paths Change-Id: I06cf8cae10f0783b45ef10c0891202347d8c7ec4 Signed-off-by: Stephane Desneux rename conf.d/default to conf.d/app-templates Change-Id: I3e91069c5f3019274f2b09255c783b240134faab Signed-off-by: Stephane Desneux config.cmake: fix widget entry point Change-Id: I5a0c1fd2ac97c0643273e25d2cbb1d761b2af5d5 Signed-off-by: Stephane Desneux adjust config.xml (required-api); bump app-templates Change-Id: I8b68f239fa0ee7107ac211cda24060b0ba447300 Signed-off-by: Stephane Desneux fix binder api export mode; fix 'licence' typo Change-Id: I57c4f4480412850160e4b0d523a2b52b30567fc3 Signed-off-by: Stephane Desneux Allows kernel minimal version check Update submodule that allows the check to be performed against a Yocto generated SDK or current running kernel Change-Id: If5a1f312091d9ad0b9c80b4824c8e0081513aced Signed-off-by: Romain Forlot Use latest app-templates version Change-Id: If485ae471590a529e038a1636708a7e819aa22ce Signed-off-by: Romain Forlot update cmake config file Signed-off-by: Ronan Le Martret fix build warning Signed-off-by: Ronan Le Martret Update packaging * Add debian packaging Signed-off-by: Ronan Le Martret Update to the latest app-templates version No more needs to call any macro and only include config.cmake file is mandatory. Common.cmake is include from config.cmake file Generation autobuild script in conf.d/autobuild dir Change-Id: I0b9bf73209e9ffbcab687024b6580f0a8c399597 Signed-off-by: Romain Forlot update gitignore Signed-off-by: Ronan Le Martret Use latest version of conf.d/app-templates submodule. Changes of conf.d/app-templates: > Fix: idem... > Fix: Debian things triggered even when use the SDK > Merge "Add pkg-config for deb packaging" > Fix: wrong variable expands at configure_file time > Comments and README update > Autobuild scripts directory execution proof > Use variable to handle autobuild target directory > Fix: Debian detection, only valid in native env > Move variable definition to the right place. > change path etc/config.cmake to conf.d/cmake/config.cmake Signed-off-by: Sebastien Douheret conf.d/autobuild: add generated autobuild script Change-Id: I79772a93e98e6f990890336728e356d6ddd2e3d0 Signed-off-by: Stephane Desneux Migration to binding version 2 Change-Id: I4dd1b0bf213a5b0d3d1751dbde781f88645f3f56 Signed-off-by: Romain Forlot Update app-templates Change-Id: Idbb3fe78aab559b5c81899861a07d01265f09867 Signed-off-by: Romain Forlot Fix: missing MimeType Change-Id: Ia114680759481cf8eefd795143760485026c8680 Signed-off-by: Romain Forlot Updated autobuild scripts. Change-Id: I7c16f07420eeb312061b5164a00dbd10a9325f5d Signed-off-by: Romain Forlot Update to the latest version resolving yocto build Change-Id: I6ad988bc1ac457eaf24c0b586ab9d3754fa62bbf Signed-off-by: Romain Forlot Fix widget type Use latest version of conf.d/app-templates submodule. Changes of conf.d/app-templates: (48149ac - Sebastien Douheret) Set scripts sh as executable (8c2d06a - Romain Forlot) Add configured file to files to clean up with make (e475d27 - Romain Forlot) Fix: wrong extension of configured files (e2fefbf - Romain Forlot) Add some reminder (6be72c1 - Romain Forlot) Fix: Yocto cross compile flag same the last commit Signed-off-by: Sebastien Douheret Use latest version of conf.d/app-templates submodule. Changes of conf.d/app-templates: (70dc538 - Romain Forlot) Default execution flag on shell scripts templates. (be6f910 - Romain Forlot) Fix: also avoid cleaning generated packaging files (85ece74 - Romain Forlot) Fix: cleaning of autobuild script using make clean (747c39c - Romain Forlot) Fix: cleaning generated additionals files (48149ac - Sebastien Douheret) Set scripts sh as executable Signed-off-by: Sebastien Douheret update app-templates Signed-off-by: Builder update autobuild script Signed-off-by: Builder update .gitignore Signed-off-by: Ronan Le Martret add security auth Signed-off-by: Ronan Le Martret update documentation Signed-off-by: Ronan Le Martret fix README Signed-off-by: Ronan Le Martret Update README.md Update For New App Template Set correct ldpaths in closing message. Git ignore private files/dirs (starting by __*) Add simple html page to test helloworld service. Add htdocs/assets to install Update version Signed-off-by: Ronan Le Martret update app-templates Signed-off-by: Ronan Le Martret update packaging Signed-off-by: Ronan Le Martret app-templates: bump to 42e5f14 Change-Id: I33a3680db8109e2c817e564662d965ef22274a11 Signed-off-by: Stephane Desneux bump submodule conf.d/app-templates Change-Id: I605aa515568dbbada37b3ff0a7f9ed21a2aed51a Signed-off-by: Stephane Desneux Update app-templates and autobuild script Change-Id: Ic8a2cb9b7e42d821a1452923a714280a432a508f Signed-off-by: Romain Forlot Fix variable overlapping Issue #3 Change-Id: I0f0b81a59ab45bbb9a54350878553a4f4332d20f Signed-off-by: Romain Forlot Fix typo ! C/C is the evil, C/C is the evil, C/C is the evil ! app-templates migration to cmake module Change-Id: I402cdc81f933201b6260fa72145e349b48b8c902 Signed-off-by: Romain Forlot Update readme about CMake module dependency Change-Id: Id7ee12069a47fcf05821d2338cf501fffb4cbbe2 Signed-off-by: Romain Forlot Switch to bindings V3 Aply automatic migration script. Update disclamer dates Remove dumb dependencies Signed-off-by: Jose Bollo Reorganization, new helloworld variant - Add a new binding service example with subscription/unsubscription and event mechanisms implementation example. - Adding the autobuild scripts within the repository Change-Id: I53efc22ac868e47ea7cffd3f8916fe21528ab9c7 Signed-off-by: Romain Forlot Correct some errors in README.md Adding information about JSON library and HTTPD alternative package package. Signed-off-by: Marc-Antoine Riou readme: Update agl script name Since the commit https://gerrit.automotivelinux.org/gerrit/gitweb?p=src/app-framework-binder.git;a=commit;h=c80873f04c5122e579333b4cf363dd623200e822, AGL-app-framework-binder.sh script has been renamed. Signed-off-by: Pierre MARZIN conf.d: Correct name of the required-api Needed since the "Reorganization" of helloworld service (commit 2f2658dc9fe2abe2d059e52dc8fbb3ab531f8a9d). Signed-off-by: Pierre MARZIN test: Add test scripts to test hello binding Scripts come from the app-afb-test binding example. They have been added here to complete the demo example of helloworld binding. Use the official documentation to build and launch the test : http://docs.automotivelinux.org/master/docs/apis_services/en/dev/reference/afb-test/the-test-widget.html Signed-off-by: Pierre MARZIN test: Correct helloworld tests Correct API name. Correct some tests exemple. Delete event tests (event are not in helloworld-skeleton anymore). Signed-off-by: Pierre MARZIN binding: change api name Use a different api name to differenciate both helloworld example. Signed-off-by: Pierre MARZIN Remove redundant autobuild script. Signed-off-by: Li Xiaoming Change-Id: I7d694edc236ce918db54d1e830a26eb32b83de5a Signed-off-by: Frederic Marec --- htdocs/AFB-websock.js | 177 +++++++++++++++++++++++++++++ htdocs/CMakeLists.txt | 33 ++++++ htdocs/assets/background_iot_bzh_light.jpg | Bin 0 -> 40718 bytes htdocs/assets/favicon.ico | Bin 0 -> 1150 bytes htdocs/assets/iot-bzh-logo-small.png | Bin 0 -> 14449 bytes htdocs/index.html | 49 ++++++++ htdocs/iotbzh-Binding.css | 59 ++++++++++ htdocs/iotbzh-Binding.js | 104 +++++++++++++++++ 8 files changed, 422 insertions(+) create mode 100644 htdocs/AFB-websock.js create mode 100644 htdocs/CMakeLists.txt create mode 100644 htdocs/assets/background_iot_bzh_light.jpg create mode 100644 htdocs/assets/favicon.ico create mode 100644 htdocs/assets/iot-bzh-logo-small.png create mode 100644 htdocs/index.html create mode 100644 htdocs/iotbzh-Binding.css create mode 100644 htdocs/iotbzh-Binding.js (limited to 'htdocs') diff --git a/htdocs/AFB-websock.js b/htdocs/AFB-websock.js new file mode 100644 index 0000000..99ab3b8 --- /dev/null +++ b/htdocs/AFB-websock.js @@ -0,0 +1,177 @@ +var urlws; +var urlhttp; + +AFB = function(base, initialtoken){ + +urlws = "ws://"+window.location.host+"/"+base; +urlhttp = "http://"+window.location.host+"/"+base; + +/*********************************************/ +/**** ****/ +/**** AFB_context ****/ +/**** ****/ +/*********************************************/ +var AFB_context; +{ + var UUID = undefined; + var TOKEN = initialtoken; + + var context = function(token, uuid) { + this.token = token; + this.uuid = uuid; + } + + context.prototype = { + get token() {return TOKEN;}, + set token(tok) {if(tok) TOKEN=tok;}, + get uuid() {return UUID;}, + set uuid(id) {if(id) UUID=id;} + }; + + AFB_context = new context(); +} +/*********************************************/ +/**** ****/ +/**** AFB_websocket ****/ +/**** ****/ +/*********************************************/ +var AFB_websocket; +{ + var CALL = 2; + var RETOK = 3; + var RETERR = 4; + var EVENT = 5; + + var PROTO1 = "x-afb-ws-json1"; + + AFB_websocket = function(onopen, onabort) { + var u = urlws; + if (AFB_context.token) { + u = u + '?x-afb-token=' + AFB_context.token; + if (AFB_context.uuid) + u = u + '&x-afb-uuid=' + AFB_context.uuid; + } + this.ws = new WebSocket(u, [ PROTO1 ]); + this.pendings = {}; + this.awaitens = {}; + this.counter = 0; + this.ws.onopen = onopen.bind(this); + this.ws.onerror = onerror.bind(this); + this.ws.onclose = onclose.bind(this); + this.ws.onmessage = onmessage.bind(this); + this.onopen = onopen; + this.onabort = onabort; + this.onclose = onabort; + } + + function onerror(event) { + var f = this.onabort; + if (f) { + delete this.onopen; + delete this.onabort; + f && f(this); + } + this.onerror && this.onerror(this); + } + + function onopen(event) { + var f = this.onopen; + delete this.onopen; + delete this.onabort; + f && f(this); + } + + function onclose(event) { + for (var id in this.pendings) { + var ferr = this.pendings[id].onerror; + ferr && ferr(null, this); + } + this.pendings = {}; + this.onclose && this.onclose(); + } + + function fire(awaitens, name, data) { + var a = awaitens[name]; + if (a) + a.forEach(function(handler){handler(data);}); + var i = name.indexOf("/"); + if (i >= 0) { + a = awaitens[name.substring(0,i)]; + if (a) + a.forEach(function(handler){handler(data);}); + } + a = awaitens["*"]; + if (a) + a.forEach(function(handler){handler(data);}); + } + + function reply(pendings, id, ans, offset) { + if (id in pendings) { + var p = pendings[id]; + delete pendings[id]; + var f = p[offset]; + f(ans); + } + } + + function onmessage(event) { + var obj = JSON.parse(event.data); + var code = obj[0]; + var id = obj[1]; + var ans = obj[2]; + AFB_context.token = obj[3]; + switch (code) { + case RETOK: + reply(this.pendings, id, ans, 0); + break; + case RETERR: + reply(this.pendings, id, ans, 1); + break; + case EVENT: + default: + fire(this.awaitens, id, ans); + break; + } + } + + function close() { + this.ws.close(); + this.onabort(); + } + + function call(method, request) { + return new Promise((function(resolve, reject){ + var id, arr; + do { + id = String(this.counter = 4095 & (this.counter + 1)); + } while (id in this.pendings); + this.pendings[id] = [ resolve, reject ]; + arr = [CALL, id, method, request ]; + if (AFB_context.token) arr.push(AFB_context.token); + this.ws.send(JSON.stringify(arr)); + }).bind(this)); + } + + function onevent(name, handler) { + var id = name; + var list = this.awaitens[id] || (this.awaitens[id] = []); + list.push(handler); + } + + AFB_websocket.prototype = { + close: close, + call: call, + onevent: onevent + }; +} +/*********************************************/ +/**** ****/ +/**** ****/ +/**** ****/ +/*********************************************/ +return { + context: AFB_context, + ws: AFB_websocket +}; +}; + diff --git a/htdocs/CMakeLists.txt b/htdocs/CMakeLists.txt new file mode 100644 index 0000000..7aa0ce1 --- /dev/null +++ b/htdocs/CMakeLists.txt @@ -0,0 +1,33 @@ +########################################################################### +# Copyright 2015, 2016, 2017 IoT.bzh +# +# author: Fulup Ar Foll +# +# 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. +########################################################################### + + + +################################################## +# HTML Testing Files +################################################## +PROJECT_TARGET_ADD(htdocs) + + file(GLOB SOURCE_FILES "*.html" "*.js" "*.jpg" "*.css" "assets") + + add_input_files("${SOURCE_FILES}") + + SET_TARGET_PROPERTIES(${TARGET_NAME} PROPERTIES + LABELS "HTDOCS" + OUTPUT_NAME ${TARGET_NAME} + ) diff --git a/htdocs/assets/background_iot_bzh_light.jpg b/htdocs/assets/background_iot_bzh_light.jpg new file mode 100644 index 0000000..f47d2ee Binary files /dev/null and b/htdocs/assets/background_iot_bzh_light.jpg differ diff --git a/htdocs/assets/favicon.ico b/htdocs/assets/favicon.ico new file mode 100644 index 0000000..eeb7ab7 Binary files /dev/null and b/htdocs/assets/favicon.ico differ diff --git a/htdocs/assets/iot-bzh-logo-small.png b/htdocs/assets/iot-bzh-logo-small.png new file mode 100644 index 0000000..2c3b2ae Binary files /dev/null and b/htdocs/assets/iot-bzh-logo-small.png differ diff --git a/htdocs/index.html b/htdocs/index.html new file mode 100644 index 0000000..ffefe20 --- /dev/null +++ b/htdocs/index.html @@ -0,0 +1,49 @@ + + + + Simple Helloworld binding Test + + + + + + + + + + +

Simple Helloworld binding Test

+ + + + +

+ +
+ + + + + + + + + +
+ +
+ + + diff --git a/htdocs/iotbzh-Binding.css b/htdocs/iotbzh-Binding.css new file mode 100644 index 0000000..96a04cc --- /dev/null +++ b/htdocs/iotbzh-Binding.css @@ -0,0 +1,59 @@ +body.page-content { + height: 100%; + width: auto; + margin-top: 20px; + background: url("assets/background_iot_bzh_light.jpg") 0 0 no-repeat; + background-size: cover; + background-position: center; +} + +img { + float: right; +} + +#question, +#output, +#outevt { + white-space: pre-wrap; +} + +button { + margin-right: 10px; + padding: 6px 8px; + font-size: large; +} + +pre { + outline: 1px solid #ccc; + padding: 5px; + margin: 5px; + background-color: white; + opacity: 0.85; + min-height: 5pc; + max-height: 10pc; + overflow: auto; +} + +pre#output { + max-height: 30pc; +} + +.string { + color: green; +} + +.number { + color: darkorange; +} + +.boolean { + color: blue; +} + +.null { + color: magenta; +} + +.key { + color: red; +} diff --git a/htdocs/iotbzh-Binding.js b/htdocs/iotbzh-Binding.js new file mode 100644 index 0000000..d2d870c --- /dev/null +++ b/htdocs/iotbzh-Binding.js @@ -0,0 +1,104 @@ +var afb = new AFB("api", "mysecret"); +var ws; +var evtidx = 0; +var count = 0; + + +//********************************************** +// Logger +//********************************************** +var log = { + command: function (api, verb, query) { + console.log("subscribe api=" + api + " verb=" + verb + " query=", query); + var question = urlws + "/" + api + "/" + verb + "?query=" + JSON.stringify(query); + log._write("question", count + ": " + log.syntaxHighlight(question)); + }, + + event: function (obj) { + console.log("gotevent:" + JSON.stringify(obj)); + log._write("outevt", (evtidx++) + ": " + JSON.stringify(obj)); + }, + + reply: function (obj) { + console.log("replyok:" + JSON.stringify(obj)); + log._write("output", count + ": OK: " + log.syntaxHighlight(obj)); + }, + + error: function (obj) { + console.log("replyerr:" + JSON.stringify(obj)); + log._write("output", count + ": ERROR: " + log.syntaxHighlight(obj)); + }, + + _write: function (element, msg) { + var el = document.getElementById(element); + el.innerHTML += msg + '\n'; + + // auto scroll down + setTimeout(function () { + el.scrollTop = el.scrollHeight; + }, 100); + }, + + syntaxHighlight: function (json) { + if (typeof json !== 'string') { + json = JSON.stringify(json, undefined, 2); + } + json = json.replace(/&/g, '&').replace(//g, '>'); + 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 '' + match + ''; + }); + }, +}; + +//********************************************** +// Generic function to call binder +//*********************************************** +function callbinder(api, verb, query) { + log.command(api, verb, query); + + // ws.call return a Promise + return ws.call(api + "/" + verb, query) + .then(function (res) { + log.reply(res); + count++; + return res; + }) + .catch(function (err) { + log.reply(err); + count++; + throw err; + }); +} + +//********************************************** +// Init - establish Websocket connection +//********************************************** +function init(elemid, api, verb, query) { + + function onopen() { + document.getElementById("main").style.visibility = "visible"; + document.getElementById("connected").innerHTML = "Binder WS Active"; + document.getElementById("connected").style.background = "lightgreen"; + ws.onevent("*", log.event); + } + + 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); +} -- cgit 1.2.3-korg