diff options
Diffstat (limited to 'conf.d')
20 files changed, 0 insertions, 1405 deletions
diff --git a/conf.d/autobuild/agl/autobuild b/conf.d/autobuild/agl/autobuild deleted file mode 100755 index 3a1ba5f..0000000 --- a/conf.d/autobuild/agl/autobuild +++ /dev/null @@ -1,67 +0,0 @@ -#!/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: compilation, link and prepare files for package into a widget" - @echo "- package: output a widget file '*.wgt'" - @echo "- install: install in your ${CMAKE_INSTALL_DIR} directory" - @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} - -install: build - @cmake --build ${BUILD_DIR} --target install - -${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 deleted file mode 100755 index 3a1ba5f..0000000 --- a/conf.d/autobuild/linux/autobuild +++ /dev/null @@ -1,67 +0,0 @@ -#!/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: compilation, link and prepare files for package into a widget" - @echo "- package: output a widget file '*.wgt'" - @echo "- install: install in your ${CMAKE_INSTALL_DIR} directory" - @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} - -install: build - @cmake --build ${BUILD_DIR} --target install - -${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/config.cmake b/conf.d/cmake/config.cmake deleted file mode 100644 index 4bb272f..0000000 --- a/conf.d/cmake/config.cmake +++ /dev/null @@ -1,232 +0,0 @@ -########################################################################### -# 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 afb-aaaa) -set(PROJECT_VERSION "0.1") -set(PROJECT_PRETTY_NAME "Audio Agent") -set(PROJECT_DESCRIPTION "Expose Alsa through AGL AppFw") -set(PROJECT_URL "https://github.com/iotbzh/audio-bindings") -set(PROJECT_ICON "icon.png") -set(PROJECT_AUTHOR "Fulup, Ar Foll") -set(PROJECT_AUTHOR_MAIL "fulup@iot.bzh") -set(PROJECT_LICENSE "Apache-V2") -set(PROJECT_LANGUAGES,"C") - -# Where are stored the project configuration files -# relative to the root project directory -set(PROJECT_CMAKE_CONF_DIR "conf.d") - -# 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 - libafbwsc - alsa>=1.1.2 -) - -# 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 -lpthread -lm) - -# 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 -# Personal compilation options -#-DMAX_SND_CARD=16 # should be more than enough even in luxury vehicule -#-DMAX_LINEAR_DB_SCALE=24 # until 24db volume normalisation use a simple linear scale -#-DTLV_BYTE_SIZE=256 # Alsa use 4096 as default but 256 should fit most sndcards -#-DCONTROL_MAXPATH_LEN=255 -# CACHE STRING "Compilation flags") - -add_compile_options(-DAFB_BINDING_VERSION=2) -add_compile_options(-DMAX_SND_CARD=16) # should be more than enough even in luxury vehicule -add_compile_options(-DMAX_LINEAR_DB_SCALE=24) # until 24db volume normalisation use a simple linear scale -add_compile_options(-DTLV_BYTE_SIZE=256) # Alsa use 4096 as default but 256 should fit most sndcards -add_compile_options(-DCONTROL_MAXPATH_LEN=255) - -#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) -set(HTTPDIR unicens CACHE PATH "Directory holding HTML5 files") - -# 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 MimeType_Not_Set) - -# 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 EntryPoint_Path_Not_Set) - -# 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 -# ---------------------------------------------------- -if(IS_DIRECTORY $ENV{HOME}/opt/afb-monitoring) -set(MONITORING_ALIAS "--alias=/monitoring:$ENV{HOME}/opt/afb-monitoring") -endif() - -if(EXISTS ${CMAKE_SOURCE_DIR}/../afb-controller/build/afb-source/afb-control-afb.so) -set(CTL_BUILD_PATH "--binding=../../afb-controller/build/afb-source/afb-control-afb.so") -endif() -set(CLOSING_MESSAGE "Debug from afb-daemon --port=1234 ${MONITORING_ALIAS} --ldpaths=. ${CTL_BUILD_PATH} --workdir=. --roothttp=../htdocs --tracereq=common --token= --verbose ") -set(PACKAGE_MESSAGE "Install widget file using in the target : afm-util install ${PROJECT_NAME}.wgt") - -# When Present LUA is used by the controller -# --------------------------------------------------------------- -set(CONTROL_SUPPORT_LUA 1 CACHE BOOL "Active or not LUA Support") - -# 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 -# -# This CMake module could be found at the following url: -# https://gerrit.automotivelinux.org/gerrit/#/admin/projects/src/cmake-apps-module -# ----------------------------------------------------------- -include(CMakeAfbTemplates) diff --git a/conf.d/packaging/agl-afb-aaaa_0.1.orig.tar.gz b/conf.d/packaging/agl-afb-aaaa_0.1.orig.tar.gz Binary files differdeleted file mode 100644 index 6a5980d..0000000 --- a/conf.d/packaging/agl-afb-aaaa_0.1.orig.tar.gz +++ /dev/null diff --git a/conf.d/project/CMakeLists.txt b/conf.d/project/CMakeLists.txt deleted file mode 100644 index fd4d454..0000000 --- a/conf.d/project/CMakeLists.txt +++ /dev/null @@ -1,24 +0,0 @@ -########################################################################### -# 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 anything not starting with _ -PROJECT_SUBDIRS_ADD(${PROJECT_SRC_DIR_PATTERN}) - - diff --git a/conf.d/project/alsa.d/README.md b/conf.d/project/alsa.d/README.md deleted file mode 100644 index aa2a54e..0000000 --- a/conf.d/project/alsa.d/README.md +++ /dev/null @@ -1,175 +0,0 @@ - -Alsa Configuration is not complex, but it's heavy and every except intuitive. - -In order to set your configuration move step by step. And verify at each new step that you did not introduce a regression. - -### Make sure your board is not taken by PulseAudio - -* Pavucontrol is your friend. Go in device configuration and switch to off the device you want to make available to ALSA. -* Check for your device list with 'play -l'. Note that just after card number your get an alias for your sound card. - it is simpler to use this alias, card number will change depending on plug/unplug of device when this alias name - is more stable (except for few stupid driver who use 'USB' as sound card name. -* When your know your sound alias (eg:v1340 in mu case) you can test it with 'speaker-test -D v1340 -c2 -twav'. You may also - use sound card number with 'speaker-test -D hw:0 -c2 -twav'. Nevertheless as said previously this number is not stable. -* you are now ready to write your $HOME/.asoundrc config - -Note that $HOME/.asoundrc is loaded within libasound client and not by Alsa kernel, this is the reason why you do not need -to activate any control or restart a daemon for modifications to be taken in account. - -To use ALSA with AAAA and the controller you need to write 1 section in your ALSA config - -* Sound Card Mixer: Allows multiple audio stream to be played on the same sound card. If hardware support mixer, Alsa will use it. If - not it will provide mixing by software. -* Audio Role Volume: They provide independent volume for each audio role. For reference, we use Alsa softvolume, depending on - your hardware you may have this directly avaliable from your sound card. -* Authorised Audio PCM: those channel are designed for applications we do not trust and then enforce AAAA control check - before granting the access to a given channel. - -### Sound Card Mixer - -``` -pcm.SoundCardMixer { - type dmix - ipc_key 1024 - ipc_key_add_uid false - ipc_perm 0666 # mixing for all users - - # Define target effective sound card (cannot be a plugin) - slave { pcm "hw:v1340" } #Jabra Solmate - - # DMIX can only map two channels - bindings { - 0 0 - 1 1 - } -} -``` - -Warning: if you have more than one Mixer each of them should have a unique ipc_key. You sound card alias move in the slave section. -When this is done you may try your mixer with: - -``` - speaker-test -D MyMixerPCM -c2 -twav -``` - - -### Audio Role - -``` -pcm.NavigationRole { - type softvol - - # Point Slave on HOOK for policies control - slave.pcm "SoundCardMixer" - - # name should match with HAL but do not set card=xx - control.name "Playback Navigation" - -} - -``` - -The slave you point to your SoundCardMixer, and the control.name should be EXACTLY the same as the one defined in your HAL. - - -WARNING: The control here "Playback Navigation" is a user defined kernel control. It means that this kernel is created in -kernel space, but that its action happen in user space. When create those control remains visible until you reset your -sound card (eg: unplug USB), but they are save each time you reboot. It is recommended to start AAAA binder before testing -your softvol audio role channel. If you do the opposite the control will be create by Alsa Plugin and this will not inherit -of the default value you have in your HAL. - -When in place you should test it with: -``` - speaker-test -D NavigationRole -c2 -twav -``` - -IMPORTANT: control volume are attache to your physical hardware and not to intermediary level (Softvol or Mixer). To see the -newly created channel you should use -``` - amixer -Dhw:v1340 controls | grep -i playback -``` - -## Authorised Audio PCM - -This PCM is supervised with the AAAA audio hook plugin. The pluging and will any application request on this PCM and will -1st request an autorisation from AAAA controller to grant access for the client application. To do so, two things: -* the plugin should be declared (only once) -* you should declare as many authorized PCM as you need. - -### Plugin declaration - -``` -pcm_hook_type.MyHookPlugin { - install "AlsaInstallHook" - lib "/home/fulup/Workspace/AGL-AppFW/audio-bindings-dev/build/Alsa-Plugin/Alsa-Policy-Hook/policy_hook_cb.so" -} - -``` - -Lib is the path where to find AAAA Alsa hook plugin, install is the name of the init function it should not be changed. - - -When your plugin is defined you may declare your authorised PCM. Those PCM like softvol will take a slave, typically a lower -level of the audio role, or directly a mixer if your goal is to protect directly the Mixer. The AAAA Plugin hook take as - -``` -pcm.AuthorisedToNavigationOnly { - type hooks - slave.pcm "NavigationRole" - # Defined used hook sharelib and provide arguments/config to install func - hooks.0 { - type "MyHookPlugin" - hook_args { - verbose true # print few log messages (default false); - - # Every Call should return OK in order PCM to open (default timeout 100ms) - uri "ws://localhost:1234/api?token=audio-agent-token&uuid=audio-agent-session" - request { - # Request autorisation to write on navigation - RequestNavigation { - api "control" - verb "dispatch" - query "{'target':'navigation', 'args':{'device':'Jabra SOLEMATE v1.34.0'}}" - } - } - # map event reception to self generated signal - event { - pause 30 - resume 31 - stop 3 - } - } - } -} - -``` - - * The slave is the PCM that application will be transfer to if access to control is granted. - * Request is a suite à control action that respond to AGL standard application framework API - * Event is the mapping of signal an appplication will receive in case AAAA controller push event to the audio application. - -When using AAAA controller, most action should be transfert to the controller that will take action to authorise/deny the access. -Nevertheless it is also possible to directly access a lower level (e.g. call alsa Use Case Manager). People may also have their -own audio policy engine and request it directly from here. - -To test this last part your need to have a controller ready to respond to your request. Otherwise control will systematically -be denied. When your AAAA controller is ready to serve your request you may check this with -``` - amixer -Dhw:AuthorisedToMusicOnly controls | grep -i playback - amixer -Dhw:AuthorisedToNavigationOnly controls | grep -i playback -``` - -IMPORTANT: you need at least to audio role to really test this part. While you may assert with one channel that your flow -to accept/deny application works. You need two simultaneous audio stream to really play with the control. Typically when playing -music if you send a navigation message then the audio will be lower during the rendering of the navigation message. - -The action on how you lower an audio role when an other one with a higger level of priority come in place not defined at the -plugin level, but in the AAAA controller, where the API control/dispatch?target=xxxxx will execute a set of actions corresponding -the set/unset accept/deny of requested control. - -Remark: to understand what is happening it is a good idea to have an alxamixer option on the your soundcard -``` - amixer -Dhw:v1340 -``` - -(!) Do not forget to replace 'hw:v1340' by what ever is the alias of your sound card.
\ No newline at end of file diff --git a/conf.d/project/alsa.d/asoundrc.sample b/conf.d/project/alsa.d/asoundrc.sample deleted file mode 100644 index 0716b11..0000000 --- a/conf.d/project/alsa.d/asoundrc.sample +++ /dev/null @@ -1,140 +0,0 @@ -# -# Author: Fulup Ar Foll -# Object: PCM hook type -# -# Test : Note: Jabra_USB=hw:v1340 -# Check SoundCard speaker-test -Dhw:v1340 -c2 -twav -# Check MixerPCM speaker-test -DMyMixerPCM -c2 -twav -# Check HookPCM speaker-test -DMyNavigationHook -c2 -twav -# Check NavPCM speaker-test -DMyNavPCM -c2 -twav -# MultiMedia aplay -DDMyNavPCM /usr/share/sounds/alsa/test.wav -# -# Bug/Feature: when softvol control is initialised from plugin and not -# from AGL binding. At 1st run ctl has invalid TLV and cannot be -# use. Bypass Solution: -# * start audio-binder before playing sound (binding create control before softvol plugin) -# * run a dummy aplay -DMyNavPCM "" to get a clean control -# -# References: https://www.spinics.net/lists/alsa-devel/msg54235.html -# -------------------------------------------------------------------- - -# Mixer PCM allow to play multiple stream simultaneously -# ------------------------------------------------------ -pcm.MyMixerPCM { - type dmix - ipc_key 1024 - ipc_key_add_uid false - ipc_perm 0666 # mixing for all users - - # Define target effective sound card (cannot be a plugin) - slave { pcm "hw:v1340" } #Jabra Solmate - - # DMIX can only map two channels - bindings { - 0 0 - 1 1 - } -} - -# Define a Hook_type with a private sharelib -# ------------------------------------------- -pcm_hook_type.MyHookPlugin { - install "AlsaInstallHook" - lib "/home/fulup/Workspace/AGL-AppFW/audio-bindings-dev/build/Alsa-Plugin/Alsa-Policy-Hook/policy_hook_cb.so" -} - - -# Define a HookedPCM that point to Hook_type sharelib -# ---------------------------------------------------- -pcm.MyNavigationHook { - type hooks - slave.pcm "MyMixerPCM" - # Defined used hook sharelib and provide arguments/config to install func - hooks.0 { - type "MyHookPlugin" - hook_args { - verbose true # print few log messages (default false); - - # Every Call should return OK in order PCM to open (default timeout 100ms) - uri "ws://localhost:1234/api?token=audio-agent-token&uuid=audio-agent-session" - request { - # Request autorisation to write on navigation - RequestNavigation { - api "control" - verb "dispatch" - query "{'target':'navigation', 'args':{'device':'Jabra SOLEMATE v1.34.0'}}" - } - } - # map event reception to self generated signal - event { - pause 30 - resume 31 - stop 3 - } - } - } -} - -# If hardware does not support mixer emulate it with softvol -# ----------------------------------------------------------- -pcm.MyMultimediaPCM { - type softvol - - # Point Slave on HOOK for policies control - slave.pcm "MyNavigationHook" - - # resolution=HAL(valMax+1) (default=256) - resolution 256 - - # name should match with HAL but do not set card=xx - control.name "Playback Navigation" - - # Make this plugin visible from aplay -L - hint { - show on - description "Navigation SolftVol PCM" - } -} - -# If hardware does not support mixer emulate it with softvol -# ----------------------------------------------------------- -pcm.MyNavPCM { - type softvol - - # Point Slave on HOOK for policies control - slave.pcm "MyNavigationHook" - - # resolution=HAL(valMax+1) (default=256) - resolution 256 - - # name should match with HAL but do not set card=xx - control.name "Playback Navigation" - - # Make this plugin visible from aplay -L - hint { - show on - description "Navigation SolftVol PCM" - } -} - -# If hardware does not support mixer emulate it with softvol -# ----------------------------------------------------------- -pcm.MyAlarmPCM { - type softvol - - # Point Slave on HOOK for policies control - slave.pcm "MyNavigationHook" - - # resolution=HAL(valMax+1) (default=256) - resolution 256 - - # name should match with HAL but do not set card=xx - control.name "Playback Navigation" - - # Make this plugin visible from aplay -L - hint { - show on - description "Navigation SolftVol PCM" - } -} - diff --git a/conf.d/project/alsa.d/ucm.sample/HDA Intel PCH.conf b/conf.d/project/alsa.d/ucm.sample/HDA Intel PCH.conf deleted file mode 100644 index f6608a0..0000000 --- a/conf.d/project/alsa.d/ucm.sample/HDA Intel PCH.conf +++ /dev/null @@ -1,6 +0,0 @@ -Comment "Leon internal card" - -SectionUseCase."HiFi" { - File "HiFi.conf" - Comment "Default" -} diff --git a/conf.d/project/alsa.d/ucm.sample/HiFi.conf b/conf.d/project/alsa.d/ucm.sample/HiFi.conf deleted file mode 100644 index 9a53c8c..0000000 --- a/conf.d/project/alsa.d/ucm.sample/HiFi.conf +++ /dev/null @@ -1,84 +0,0 @@ -SectionVerb { - EnableSequence [ - cdev "hw:PCH" - - cset "name='Master Playback Switch' on" - cset "name='Headphone Playback Switch' off" - cset "name='Speaker Playback Switch' on" - - cset "name='Capture Switch' on" - cset "name='Capture Volume' 39" - cset "name='Mic Boost Volume' 2" - cset "name='Internal Mic Boost Volume' 0" - #cset "name='Capture Source' 0" - ] - DisableSequence [ - ] - Value { - TQ "Music" - OutputDspName "speaker_eq" - PlaybackPCM "hw:PCH,0" - } -} - -SectionDevice."Headphone".0 { - Value { - JackName "Headphone Jack" - OutputDspName "Jheadphone" - } - EnableSequence [ - cdev "hw:PCH" - - cset "name='Speaker Playback Switch' off" - cset "name='Headphone Playback Switch' on" - ] - DisableSequence [ - cdev "hw:PCH" - - cset "name='Headphone Playback Switch' off" - cset "name='Speaker Playback Switch' on" - ] -} - -SectionDevice."Mic".0 { - Value { - JackName "Mic Jack" - } - EnableSequence [ - cdev "hw:PCH" - - #cset "name='Capture Source' 1" - ] - DisableSequence [ - cdev "hw:PCH" - - cset "name='Capture Source' 0" - ] -} - -SectionModifier."RecordMedia".0 { - SupportedDevice [ - "Headphone" - ] - EnableSequence [ - cdev "hw:PCH" - ] - - DisableSequence [ - cdev "hw:PCH" - ] - - TransitionSequence."ToModifierName" [ - cdev "hw:PCH" - ] - - # Optional TQ and ALSA PCMs - Value { - TQ Voice - CapturePCM "hw:1" - PlaybackVolume "name='Master Playback Volume',index=2" - PlaybackSwitch "name='Master Playback Switch',index=2" - } - -} - diff --git a/conf.d/project/alsa.d/ucm.sample/README b/conf.d/project/alsa.d/ucm.sample/README deleted file mode 100644 index e7f08ae..0000000 --- a/conf.d/project/alsa.d/ucm.sample/README +++ /dev/null @@ -1,2 +0,0 @@ -Should match sound card name ex: "HDA Intel PCH" -cp -r . /usr/share/alsa/ucm diff --git a/conf.d/project/json.d/CMakeLists.txt b/conf.d/project/json.d/CMakeLists.txt deleted file mode 100644 index 8070997..0000000 --- a/conf.d/project/json.d/CMakeLists.txt +++ /dev/null @@ -1,32 +0,0 @@ -########################################################################### -# 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(ctl-config.d) - - file(GLOB XML_FILES "*.json") - - add_input_files("${XML_FILES}") - - SET_TARGET_PROPERTIES(${TARGET_NAME} PROPERTIES - LABELS "DATA" - OUTPUT_NAME ${TARGET_NAME} - ) diff --git a/conf.d/project/json.d/README.md b/conf.d/project/json.d/README.md deleted file mode 100644 index 0f4967d..0000000 --- a/conf.d/project/json.d/README.md +++ /dev/null @@ -1,22 +0,0 @@ -By default controller searches for a config filename with the same 'middlename' as daemon process. As an example if your process name is afb-daemon then middle name is 'daemon'. - -``` - onload-middlename-xxxxx.json - - # Middlename is taken from process middlename. -``` - -You may overload config search path with environement variables - * AFB_BINDER_NAME: change patern config search path. 'export AFB_BINDER_NAME=sample' will make controller to search for a configfile name 'onload-sample-xxx.json'. - * CONTROL_CONFIG_PATH: change default reserch path for configuration. You may provide multiple directories separated by ':'. - * CONTROL_LUA_PATH: same as CONTROL_CONFIG_PATH but for Lua script files. - -Example to load a config name 'onload-myconfig-test.json' do -``` - AFB_BINDER_NAME='myconfig' afb-daemon --verbose ...' -``` - -Note: you may change search pattern for Lua script by adding 'ctlname=afb-middlename-xxx' in the metadata section of your config 'onload-*.json' - -WARNING: Audio Control are the one from the HAL and not from Alsa LowLevel - diff --git a/conf.d/project/json.d/onload-aaaa-sample.json b/conf.d/project/json.d/onload-aaaa-sample.json deleted file mode 100644 index 2b0ad7f..0000000 --- a/conf.d/project/json.d/onload-aaaa-sample.json +++ /dev/null @@ -1,118 +0,0 @@ -{ - "$schema": "ToBeDone", - "metadata": { - "label": "sample-aaaa-control", - "info": "Sample of Video AAAA controls", - "name": "afb-sample-controller", - "version": "1.0" - }, - "onload": [{ - "label": "onload-default", - "info": "onload initialisation config", - "require": ["alsacore","jabra-usb","intel-hda","hal-most-unicens"], - "actions": - { - "label": "control-init", - "lua": "_Audio_Controller_Init", - "args": { - "evtname": "agl-audio" - } - } - }], - "controls": - [ - { - "label": "Volume", - "permissions": "urn:AGL:permission:audio:public:multimedia", - "actions": { - "label": "adjust-master-volume", - "info" : "volume value should be provided by requesting client", - "lua": "_Permament_Control", - "args": { - "ctl" : "Master_Playback_Volume" - } - } - },{ - "label": "Multimedia", - "permissions": "urn:AGL:permission:audio:public:multimedia", - "actions": { - "label": "authorize-multimedia", - "lua": "_Temporarily_Control", - "args": { - "ctl" : "Multimedia_Playback_Volume", - "val": 80 - } - } - }, { - "label": "Navigation", - "permissions": "urn:AGL:permission:audio:public:navigation", - "actions": { - "label": "authorize-navigation", - "lua": "_Temporarily_Control", - "args": { - "ctl" : "Multimedia_Playback_Volume", - "val": 40 - } - } - }, { - "label": "Telephony", - "permissions": "urn:AGL:permission:audio:public:telephony", - "actions": { - "label": "authorize-multimedia", - "lua": "_Temporarily_Control", - "args": { - "ctl" : "Multimedia_Playback_Volume", - "val": 20 - } - } - }, { - "label": "Emergency", - "permissions": "urn:AGL:permission:audio:public:emergency", - "actions": { - "label": "authorize-multimedia", - "lua": "_Temporarily_Control", - "args": { - "ctl" : "Multimedia_Playback_Switch", - "val": 0 - }, - "label": "authorize-multimedia", - "lua": "_Temporarily_Control", - "args": { - "ctl" : "Navigation_Playback_Switch", - "val": 0 - } - } - } - ], - "events": - [ - { - "label": "ReverseEngage", - "actions": [{ - "label": "adjust_volume-reverse", - "lua": "_Temporarily_Control", - "args": { - "ctl": "Multimedia_Playback_Volume", - "val": 20 - } - }, - { - "label": "prevent-telephony", - "lua": "_Temporarily_Control", - "args": { - "ctl": "Telephony_Playback_Switch", - "val": 0 - } - } - ] - }, - { - "label": "SpeedChanged", - "actions": { - "label": "adjust_volume", - "lua": "_Adjust_Volume" - } - } - ] -} - diff --git a/conf.d/project/lua.d/CMakeLists.txt b/conf.d/project/lua.d/CMakeLists.txt deleted file mode 100644 index 71b3371..0000000 --- a/conf.d/project/lua.d/CMakeLists.txt +++ /dev/null @@ -1,34 +0,0 @@ -########################################################################### -# 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(ctl-lua.d) - file(GLOB LUA_FILES "*.lua") - - # Romain work around to activate lua compilation - set(LUA_LIST "${LUA_FILES}" CACHE STRING "") - - add_input_files("${LUA_FILES}") - - SET_TARGET_PROPERTIES(${TARGET_NAME} PROPERTIES - LABELS "DATA" - OUTPUT_NAME ${TARGET_NAME} - )
\ No newline at end of file diff --git a/conf.d/project/lua.d/README.md b/conf.d/project/lua.d/README.md deleted file mode 100644 index fc3548b..0000000 --- a/conf.d/project/lua.d/README.md +++ /dev/null @@ -1,36 +0,0 @@ -WARNING: controller is now independent from AAAA and thus should be imported by your binder before requesting it. - -For this your only have to provide the path where to find your controller you are in your development tree probably with something -like --binding=../../afb-controller/build/ctl-binding/afb-controller.so on the other hand if you controller was installed you -should import it from where ever you install it. - -To run this controller sample from your developpement environement use -``` - -export BUILD_DIR=build - -# with an internal MPDC (Pusic Player Daemon Client) API -afb-daemon --port=1234 --workdir=. --roothttp=../htdocs --token= --verbose \ ---alias=/monitoring:$HOME/opt/afb-monitoring \ ---ldpaths=package/lib \ ---alias=/monitoring:/home/fulup/opt/afb-monitoring \ ---binding=../../afb-controller/$BUILD_DIR/package/lib/afb-controller.so \ ---binding=../../afb-mpdc/$BUILD_DIR/package/lib/afb-mpdc-api.so \ ---ws-server=unix:/var/tmp/afb-ws/mpdc - -# with an exernal MPDC API -afb-daemon --port=1234 --workdir=. --roothttp=../htdocs --token= --verbose \ ---alias=/monitoring:$HOME/opt/afb-monitoring \ ---ldpaths=. \ ---alias=/monitoring:/home/fulup/opt/afb-monitoring \ ---binding=../../afb-controller/$BUILD_DIR/ctl-binding/afb-controller.so \ ---ws-client=unix:/var/tmp/afb-ws/mpdc - -# Note: - - Both sample make the assumption the monitoring HTML5 app is avaliable at $HOME/opt/afb-monitoring - - With second sample you should obviously have your MPDC service exposing its API with --ws-server=unix:/var/tmp/afb-ws/mpdc - - Should use 'make populate' to get ./build/package/lib to be uptodate - -``` - -Running AAAA from you IDE ![Sample config](netbeans-aaaa-run-config.png) diff --git a/conf.d/project/lua.d/netbeans-aaaa-run-config.png b/conf.d/project/lua.d/netbeans-aaaa-run-config.png Binary files differdeleted file mode 100644 index ffb0e5d..0000000 --- a/conf.d/project/lua.d/netbeans-aaaa-run-config.png +++ /dev/null diff --git a/conf.d/project/lua.d/onload-aaaa-00-utils.lua b/conf.d/project/lua.d/onload-aaaa-00-utils.lua deleted file mode 100644 index 29d2c70..0000000 --- a/conf.d/project/lua.d/onload-aaaa-00-utils.lua +++ /dev/null @@ -1,86 +0,0 @@ ---[[ - 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-aaaa-01-init.lua b/conf.d/project/lua.d/onload-aaaa-01-init.lua deleted file mode 100644 index 5ebc695..0000000 --- a/conf.d/project/lua.d/onload-aaaa-01-init.lua +++ /dev/null @@ -1,48 +0,0 @@ ---[[ - 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 _Audio_Controller_Init(source, control) - - printf ("[--> Audio_Controller_Init -->] source=%d control=%s", source, Dump_Table(control)) - - -- create an event from configuration name - _Global_Context["event"]=AFB:evtmake(control["evtname"]) - - -- query HAL to retrieve sound card. - local err,result= AFB:servsync ("alsacore", "hallist", {}) - - if (err) then - AFB:error("Fail to retrieve Audio HAL") - else - _Global_Context["registry"]=result["response"] - printf("[<-- Audio_Controller_Init <--] Active HAL=%s", Dump_Table(result["response"])) - end -end diff --git a/conf.d/project/lua.d/onload-aaaa-03-controls.lua b/conf.d/project/lua.d/onload-aaaa-03-controls.lua deleted file mode 100644 index ae1269b..0000000 --- a/conf.d/project/lua.d/onload-aaaa-03-controls.lua +++ /dev/null @@ -1,158 +0,0 @@ ---[[ - 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 control activate a label with - labeller api -> APi=label VERB=dispatch - arguments are - - source (0) when requesting the label (-1) when releasing - - label comme from config given with 'control' in onload-middlename-xxxxx.json - - control is the argument part of the query as providing by control requesting the label. - ---]] - -_CurrentHalVolume={} - - - ---[[ Apply control - * source=1 permanent change requested - * source=0 temporally request control - * source=-1 temporally release control --- ------------------------------------ --]] -local function Apply_Hal_Control(source, label, adjustment) - local HAL = _Global_Context["registry"] - - -- check we really got some data - if (adjustment == nil) then - AFB:error ("--* (Hoops) Control should provide volume adjustment") - return 1 - end - - -- loop on each HAL save current volume and push adjustment - for key,hal in pairs(_Global_Context["registry"]) do - printf ("--- HAL=%s", Dump_Table(hal)) - - -- action set loop on active HAL and get current volume - -- if label respond then do volume adjustment - - if (source >= 0) then - - -- get current volume for each HAL - local err,result= AFB:servsync(hal["api"],"ctlget", {["label"]=label}) - - -- if no error save current volume and set adjustment - if (err ~= nil) then - local response= result["response"] - printf ("--- Response %s=%s", hal["api"], Dump_Table(response)) - - if (response == nil) then - printf ("--- Fail to Activate '%s'='%s' result=%s", hal["api"], label, Dump_Table(result)) - return 1 -- unhappy - end - - -- save response in global space - _CurrentHalVolume [hal["api"]] = response - - -- finally set the new value - local query= { - ["tag"]= response["tag"], - ["val"]= adjustment - } - - -- best effort to set adjustment value - AFB:servsync(hal["api"],"ctlset",query) - end - - else -- when label is release reverse action at preempt time - - if (_CurrentHalVolume [hal["api"]] ~= nil) then - - printf("--- Restoring initial volume HAL=%s Control=%s", hal["api"], _CurrentHalVolume [hal["api"]]) - - AFB:servsync(hal["api"],"ctlset", _CurrentHalVolume [hal["api"]]) - end - end - - end - return 0 -- happy end -end - - --- Temporally adjust volume -function _Temporarily_Control(source, control, client) - - printf ("[--> _Temporarily_Control -->] source=%d control=%s client=%s", source, Dump_Table(control), Dump_Table(client)) - - -- Init should have been properly done - if (_Global_Context["registry"] == nil) then - AFB:error ("--* (Hoops) No Hal in _Global_Context=%s", Dump_Table(_Global_Context)) - return 1 - end - - -- make sure label as valid - if (control["ctl"] == nil or control["val"] == nil) then - AFB:error ("--* Action Ignore no/invalid control=%s", Dump_Table(control)) - return 1 -- unhappy - end - - if (source == 0) then - AFB:info("-- Adjust %s=%d", control["ctl"], control["val"]) - local error=Apply_Hal_Control(source, control["ctl"], control["val"]) - if (error == nil) then - return 1 -- unhappy - end - AFB:notice ("[<-- _Temporarily_Control Granted<--]") - else - Apply_Hal_Control(source, control["ctl"],0) - AFB:notice ("[<-- _Temporarily_Control Restore--]") - end - - return 0 -- happy return -end - - --- Permanent Adjust volume -function _Permanent_Control(source, control, client) - - printf ("[--> _Permanent_Control -->] source=%d control=%s client=%s", source, Dump_Table(control), Dump_Table(client)) - - -- Init should have been properly done - if (_Global_Context["registry"] == nil) then - AFB:error ("--* (Hoops) No Hal in _Global_Context=%s", Dump_Table(_Global_Context)) - return 1 - end - - -- make sure label as valid - if (control["ctl"] == nil or control["val"] == nil) then - AFB:error ("--* Action Ignore no/invalid control=%s", Dump_Table(control)) - return 1 -- unhappy - end - - if (source == 0) then - AFB:info("-- Adjust %s=%d", control["ctl"], control["val"]) - local error=Apply_Hal_Control(1, control["ctl"], control["val"]) - if (error == nil) then - return 1 -- unhappy - end - AFB:notice ("[<-- _Permanent_Control Granted<--]") - else - Apply_Hal_Control(source, control["ctl"],0) - AFB:notice ("[<-- _Permanent_Control Restore--]") - end - - return 0 -- happy return -end - diff --git a/conf.d/project/lua.d/onload-aaaa-10-event.lua b/conf.d/project/lua.d/onload-aaaa-10-event.lua deleted file mode 100644 index 474ebe0..0000000 --- a/conf.d/project/lua.d/onload-aaaa-10-event.lua +++ /dev/null @@ -1,74 +0,0 @@ ---[[ - 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 |