summaryrefslogtreecommitdiffstats
path: root/conf.d
diff options
context:
space:
mode:
Diffstat (limited to 'conf.d')
-rw-r--r--conf.d/CMakeLists.txt22
m---------conf.d/app-templates0
-rwxr-xr-xconf.d/autobuild/agl/autobuild63
-rwxr-xr-xconf.d/autobuild/linux/autobuild63
-rw-r--r--conf.d/cmake/00-suse-config.cmake1
-rw-r--r--conf.d/cmake/config.cmake203
-rw-r--r--conf.d/project/CMakeLists.txt22
-rw-r--r--conf.d/project/etc/CMakeLists.txt31
-rw-r--r--conf.d/project/etc/sig-demoboard.json58
-rw-r--r--conf.d/project/etc/sig-doors.json85
-rw-r--r--conf.d/project/etc/sig-geoloc.json294
-rw-r--r--conf.d/project/etc/sig-sources.json44
-rw-r--r--conf.d/project/lua.d/00-viwi-low-can.lua27
-rw-r--r--conf.d/project/lua.d/CMakeLists.txt32
-rw-r--r--conf.d/project/lua.d/doscript-helloworld.lua36
-rw-r--r--conf.d/project/lua.d/onload-daemon-00-utils.lua86
-rw-r--r--conf.d/project/lua.d/onload-daemon-01-init.lua48
-rw-r--r--conf.d/project/lua.d/onload-daemon-03-controls.lua48
-rw-r--r--conf.d/project/lua.d/onload-daemon-04-oncall.lua70
-rw-r--r--conf.d/project/lua.d/onload-daemon-10-event.lua74
20 files changed, 1307 insertions, 0 deletions
diff --git a/conf.d/CMakeLists.txt b/conf.d/CMakeLists.txt
new file mode 100644
index 0000000..28a0609
--- /dev/null
+++ b/conf.d/CMakeLists.txt
@@ -0,0 +1,22 @@
+###########################################################################
+# Copyright 2015, 2016, 2017 IoT.bzh
+#
+# author: 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.
+###########################################################################
+
+
+# Include any directory not starting with _
+# -----------------------------------------------------
+PROJECT_SUBDIRS_ADD(${PROJECT_SRC_DIR_PATTERN})
diff --git a/conf.d/app-templates b/conf.d/app-templates
new file mode 160000
+Subproject e9a682f1c694eec242c3cebccc09380f621ade0
diff --git a/conf.d/autobuild/agl/autobuild b/conf.d/autobuild/agl/autobuild
new file mode 100755
index 0000000..4811441
--- /dev/null
+++ b/conf.d/autobuild/agl/autobuild
@@ -0,0 +1,63 @@
+#!/usr/bin/make -f
+# Copyright (C) 2015, 2016 "IoT.bzh"
+# Author "Romain Forlot" <romain.forlot@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.
+
+THISFILE := $(lastword $(MAKEFILE_LIST))
+BUILD_DIR := $(abspath $(dir $(THISFILE)/../../../../..)/build)
+DEST := ${BUILD_DIR}/target
+
+.PHONY: all clean distclean configure build package help update
+
+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"
+
+update: configure
+ @cmake --build ${BUILD_DIR} --target autobuild
+
+clean:
+ @([ -d ${BUILD_DIR} ] && make -C ${BUILD_DIR} clean) || echo Nothing to clean
+
+distclean:
+ @rm -rf ${BUILD_DIR}
+
+configure: ${BUILD_DIR}/Makefile
+
+build: configure
+ @cmake --build ${BUILD_DIR} ${BUILD_ARGS} --target all
+
+package: build
+ @mkdir -p ${BUILD_DIR}/$@/bin
+ @mkdir -p ${BUILD_DIR}/$@/etc
+ @mkdir -p ${BUILD_DIR}/$@/lib
+ @mkdir -p ${BUILD_DIR}/$@/htdocs
+ @mkdir -p ${BUILD_DIR}/$@/data
+ @cmake --build ${BUILD_DIR} --target widget
+ @mkdir -p ${DEST} && cp ${BUILD_DIR}/*wgt ${DEST}
+
+${BUILD_DIR}/Makefile:
+ @[ -d ${BUILD_DIR} ] || mkdir -p ${BUILD_DIR}
+ @[ -f ${BUILD_DIR}/Makefile ] || (cd ${BUILD_DIR} && cmake ${CONFIGURE_ARGS} ..)
diff --git a/conf.d/autobuild/linux/autobuild b/conf.d/autobuild/linux/autobuild
new file mode 100755
index 0000000..4811441
--- /dev/null
+++ b/conf.d/autobuild/linux/autobuild
@@ -0,0 +1,63 @@
+#!/usr/bin/make -f
+# Copyright (C) 2015, 2016 "IoT.bzh"
+# Author "Romain Forlot" <romain.forlot@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.
+
+THISFILE := $(lastword $(MAKEFILE_LIST))
+BUILD_DIR := $(abspath $(dir $(THISFILE)/../../../../..)/build)
+DEST := ${BUILD_DIR}/target
+
+.PHONY: all clean distclean configure build package help update
+
+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"
+
+update: configure
+ @cmake --build ${BUILD_DIR} --target autobuild
+
+clean:
+ @([ -d ${BUILD_DIR} ] && make -C ${BUILD_DIR} clean) || echo Nothing to clean
+
+distclean:
+ @rm -rf ${BUILD_DIR}
+
+configure: ${BUILD_DIR}/Makefile
+
+build: configure
+ @cmake --build ${BUILD_DIR} ${BUILD_ARGS} --target all
+
+package: build
+ @mkdir -p ${BUILD_DIR}/$@/bin
+ @mkdir -p ${BUILD_DIR}/$@/etc
+ @mkdir -p ${BUILD_DIR}/$@/lib
+ @mkdir -p ${BUILD_DIR}/$@/htdocs
+ @mkdir -p ${BUILD_DIR}/$@/data
+ @cmake --build ${BUILD_DIR} --target widget
+ @mkdir -p ${DEST} && cp ${BUILD_DIR}/*wgt ${DEST}
+
+${BUILD_DIR}/Makefile:
+ @[ -d ${BUILD_DIR} ] || mkdir -p ${BUILD_DIR}
+ @[ -f ${BUILD_DIR}/Makefile ] || (cd ${BUILD_DIR} && cmake ${CONFIGURE_ARGS} ..)
diff --git a/conf.d/cmake/00-suse-config.cmake b/conf.d/cmake/00-suse-config.cmake
new file mode 100644
index 0000000..0c40b68
--- /dev/null
+++ b/conf.d/cmake/00-suse-config.cmake
@@ -0,0 +1 @@
+add_definitions(-DSUSE_LUA_INCDIR) \ No newline at end of file
diff --git a/conf.d/cmake/config.cmake b/conf.d/cmake/config.cmake
new file mode 100644
index 0000000..d57f225
--- /dev/null
+++ b/conf.d/cmake/config.cmake
@@ -0,0 +1,203 @@
+###########################################################################
+# Copyright 2015, 2016, 2017 IoT.bzh
+#
+# author: 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.
+###########################################################################
+
+# Project Info
+# ------------------
+set(PROJECT_NAME signal-composer)
+set(PROJECT_VERSION "4.0")
+set(PROJECT_PRETTY_NAME "Signal composer")
+set(PROJECT_DESCRIPTION "Signal composer API connected to low level AGL services")
+set(PROJECT_URL "https://github.com/iotbzh/afb-signal-composer")
+set(PROJECT_ICON "icon.png")
+set(PROJECT_AUTHOR "Forlot Romain")
+set(PROJECT_AUTHOR_MAIL "romain.forlot@iot.bzh")
+set(PROJECT_LICENSE "APL2.0")
+set(PROJECT_LANGUAGES,"C")
+
+# Where are stored default templates files from submodule or subtree app-templates in your project tree
+# relative to the root project directory
+set(PROJECT_APP_TEMPLATES_DIR "conf.d/app-templates")
+
+# Where are stored your external libraries for your project. This is 3rd party library that you don't maintain
+# but used and must be built and linked.
+# set(PROJECT_LIBDIR "libs")
+
+# Where are stored data for your application. Pictures, static resources must be placed in that folder.
+# set(PROJECT_RESOURCES "data")
+
+# Which directories inspect to find CMakeLists.txt target files
+# set(PROJECT_SRC_DIR_PATTERN "*")
+
+# Compilation Mode (DEBUG, RELEASE)
+# ----------------------------------
+set(CMAKE_BUILD_TYPE "DEBUG")
+
+# Kernel selection if needed. You can choose between a
+# mandatory version to impose a minimal version.
+# Or check Kernel minimal version and just print a Warning
+# about missing features and define a preprocessor variable
+# to be used as preprocessor condition in code to disable
+# incompatibles features. Preprocessor define is named
+# KERNEL_MINIMAL_VERSION_OK.
+#
+# NOTE*** FOR NOW IT CHECKS KERNEL Yocto environment and
+# Yocto SDK Kernel version.
+# -----------------------------------------------
+#set (kernel_mandatory_version 4.8)
+#set (kernel_minimal_version 4.8)
+
+# Compiler selection if needed. Impose a minimal version.
+# -----------------------------------------------
+set (gcc_minimal_version 4.9)
+
+# PKG_CONFIG required packages
+# -----------------------------
+set (PKG_REQUIRED_LIST
+ json-c
+ libsystemd>=222
+ afb-daemon
+ libmicrohttpd>=0.9.55
+)
+
+# Prefix path where will be installed the files
+# Default: /usr/local (need root permission to write in)
+# ------------------------------------------------------
+#set(CMAKE_INSTALL_PREFIX $ENV{HOME}/opt)
+
+# Customize link option
+# -----------------------------
+#list(APPEND link_libraries -an-option)
+
+# Compilation options definition
+# Use CMake generator expressions to specify only for a specific language
+# Values are prefilled with default options that is currently used.
+# Either separate options with ";", or each options must be quoted separately
+# DO NOT PUT ALL OPTION QUOTED AT ONCE , COMPILATION COULD FAILED !
+# ----------------------------------------------------------------------------
+#set(COMPILE_OPTIONS
+# -Wall
+# -Wextra
+# -Wconversion
+# -Wno-unused-parameter
+# -Wno-sign-compare
+# -Wno-sign-conversion
+# -Werror=maybe-uninitialized
+# -Werror=implicit-function-declaration
+# -ffunction-sections
+# -fdata-sections
+# -fPIC
+# CACHE STRING "Compilation flags")
+#set(C_COMPILE_OPTIONS "" CACHE STRING "Compilation flags for C language.")
+#set(CXX_COMPILE_OPTIONS "" CACHE STRING "Compilation flags for C++ language.")
+#set(PROFILING_COMPILE_OPTIONS
+# -g
+# -O0
+# -pg
+# -Wp,-U_FORTIFY_SOURCE
+# CACHE STRING "Compilation flags for PROFILING build type.")
+#set(DEBUG_COMPILE_OPTIONS
+# -g
+# -ggdb
+# -Wp,-U_FORTIFY_SOURCE
+# CACHE STRING "Compilation flags for DEBUG build type.")
+#set(CCOV_COMPILE_OPTIONS
+# -g
+# -O2
+# --coverage
+# CACHE STRING "Compilation flags for CCOV build type.")
+#set(RELEASE_COMPILE_OPTIONS
+# -g
+# -O2
+# CACHE STRING "Compilation flags for RELEASE build type.")
+
+# (BUG!!!) as PKG_CONFIG_PATH does not work [should be an env variable]
+# ---------------------------------------------------------------------
+set(CMAKE_PREFIX_PATH ${CMAKE_INSTALL_PREFIX}/lib64/pkgconfig ${CMAKE_INSTALL_PREFIX}/lib/pkgconfig)
+set(LD_LIBRARY_PATH ${CMAKE_INSTALL_PREFIX}/lib64 ${CMAKE_INSTALL_PREFIX}/lib)
+
+# Optional location for config.xml.in
+# -----------------------------------
+#set(WIDGET_ICON conf.d/wgt/${PROJECT_ICON} CACHE PATH "Path to the widget icon")
+#set(WIDGET_CONFIG_TEMPLATE ${CMAKE_CURRENT_SOURCE_DIR}/conf.d/wgt/config.xml.in CACHE PATH "Path to widget config file template (config.xml.in)")
+
+# Mandatory widget Mimetype specification of the main unit
+# --------------------------------------------------------------------------
+# Choose between :
+#- text/html : HTML application,
+# content.src designates the home page of the application
+#
+#- application/vnd.agl.native : AGL compatible native,
+# content.src designates the relative path of the binary.
+#
+# - application/vnd.agl.service: AGL service, content.src is not used.
+#
+#- ***application/x-executable***: Native application,
+# content.src designates the relative path of the binary.
+# For such application, only security setup is made.
+#
+set(WIDGET_TYPE application/vnd.agl.service)
+
+# Mandatory Widget entry point file of the main unit
+# --------------------------------------------------------------
+# This is the file that will be executed, loaded,
+# at launch time by the application framework.
+#
+set(WIDGET_ENTRY_POINT lib/afb-signals-composer.so)
+
+# Optional dependencies order
+# ---------------------------
+#set(EXTRA_DEPENDENCIES_ORDER)
+
+# Optional Extra global include path
+# -----------------------------------
+#set(EXTRA_INCLUDE_DIRS)
+
+# Optional extra libraries
+# -------------------------
+#set(EXTRA_LINK_LIBRARIES)
+
+# Optional force binding Linking flag
+# ------------------------------------
+# set(BINDINGS_LINK_FLAG LinkOptions )
+
+# Optional force package prefix generation, like widget
+# -----------------------------------------------------
+# set(PKG_PREFIX DestinationPath)
+
+# Optional Application Framework security token
+# and port use for remote debugging.
+#------------------------------------------------------------
+set(AFB_TOKEN "" CACHE PATH "Default binder security token")
+set(AFB_REMPORT "1234" CACHE PATH "Default binder listening port")
+
+# Print a helper message when every thing is finished
+# ----------------------------------------------------
+set(CLOSING_MESSAGE "Typical binding launch: afb-daemon --port=${AFB_REMPORT} --workdir=${CMAKE_BINARY_DIR}/package --ldpaths=lib --roothttp=htdocs --token=\"${AFB_TOKEN}\" --tracereq=common --verbose")
+set(PACKAGE_MESSAGE "Install widget file using in the target : afm-util install ${PROJECT_NAME}.wgt")
+
+# Optional schema validator about now only XML, LUA and JSON
+# are supported
+#------------------------------------------------------------
+#set(LUA_CHECKER "luac" "-p" CACHE STRING "LUA compiler")
+#set(XML_CHECKER "xmllint" CACHE STRING "XML linter")
+#set(JSON_CHECKER "json_verify" CACHE STRING "JSON linter")
+
+# This include is mandatory and MUST happens at the end
+# of this file, else you expose you to unexpected behavior
+# -----------------------------------------------------------
+include(${PROJECT_APP_TEMPLATES_DIR}/cmake/common.cmake)
diff --git a/conf.d/project/CMakeLists.txt b/conf.d/project/CMakeLists.txt
new file mode 100644
index 0000000..28a0609
--- /dev/null
+++ b/conf.d/project/CMakeLists.txt
@@ -0,0 +1,22 @@
+###########################################################################
+# Copyright 2015, 2016, 2017 IoT.bzh
+#
+# author: 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.
+###########################################################################
+
+
+# Include any directory not starting with _
+# -----------------------------------------------------
+PROJECT_SUBDIRS_ADD(${PROJECT_SRC_DIR_PATTERN})
diff --git a/conf.d/project/etc/CMakeLists.txt b/conf.d/project/etc/CMakeLists.txt
new file mode 100644
index 0000000..1ff98b1
--- /dev/null
+++ b/conf.d/project/etc/CMakeLists.txt
@@ -0,0 +1,31 @@
+###########################################################################
+# Copyright 2017 IoT.bzh
+#
+# author: 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.
+###########################################################################
+
+##################################################
+# Control Policy Config file
+##################################################
+PROJECT_TARGET_ADD(signal-composer-config)
+
+ file(GLOB CONF_FILES "*.json")
+
+ add_input_files("${CONF_FILES}")
+
+ SET_TARGET_PROPERTIES(${TARGET_NAME} PROPERTIES
+ LABELS "BINDING-CONFIG"
+ OUTPUT_NAME ${TARGET_NAME}
+ )
diff --git a/conf.d/project/etc/sig-demoboard.json b/conf.d/project/etc/sig-demoboard.json
new file mode 100644
index 0000000..4b81989
--- /dev/null
+++ b/conf.d/project/etc/sig-demoboard.json
@@ -0,0 +1,58 @@
+{
+ "resources": [{
+ "name": "/car/demoboard/",
+ "values": [{
+ "name": "vehicleSpeed",
+ "additionnals_infos": {
+ "unit": "km/h",
+ "interval": 1000
+ },
+ "source": "CAN bus",
+ "class": "raw",
+ "type": "double",
+ "source_args": {
+ "event": "diagnostic_messages.vehicle.speed",
+ "filter": {
+ "frequency": "100",
+ "min": 10
+ }
+ }
+ }, {
+ "name": "engineSpeed",
+ "additionnals_infos": {
+ "unit": "rpm",
+ "interval": 1000
+ },
+ "source":"CAN bus",
+ "class": "raw",
+ "type": "double",
+ "source_args": {
+ "event": "diagnostic_messages.engine.speed"
+ }
+ }, {
+ "name": "fuelLevel",
+ "additionnals_infos": {
+ "unit": "litre",
+ "interval": 1000
+ },
+ "class":"raw",
+ "source":"CAN bus",
+ "type": "double",
+ "source_args": {
+ "event": "diagnostic_messages.fuel.level"
+ }
+ }, {
+ "name": "engineLoad",
+ "additionnals_infos": {
+ "unit": "Nm",
+ "interval": 1000
+ },
+ "source":"CAN bus",
+ "type":"double",
+ "class":"raw",
+ "source_args": {
+ "event": "diagnostic_messages.engine.load"
+ }
+ }]
+ }]
+}
diff --git a/conf.d/project/etc/sig-doors.json b/conf.d/project/etc/sig-doors.json
new file mode 100644
index 0000000..46d37cc
--- /dev/null
+++ b/conf.d/project/etc/sig-doors.json
@@ -0,0 +1,85 @@
+{
+ "signals": [
+ {
+ "label": "low-can/messages.windows.front_left.open",
+ "actions": {
+ "label": "Door open event action",
+ "lua": "_Door_opened",
+ "args": {
+ "evtname": "messages.windows.front_left.open"
+ }
+ }
+ },
+ {
+ "label": "low-can/messages.windows.front_right.open",
+ "actions": {
+ "label": "Door open event action",
+ "lua": "_Door_opened",
+ "args": {
+ "evtname": "messages.windows.front_right.open"
+ }
+ }
+ },
+ {
+ "label": "low-can/messages.windows.rear_left.open",
+ "actions": {
+ "label": "Door open event action",
+ "lua": "_Door_opened",
+ "args": {
+ "evtname": "messages.windows.rear_left.open"
+ }
+ }
+ },
+ {
+ "label": "low-can/messages.windows.rear_right.open",
+ "actions": {
+ "label": "Door open event action",
+ "lua": "_Door_opened",
+ "args": {
+ "evtname": "messages.windows.rear_right.open"
+ }
+ }
+ }],
+ "virtual_signals": [
+ {
+ "label": "sig-orc/doors.open",
+ "depends_on": [
+ "front_left_doors",
+ "front_left_windows",
+ "front_right_doors",
+ "front_right_windows",
+ "rear_left_doors",
+ "rear_left_windows",
+ "rear_right_doors",
+ "rear_right_windows"
+ ],
+ "actions": {
+ "label": "A door is open",
+ "lua": "_Door_opened",
+ "args": {
+ "evtname": "doors.open"
+ }
+ }
+ },
+ {
+ "label": "sig-orc/doors.average",
+ "depends_on": [
+ "front_left_doors",
+ "front_left_windows",
+ "front_right_doors",
+ "front_right_windows",
+ "rear_left_doors",
+ "rear_left_windows",
+ "rear_right_doors",
+ "rear_right_windows"
+ ],
+ "actions": {
+ "label": "A door is open",
+ "lua": "_Door_average",
+ "args": {
+ "evtname": "door.average",
+ "time": 120
+ }
+ }
+ }]
+} \ No newline at end of file
diff --git a/conf.d/project/etc/sig-geoloc.json b/conf.d/project/etc/sig-geoloc.json
new file mode 100644
index 0000000..6db766d
--- /dev/null
+++ b/conf.d/project/etc/sig-geoloc.json
@@ -0,0 +1,294 @@
+{
+ "resources": [{
+ "group": "/car/geoloc/",
+ "values": [{
+ "name": "latitude",
+ "additionnals_infos": {
+ "unit": "degree",
+ "interval": 1000
+ },
+ "source": "GNSS/GPS",
+ "class": "raw",
+ "type": "double",
+ "source_args": {
+ "value": "location"
+ }
+ },
+ {
+ "name": "longitude",
+ "additionnals_infos": {
+ "unit": "degree",
+ "interval": 1000
+ },
+ "source": "GNSS/GPS",
+ "class": "raw",
+ "type": "double",
+ "source_args": {
+ "value": "location"
+ }
+ },
+ {
+ "name": "altitude",
+ "additionnals_infos": {
+ "unit": "meter",
+ "interval": 1000
+ },
+ "source": "GNSS/GPS",
+ "class": "raw",
+ "type": "double",
+ "source_args": {
+ "value": "location"
+ }
+ },
+ {
+ "name": "heading",
+ "additionnals_infos": {
+ "unit": "degree",
+ "interval": 1000
+ },
+ "source": "GNSS/GPS",
+ "class": "raw",
+ "type": "double",
+ "source_args": {
+ "value": "location"
+ }
+ },
+ {
+ "name": "speed",
+ "additionnals_infos": {
+ "unit": "m/s",
+ "interval": 1000
+ },
+ "source": "GNSS/GPS",
+ "class": "raw",
+ "type": "double",
+ "source_args": {
+ "value": "location"
+ }
+ },
+ {
+ "name": "climb",
+ "additionnals_infos": {
+ "unit": "degree",
+ "interval": 1000
+ },
+ "source": "Sensors",
+ "class": "raw",
+ "type": "double",
+ "source_args": {
+ "sensor": "gyro"
+ }
+ },
+ {
+ "name": "roll_rate",
+ "additionnals_infos": {
+ "unit": "degree/s",
+ "interval": 1000
+ },
+ "source": "Sensors",
+ "class": "raw",
+ "type": "double",
+ "source_args": {
+ "sensor": "roll_rate"
+ }
+ },
+ {
+ "name": "roll_rate",
+ "additionnals_infos": {
+ "unit": "degree/s",
+ "interval": 1000
+ },
+ "source": "Sensors",
+ "class": "raw",
+ "type": "double",
+ "source_args": {
+ "sensor": "pitch_rate"
+ }
+ },
+ {
+ "name": "roll_rate",
+ "additionnals_infos": {
+ "unit": "degree/s",
+ "interval": 1000
+ },
+ "source": "Sensors",
+ "class": "raw",
+ "type": "double",
+ "source_args": {
+ "sensor": "yaw_rate"
+ }
+ },
+ {
+ "name": "pdop",
+ "additionnals_infos": {
+ "interval": 1000
+ }, "source": "GNSS/GPS",
+ "class": "raw",
+ "type": "double",
+ "source_args": {
+ "value": "location"
+ }
+ },
+ {
+ "name": "hdop",
+ "additionnals_infos": {
+ "interval": 1000
+ },
+ "source": "GNSS/GPS",
+ "class": "raw",
+ "type": "double",
+ "source_args": {
+ "value": "location"
+ }
+ },
+ {
+ "name": "vdop",
+ "additionnals_infos": {
+ "interval": 1000
+ },
+ "source": "GNSS/GPS",
+ "class": "raw",
+ "type": "double",
+ "source_args": {
+ "value": "location"
+ }
+ },
+ {
+ "name": "used_satellites",
+ "additionnals_infos": {
+ "interval": 1000
+ },
+ "source": "GNSS/GPS",
+ "class": "raw",
+ "type": "uint8",
+ "source_args": {
+ "value": "configuration"
+ }
+ },
+ {
+ "name": "tracked_satellites",
+ "additionnals_infos": {
+ "interval": 1000
+ },
+ "source": "GNSS/GPS",
+ "class": "raw",
+ "type": "uint8",
+ "source_args": {
+ "value": "configuration"
+ }
+ },
+ {
+ "name": "visible_satellites",
+ "additionnals_infos": {
+ "interval": 1000
+ },
+ "source": "GNSS/GPS",
+ "class": "raw",
+ "type": "uint8",
+ "source_args": {
+ "value": "configuration"
+ }
+ },
+ {
+ "name": "sigma_hposition",
+ "additionnals_infos": {
+ "unit": "meter",
+ "interval": 1000
+ },
+ "source": "GNSS/GPS",
+ "class": "raw",
+ "type": "double",
+ "source_args": {
+ "value": "configuration"
+ }
+ },
+ {
+ "name": "sigma_altitude",
+ "additionnals_infos": {
+ "unit": "meter",
+ "interval": 1000
+ },
+ "source": "GNSS/GPS",
+ "class": "raw",
+ "type": "double",
+ "source_args": {
+ "value": "configuration"
+ }
+ },
+ {
+ "name": "sigma_heading",
+ "additionnals_infos": {
+ "unit": "degree",
+ "interval": 1000
+ },
+ "source": "GNSS/GPS",
+ "class": "raw",
+ "type": "double",
+ "source_args": {
+ "value": "configuration"
+ }
+ },
+ {
+ "name": "sigma_speed",
+ "additionnals_infos": {
+ "unit": "m/s",
+ "interval": 1000
+ },
+ "source": "GNSS/GPS",
+ "class": "raw",
+ "type": "double",
+ "source_args": {
+ "value": "configuration"
+ }
+ },
+ {
+ "name": "sigma_climb",
+ "additionnals_infos": {
+ "unit": "degree",
+ "interval": 1000
+ },
+ "source": "GNSS/GPS",
+ "class": "raw",
+ "type": "double",
+ "source_args": {
+ "value": "configuration"
+ }
+ },
+ {
+ "name": "gnss_fix_status",
+ "additionnals_infos": {
+ "interval": 1000
+ },
+ "source": "GNSS/GPS",
+ "class": "raw",
+ "type": "uint16",
+ "source_args": {
+ "value": "configuration"
+ }
+ },
+ {
+ "name": "dr_status",
+ "additionnals_infos": {
+ "interval": 1000
+ },
+ "source": "GNSS/GPS",
+ "class": "raw",
+ "type": "boolean",
+ "source_args": {
+ "value": "configuration"
+ }
+ },
+ {
+ "name": "reliabilty_index",
+ "additionnals_infos": {
+ "interval": 1000
+ },
+ "source": "GNSS/GPS",
+ "class": "raw",
+ "type": "uint8_t",
+ "source_args": {
+ "value": "configuration"
+ }
+ }]
+ }]
+}
diff --git a/conf.d/project/etc/sig-sources.json b/conf.d/project/etc/sig-sources.json
new file mode 100644
index 0000000..076139f
--- /dev/null
+++ b/conf.d/project/etc/sig-sources.json
@@ -0,0 +1,44 @@
+{
+ "$schema": "ToBeDone",
+ "metadata": {
+ "label": "signal-composer",
+ "info": "Signal composer Configuration",
+ "name": "afb-signal-composer",
+ "version": "1.0"
+ },
+ "onload": [{
+ "label": "onload-signal-composer",
+ "info": "onload initialisation config",
+ "require": [
+ {
+ "label": "CAN bus",
+ "api": "low-can",
+ "info": "Low level binding to handle CAN bus communications",
+ "callback": "c function to subscribe on signals",
+ "lua": "or a lua function to subscribe on signals",
+ "args": {
+ "arg": "first argument"
+ }
+ },
+ {
+ "label": "GNSS/GPS",
+ "api": "gps",
+ "info": "Low level binding which retrieve Satellite positionning values",
+ "callback": "c function to subscribe on signals",
+ "lua": "or a lua function to subscribe on signals",
+ "args": {
+ "value" : "arg"
+ }
+ },
+ {
+ "label": "Sensors",
+ "api": "mraa",
+ "info": "Low level binding which retrieve different values from several sensors like gyroscope, accelerometer, etc",
+ "callback": "c function to subscribe on signals",
+ "lua": "or a lua function to subscribe on signals",
+ "args": {
+ "sensor" : "eg"
+ }
+ }]
+ }]
+}
diff --git a/conf.d/project/lua.d/00-viwi-low-can.lua b/conf.d/project/lua.d/00-viwi-low-can.lua
new file mode 100644
index 0000000..b13863a
--- /dev/null
+++ b/conf.d/project/lua.d/00-viwi-low-can.lua
@@ -0,0 +1,27 @@
+--[[
+ Copyright (C) 2017 "IoT.bzh"
+ Author Romain Forlot <romain.forlot@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.
+--]]
+
+function _SubscribeLowCan (request, args)
+
+ AFB:notice ("_We gonna subscribe to %s", args)
+ local err, result= AFB:servsync ("low-can","subscribe", args)
+ if (err) then
+ AFB:fail ("AFB:service_call_sync fail");
+ else
+ AFB:success (request, result["response"])
+ end
+end
diff --git a/conf.d/project/lua.d/CMakeLists.txt b/conf.d/project/lua.d/CMakeLists.txt
new file mode 100644
index 0000000..07d39af
--- /dev/null
+++ b/conf.d/project/lua.d/CMakeLists.txt
@@ -0,0 +1,32 @@
+###########################################################################
+# Copyright 2017 IoT.bzh
+#
+# author: 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.
+###########################################################################
+
+
+##################################################
+# Control Policy Config file
+##################################################
+PROJECT_TARGET_ADD(lua.d)
+
+ file(GLOB LUA_FILES "*.lua")
+
+ add_input_files("${LUA_FILES}")
+
+ SET_TARGET_PROPERTIES(${TARGET_NAME} PROPERTIES
+ LABELS "DATA"
+ OUTPUT_NAME ${TARGET_NAME}
+ )
diff --git a/conf.d/project/lua.d/doscript-helloworld.lua b/conf.d/project/lua.d/doscript-helloworld.lua
new file mode 100644
index 0000000..e722db7
--- /dev/null
+++ b/conf.d/project/lua.d/doscript-helloworld.lua
@@ -0,0 +1,36 @@
+--[[
+ Copyright (C) 2016 "IoT.bzh"
+ Author 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.
+
+
+ Simple API script to be use with AGL control LuaDoCall API
+ - After the script is loaded by lua_docall
+ - Controller start function=xxxx where xxxx is taken from script filename doscript-xxxx-anything
+
+--]]
+
+function _helloworld (request, query)
+
+ AFB:notice ("LUA HelloWorld: Simple test query=%s", query);
+
+ if (query == nil) then
+ AFB:notice ("LUA HelloWorld:FX query should not be empty");
+ AFB:fail (request, "LUA HelloWorld: query should not be empty");
+ else
+ AFB:notice ("LUA HelloWorld:OK query=%s", query);
+ AFB:success (request, {arg0="Demat", arg1="Bonjours", arg2="Gootentag", arg3="Morning"});
+ end
+
+end
diff --git a/conf.d/project/lua.d/onload-daemon-00-utils.lua b/conf.d/project/lua.d/onload-daemon-00-utils.lua
new file mode 100644
index 0000000..29d2c70
--- /dev/null
+++ b/conf.d/project/lua.d/onload-daemon-00-utils.lua
@@ -0,0 +1,86 @@
+--[[
+ Copyright (C) 2016 "IoT.bzh"
+ Author 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.
+
+ Note: this file should be called before any other to assert declare function
+ is loaded before anything else.
+
+ References:
+ http://lua-users.org/wiki/DetectingUndefinedVariables
+
+--]]
+
+
+--===================================================
+--= Niklas Frykholm
+-- basically if user tries to create global variable
+-- the system will not let them!!
+-- call GLOBAL_lock(_G)
+--
+--===================================================
+function GLOBAL_lock(t)
+ local mt = getmetatable(t) or {}
+ mt.__newindex = lock_new_index
+ setmetatable(t, mt)
+end
+
+--===================================================
+-- call GLOBAL_unlock(_G)
+-- to change things back to normal.
+--===================================================
+function GLOBAL_unlock(t)
+ local mt = getmetatable(t) or {}
+ mt.__newindex = unlock_new_index
+ setmetatable(t, mt)
+end
+
+function lock_new_index(t, k, v)
+ if (string.sub(k,1,1) ~= "_") then
+ GLOBAL_unlock(_G)
+ error("GLOBALS are locked -- " .. k ..
+ " must be declared local or prefix with '_' for globals.", 2)
+ else
+ rawset(t, k, v)
+ end
+end
+
+function unlock_new_index(t, k, v)
+ rawset(t, k, v)
+end
+
+-- return serialised version of printable table
+function Dump_Table(o)
+ if type(o) == 'table' then
+ local s = '{ '
+ for k,v in pairs(o) do
+ if type(k) ~= 'number' then k = '"'..k..'"' end
+ s = s .. '['..k..'] = ' .. Dump_Table(v) .. ','
+ end
+ return s .. '} '
+ else
+ return tostring(o)
+ end
+end
+
+
+-- simulate C prinf function
+printf = function(s,...)
+ io.write(s:format(...))
+ io.write("\n")
+ return
+end
+
+-- lock global variable
+GLOBAL_lock(_G)
diff --git a/conf.d/project/lua.d/onload-daemon-01-init.lua b/conf.d/project/lua.d/onload-daemon-01-init.lua
new file mode 100644
index 0000000..26ff08a
--- /dev/null
+++ b/conf.d/project/lua.d/onload-daemon-01-init.lua
@@ -0,0 +1,48 @@
+--[[
+ Copyright (C) 2016 "IoT.bzh"
+ Author 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.
+--]]
+
+-- Global variable SHOULD start with _
+_Global_Context={}
+
+--[[
+ This function is call during controller init phase as describe in onload-daemon-sample.json
+ It receives two argument 1st one is the source (here on load) second one is the arguments
+ as expose in config file.
+
+ In this sample we create an event that take the name of args["zzzz"], the resulting handle
+ is save into _Global_Context for further use.
+
+ Note: init functions are not call from a client and thus do not receive query
+
+--]]
+function _Sample_Controller_Init(source, control)
+
+ printf ("[-- Sample_Controller_Init --] source=%d control=%s", source, Dump_Table(control))
+
+ -- if no argument return now
+ if (control==nil or control["zzzz"]==nil) then
+ printf ("[-- Sample_Controller_Init --] no event name given")
+ return
+ end
+
+ -- set a count to make more visible each call
+ _Global_Context["counter"]=0
+
+ -- just for fun create an event
+ _Global_Context["event"]=AFB:evtmake(control["zzzz"])
+
+end
diff --git a/conf.d/project/lua.d/onload-daemon-03-controls.lua b/conf.d/project/lua.d/onload-daemon-03-controls.lua
new file mode 100644
index 0000000..cc13e0f
--- /dev/null
+++ b/conf.d/project/lua.d/onload-daemon-03-controls.lua
@@ -0,0 +1,48 @@
+--[[
+ Copyright (C) 2016 "IoT.bzh"
+ Author 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.
+
+ Following function are called when a client activate a control with
+ controller api -> APi=control VERB=dispatch
+ arguments are
+ - source (0) when requesting the control (-1) when releasing
+ - control comme from config given with 'args' in onload-middlename-xxxxx.json
+ - client is the argument part of the query as providing by client requesting the control.
+
+--]]
+
+
+
+-- Simple Happy(granted) Control
+function _Button_Happy(source, control, client)
+
+ -- print argument to make sure we understant what we get
+ printf ("[-- _Button_Happy --] source=%d control=%s client=%s", source, Dump_Table(control), Dump_Table(client))
+
+ AFB:notice ("[-- _Button_Happy --] To Be Done")
+
+ return 0 -- control granted
+end
+
+
+-- Simple UnHappy(debu) Control
+function _Button_UnHappy(source, control, client)
+
+ -- print argument to make sure we understant what we get
+ printf ("[-- _Button_UnHappy --] source=%d control=%s client=%s", source, Dump_Table(client), Dump_Table(control))
+
+ AFB:error ("[-- _Button_UnHappy --] To Be Done")
+ return 1 -- control is refused
+end
diff --git a/conf.d/project/lua.d/onload-daemon-04-oncall.lua b/conf.d/project/lua.d/onload-daemon-04-oncall.lua
new file mode 100644
index 0000000..b450932
--- /dev/null
+++ b/conf.d/project/lua.d/onload-daemon-04-oncall.lua
@@ -0,0 +1,70 @@
+--[[
+ Copyright (C) 2016 "IoT.bzh"
+ Author 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.
+
+
+ Provide sample LUA routines to be used with AGL control "lua_docall" API
+--]]
+
+--global counter to keep track of calls
+_count=0
+
+-- Display receive arguments and echo them to caller
+function _Simple_Echo_Args (request, args)
+ _count=_count+1
+ AFB:notice("LUA OnCall Echo Args count=%d args=%s", count, args)
+
+ print ("--inlua-- args=", Dump_Table(args))
+
+ local response={
+ ["count"]=_count,
+ ["args"]=args,
+ }
+
+ -- fulup Embdeded table ToeDone AFB:success (request, response)
+ AFB:success (request, {["func"]="Simple_Echo_Args", ["ret1"]=5678, ["ret2"]="abcd"})
+end
+
+local function Test_Async_CB (request, result, context)
+ response={
+ ["result"]=result,
+ ["context"]=context,
+ }
+
+ AFB:notice ("Test_Async_CB result=%s context=%s", result, context)
+ AFB:success (request, response)
+end
+
+function _Test_Call_Async (request, args)
+ local context={
+ ["value1"]="abcd",
+ ["value2"]=1234
+ }
+
+ AFB:notice ("Test_Call_Async args=%s cb=Test_Async_CB", args)
+ AFB:service("monitor","ping", "Test_Async_CB", context)
+end
+
+function _Simple_Monitor_Call (request, args)
+
+ AFB:notice ("_Simple_Server_Call args=%s", args)
+ local err, result= AFB:servsync ("monitor","get", args)
+ if (err) then
+ AFB:fail ("AFB:service_call_sync fail");
+ else
+ AFB:success (request, result["response"])
+ end
+end
+
diff --git a/conf.d/project/lua.d/onload-daemon-10-event.lua b/conf.d/project/lua.d/onload-daemon-10-event.lua
new file mode 100644
index 0000000..474ebe0
--- /dev/null
+++ b/conf.d/project/lua.d/onload-daemon-10-event.lua
@@ -0,0 +1,74 @@
+--[[
+ Copyright (C) 2016 "IoT.bzh"
+ Author 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.
+
+
+ Provide Sample Timer Handing to push event from LUA
+--]]
+
+-- Create event on Lua script load
+_MyContext={}
+
+-- WARNING: call back are global and should start with '_'
+function _Timer_Test_CB (timer, context)
+
+ local evtinfo= AFB:timerget(timer)
+ printf ("[-- _Timer_Test_C --] evtInfo=%s", Dump_Table(evtinfo))
+
+ --send an event an event with count as value
+ AFB:evtpush (_MyContext["event"], {["label"]= evtinfo["label"], ["count"]=evtinfo["count"], ["info"]=context["info"]})
+
+ -- note when timerCB return!=0 timer is kill
+ return 0
+
+end
+
+-- sendback event depending on count and delay
+function _Simple_Timer_Test (request, client)
+
+ local context = {
+ ["info"]="My 1st private Event",
+ }
+
+ -- if event does not exit create it now.
+ if (_MyContext["event"] == nil) then
+ _MyContext["event"]= AFB:evtmake(client["label"])
+ end
+
+ -- if delay not defined default is 5s
+ if (client["delay"]==nil) then client["delay"]=5000 end
+
+ -- if count is not defined default is 10
+ if (client["count"]==nil) then client["count"]=10 end
+
+ -- we could use directly client but it is a sample
+ local myTimer = {
+ ["label"]=client["label"],
+ ["delay"]=client["delay"],
+ ["count"]=client["count"],
+ }
+ AFB:notice ("Test_Timer myTimer=%s", myTimer)
+
+ -- subscribe to event
+ AFB:subscribe (request, _MyContext["event"])
+
+ -- settimer take a table with delay+count as input (count==0 means infinite)
+ AFB:timerset (myTimer, "_Timer_Test_CB", context)
+
+ -- nothing special to return send back
+ AFB:success (request, myTimer)
+
+ return 0
+end