diff options
author | Loïc Collignon <loic.collignon@iot.bzh> | 2018-01-11 14:41:57 +0100 |
---|---|---|
committer | Loïc Collignon <loic.collignon@iot.bzh> | 2018-01-26 07:36:21 +0100 |
commit | b13719ee11e8ef5cb14e2310a12e9f790ecc7809 (patch) | |
tree | 47acdd6ccb02acdfa685b7635ef8b2d3abfabb0a | |
parent | 786a2a295fd452aab5078ce4923cd5fcc2c1b464 (diff) |
removed unused files and useless subdirectories
Change-Id: Ie0ebe0104589ff99ae24c7410a484eeef18821e7
Signed-off-by: Loïc Collignon <loic.collignon@iot.bzh>
-rw-r--r-- | CMakeLists.txt | 56 | ||||
-rw-r--r-- | agl-identity-agent.service.in | 11 | ||||
-rw-r--r-- | agl-identity-service/CMakeLists.txt | 25 | ||||
-rw-r--r-- | conf.d/cmake/config.cmake (renamed from agl-identity-service/conf.d/cmake/config.cmake) | 4 | ||||
-rw-r--r-- | conf.d/wgt/config.xml.in (renamed from agl-identity-service/conf.d/wgt/config.xml.in) | 0 | ||||
-rw-r--r-- | etc/config.json (renamed from agl-identity-service/etc/config.json) | 0 | ||||
-rw-r--r-- | htdocs/identity/AFB-websock.js (renamed from agl-identity-service/htdocs/identity/AFB-websock.js) | 0 | ||||
-rw-r--r-- | htdocs/identity/binding-debug.css (renamed from agl-identity-service/htdocs/identity/binding-debug.css) | 0 | ||||
-rw-r--r-- | htdocs/identity/identity-binding.js (renamed from agl-identity-service/htdocs/identity/identity-binding.js) | 0 | ||||
-rw-r--r-- | htdocs/identity/index.html (renamed from agl-identity-service/htdocs/identity/index.html) | 0 | ||||
-rw-r--r-- | src/CMakeLists.txt (renamed from agl-identity-service/src/CMakeLists.txt) | 0 | ||||
-rw-r--r-- | src/agl-forgerock.c (renamed from agl-identity-service/src/agl-forgerock.c) | 0 | ||||
-rw-r--r-- | src/agl-forgerock.h (renamed from agl-identity-service/src/agl-forgerock.h) | 0 | ||||
-rw-r--r-- | src/agl-identity-binding.c (renamed from agl-identity-service/src/agl-identity-binding.c) | 0 | ||||
-rw-r--r-- | src/aia-get.c (renamed from agl-identity-service/src/aia-get.c) | 0 | ||||
-rw-r--r-- | src/aia-get.h (renamed from agl-identity-service/src/aia-get.h) | 0 | ||||
-rw-r--r-- | src/authorization.c (renamed from agl-identity-service/src/authorization.c) | 0 | ||||
-rw-r--r-- | src/authorization.h (renamed from agl-identity-service/src/authorization.h) | 0 | ||||
-rw-r--r-- | src/base64.c (renamed from agl-identity-service/src/base64.c) | 0 | ||||
-rw-r--r-- | src/base64.h (renamed from agl-identity-service/src/base64.h) | 0 | ||||
-rw-r--r-- | src/curl-wrap.c (renamed from agl-identity-service/src/curl-wrap.c) | 0 | ||||
-rw-r--r-- | src/curl-wrap.h (renamed from agl-identity-service/src/curl-wrap.h) | 0 | ||||
-rw-r--r-- | src/escape.c (renamed from agl-identity-service/src/escape.c) | 0 | ||||
-rw-r--r-- | src/escape.h (renamed from agl-identity-service/src/escape.h) | 0 | ||||
-rw-r--r-- | src/export.map (renamed from agl-identity-service/src/export.map) | 0 | ||||
-rw-r--r-- | src/memo.txt (renamed from agl-identity-service/src/memo.txt) | 0 | ||||
-rw-r--r-- | src/oidc-agent.c (renamed from agl-identity-service/src/oidc-agent.c) | 0 | ||||
-rw-r--r-- | src/oidc-agent.h (renamed from agl-identity-service/src/oidc-agent.h) | 0 | ||||
-rw-r--r-- | src/test-aia-uds-bluez.c (renamed from agl-identity-service/src/test-aia-uds-bluez.c) | 0 | ||||
-rw-r--r-- | uds-ble-id-init-service/CMakeLists.txt | 21 | ||||
-rw-r--r-- | uds-ble-id-init-service/btle-advise.service | 8 | ||||
-rw-r--r-- | uds-ble-id-init-service/btle-advise.timer | 6 | ||||
-rw-r--r-- | uds-ble-id-init-service/conf.d/cmake/config.cmake | 201 | ||||
-rw-r--r-- | uds-ble-id-init-service/conf.d/wgt/config.xml.in | 19 | ||||
-rw-r--r-- | uds-ble-id-init-service/src/CMakeLists.txt | 35 | ||||
-rw-r--r-- | uds-ble-id-init-service/src/aia-uds-bluez.c | 607 | ||||
-rw-r--r-- | uds-ble-id-init-service/src/aia-uds-bluez.h | 46 | ||||
-rw-r--r-- | uds-ble-id-init-service/src/uds-ble-id-init-service.c | 146 |
38 files changed, 9 insertions, 1176 deletions
diff --git a/CMakeLists.txt b/CMakeLists.txt index d9d7bd1..7ef4f7a 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -1,8 +1,7 @@ ########################################################################### -# Copyright 2016 IoT.bzh +# Copyright 2017 IoT.bzh # -# author: José Bollo <jose.bollo@iot.bzh> -# author: Stéphane Desneux <stephane.desneux@iot.bzh> +# author: Jose Bollo <jose.bollo@iot.bzh> # # Licensed under the Apache License, Version 2.0 (the "License"); # you may not use this file except in compliance with the License. @@ -17,51 +16,10 @@ # limitations under the License. ########################################################################### -cmake_minimum_required(VERSION 3.3) - -project(agl-identity-agent VERSION 0.1) - -include(GNUInstallDirs) -include(FindPkgConfig) - -########################################################################### - -set(CMAKE_BUILD_TYPE Debug CACHE STRING "set debug build by default") - -link_libraries(-Wl,--as-needed -Wl,--gc-sections) - -add_compile_options(-Wall -Wextra -Wconversion) -add_compile_options(-Wno-unused-parameter) # frankly not using a parameter does it care? -add_compile_options(-Wno-unused-but-set-variable) -add_compile_options(-Werror=maybe-uninitialized) -add_compile_options(-Werror=implicit-function-declaration) -add_compile_options(-ffunction-sections -fdata-sections) -add_compile_options(-Wl,--as-needed -Wl,--gc-sections) -add_compile_options(-fPIC) - -set(CMAKE_C_FLAGS_PROFILING "-g -O0 -pg -Wp,-U_FORTIFY_SOURCE") -set(CMAKE_C_FLAGS_DEBUG "-g -O0 -ggdb -Wp,-U_FORTIFY_SOURCE") -set(CMAKE_C_FLAGS_RELEASE "-g -O2") -set(CMAKE_C_FLAGS_CCOV "-g -O2 --coverage") - -########################################################################### - -set(PROJECT_DESTINATION ${CMAKE_INSTALL_FULL_LIBEXECDIR}/${PROJECT_NAME}) - -########################################################################### - -add_subdirectory(binding) - -########################################################################### - -configure_file(agl-identity-agent.service.in agl-identity-agent.service @ONLY) - -INSTALL(FILES - ${CMAKE_CURRENT_BINARY_DIR}/agl-identity-agent.service - ${CMAKE_CURRENT_SOURCE_DIR}/btle-advise.service - ${CMAKE_CURRENT_SOURCE_DIR}/btle-advise.timer - DESTINATION - ${PROJECT_DESTINATION} - ) +cmake_minimum_required(VERSION 3.6) +SET(CMAKE_MODULE_PATH ${CMAKE_MODULE_PATH} ${CMAKE_CURRENT_SOURCE_DIR}/conf.d/cmake/) +include(${CMAKE_CURRENT_SOURCE_DIR}/conf.d/cmake/config.cmake) +install(DIRECTORY etc DESTINATION ./) +install(DIRECTORY htdocs/identity DESTINATION htdocs) diff --git a/agl-identity-agent.service.in b/agl-identity-agent.service.in deleted file mode 100644 index 5381946..0000000 --- a/agl-identity-agent.service.in +++ /dev/null @@ -1,11 +0,0 @@ -[Unit] -Description=AGL identity agent -Requires=btle-advise.service - -[Service] -User=root -ExecStartPre=/usr/sbin/rfkill unblock 0 -ExecStart=/usr/bin/afb-daemon --rootdir=@PROJECT_DESTINATION@ --ldpaths=@PROJECT_DESTINATION@ --port=1212 --token= --verbose --verbose --verbose - -[Install] -WantedBy=default.target diff --git a/agl-identity-service/CMakeLists.txt b/agl-identity-service/CMakeLists.txt deleted file mode 100644 index 7ef4f7a..0000000 --- a/agl-identity-service/CMakeLists.txt +++ /dev/null @@ -1,25 +0,0 @@ -########################################################################### -# Copyright 2017 IoT.bzh -# -# author: Jose Bollo <jose.bollo@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. -########################################################################### - -cmake_minimum_required(VERSION 3.6) -SET(CMAKE_MODULE_PATH ${CMAKE_MODULE_PATH} ${CMAKE_CURRENT_SOURCE_DIR}/conf.d/cmake/) -include(${CMAKE_CURRENT_SOURCE_DIR}/conf.d/cmake/config.cmake) - - -install(DIRECTORY etc DESTINATION ./) -install(DIRECTORY htdocs/identity DESTINATION htdocs) diff --git a/agl-identity-service/conf.d/cmake/config.cmake b/conf.d/cmake/config.cmake index c5fdae6..6e2aa26 100644 --- a/agl-identity-service/conf.d/cmake/config.cmake +++ b/conf.d/cmake/config.cmake @@ -22,7 +22,7 @@ set(PROJECT_NAME agl-identity-service) set(PROJECT_VERSION "0.1") set(PROJECT_PRETTY_NAME "AGL identity service") set(PROJECT_DESCRIPTION "AGL identity service") -set(PROJECT_URL "https://github.com/iotbzh/aia-binding") +set(PROJECT_URL "https://gerrit.automotivelinux.org/gerrit/p/apps/agl-service-identity-agent.git") set(PROJECT_ICON "icon.png") set(PROJECT_AUTHOR "José Bollo") set(PROJECT_AUTHOR_MAIL "jose.bollo@iot.bzh") @@ -31,7 +31,7 @@ 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") +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. diff --git a/agl-identity-service/conf.d/wgt/config.xml.in b/conf.d/wgt/config.xml.in index cd66c2b..cd66c2b 100644 --- a/agl-identity-service/conf.d/wgt/config.xml.in +++ b/conf.d/wgt/config.xml.in diff --git a/agl-identity-service/etc/config.json b/etc/config.json index c69e5be..c69e5be 100644 --- a/agl-identity-service/etc/config.json +++ b/etc/config.json diff --git a/agl-identity-service/htdocs/identity/AFB-websock.js b/htdocs/identity/AFB-websock.js index 08a7ffe..08a7ffe 100644 --- a/agl-identity-service/htdocs/identity/AFB-websock.js +++ b/htdocs/identity/AFB-websock.js diff --git a/agl-identity-service/htdocs/identity/binding-debug.css b/htdocs/identity/binding-debug.css index f41c940..f41c940 100644 --- a/agl-identity-service/htdocs/identity/binding-debug.css +++ b/htdocs/identity/binding-debug.css diff --git a/agl-identity-service/htdocs/identity/identity-binding.js b/htdocs/identity/identity-binding.js index 55dbb96..55dbb96 100644 --- a/agl-identity-service/htdocs/identity/identity-binding.js +++ b/htdocs/identity/identity-binding.js diff --git a/agl-identity-service/htdocs/identity/index.html b/htdocs/identity/index.html index bbeee51..bbeee51 100644 --- a/agl-identity-service/htdocs/identity/index.html +++ b/htdocs/identity/index.html diff --git a/agl-identity-service/src/CMakeLists.txt b/src/CMakeLists.txt index e4a744b..e4a744b 100644 --- a/agl-identity-service/src/CMakeLists.txt +++ b/src/CMakeLists.txt diff --git a/agl-identity-service/src/agl-forgerock.c b/src/agl-forgerock.c index 97cc4b9..97cc4b9 100644 --- a/agl-identity-service/src/agl-forgerock.c +++ b/src/agl-forgerock.c diff --git a/agl-identity-service/src/agl-forgerock.h b/src/agl-forgerock.h index 1aee680..1aee680 100644 --- a/agl-identity-service/src/agl-forgerock.h +++ b/src/agl-forgerock.h diff --git a/agl-identity-service/src/agl-identity-binding.c b/src/agl-identity-binding.c index 12f43bd..12f43bd 100644 --- a/agl-identity-service/src/agl-identity-binding.c +++ b/src/agl-identity-binding.c diff --git a/agl-identity-service/src/aia-get.c b/src/aia-get.c index 56c82b0..56c82b0 100644 --- a/agl-identity-service/src/aia-get.c +++ b/src/aia-get.c diff --git a/agl-identity-service/src/aia-get.h b/src/aia-get.h index be1a1f8..be1a1f8 100644 --- a/agl-identity-service/src/aia-get.h +++ b/src/aia-get.h diff --git a/agl-identity-service/src/authorization.c b/src/authorization.c index ae00923..ae00923 100644 --- a/agl-identity-service/src/authorization.c +++ b/src/authorization.c diff --git a/agl-identity-service/src/authorization.h b/src/authorization.h index bd26c1a..bd26c1a 100644 --- a/agl-identity-service/src/authorization.h +++ b/src/authorization.h diff --git a/agl-identity-service/src/base64.c b/src/base64.c index 0841aba..0841aba 100644 --- a/agl-identity-service/src/base64.c +++ b/src/base64.c diff --git a/agl-identity-service/src/base64.h b/src/base64.h index 5a944df..5a944df 100644 --- a/agl-identity-service/src/base64.h +++ b/src/base64.h diff --git a/agl-identity-service/src/curl-wrap.c b/src/curl-wrap.c index 3c566a3..3c566a3 100644 --- a/agl-identity-service/src/curl-wrap.c +++ b/src/curl-wrap.c diff --git a/agl-identity-service/src/curl-wrap.h b/src/curl-wrap.h index 2e44f47..2e44f47 100644 --- a/agl-identity-service/src/curl-wrap.h +++ b/src/curl-wrap.h diff --git a/agl-identity-service/src/escape.c b/src/escape.c index 3bb25c2..3bb25c2 100644 --- a/agl-identity-service/src/escape.c +++ b/src/escape.c diff --git a/agl-identity-service/src/escape.h b/src/escape.h index 7d548db..7d548db 100644 --- a/agl-identity-service/src/escape.h +++ b/src/escape.h diff --git a/agl-identity-service/src/export.map b/src/export.map index ee2f413..ee2f413 100644 --- a/agl-identity-service/src/export.map +++ b/src/export.map diff --git a/agl-identity-service/src/memo.txt b/src/memo.txt index 3a6ed50..3a6ed50 100644 --- a/agl-identity-service/src/memo.txt +++ b/src/memo.txt diff --git a/agl-identity-service/src/oidc-agent.c b/src/oidc-agent.c index 1f09e7a..1f09e7a 100644 --- a/agl-identity-service/src/oidc-agent.c +++ b/src/oidc-agent.c diff --git a/agl-identity-service/src/oidc-agent.h b/src/oidc-agent.h index de5918d..de5918d 100644 --- a/agl-identity-service/src/oidc-agent.h +++ b/src/oidc-agent.h diff --git a/agl-identity-service/src/test-aia-uds-bluez.c b/src/test-aia-uds-bluez.c index 4a084a5..4a084a5 100644 --- a/agl-identity-service/src/test-aia-uds-bluez.c +++ b/src/test-aia-uds-bluez.c diff --git a/uds-ble-id-init-service/CMakeLists.txt b/uds-ble-id-init-service/CMakeLists.txt deleted file mode 100644 index 14b6d55..0000000 --- a/uds-ble-id-init-service/CMakeLists.txt +++ /dev/null @@ -1,21 +0,0 @@ -########################################################################### -# Copyright 2017 IoT.bzh -# -# author: Jose Bollo <jose.bollo@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. -########################################################################### - -cmake_minimum_required(VERSION 3.6) -SET(CMAKE_MODULE_PATH ${CMAKE_MODULE_PATH} ${CMAKE_CURRENT_SOURCE_DIR}/conf.d/cmake/) -include(${CMAKE_CURRENT_SOURCE_DIR}/conf.d/cmake/config.cmake) diff --git a/uds-ble-id-init-service/btle-advise.service b/uds-ble-id-init-service/btle-advise.service deleted file mode 100644 index 1a34237..0000000 --- a/uds-ble-id-init-service/btle-advise.service +++ /dev/null @@ -1,8 +0,0 @@ -[Unit] -Description=activates advertising of BlueTooth Low-Energy on hci0 - -[Service] -Type=oneshot -ExecStart=/bin/bash -c "rfkill list|sed '/[bB]luetooth/!d;s/:.*//'|xargs -n1 rfkill unblock" -ExecStart=/bin/bash -c "hcitool dev|tail -n+2|cut -f2|xargs -n1 -IX hciconfig X leadv" - diff --git a/uds-ble-id-init-service/btle-advise.timer b/uds-ble-id-init-service/btle-advise.timer deleted file mode 100644 index b02594c..0000000 --- a/uds-ble-id-init-service/btle-advise.timer +++ /dev/null @@ -1,6 +0,0 @@ -[Unit] -Description=Ensure BLE advise is up - -[Timer] -AccuracySec=1min -OnUnitActiveSec=1min diff --git a/uds-ble-id-init-service/conf.d/cmake/config.cmake b/uds-ble-id-init-service/conf.d/cmake/config.cmake deleted file mode 100644 index 4ea1d79..0000000 --- a/uds-ble-id-init-service/conf.d/cmake/config.cmake +++ /dev/null @@ -1,201 +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 uds-ble-id-init) -set(PROJECT_VERSION "0.1") -set(PROJECT_PRETTY_NAME "AGL Identitity initiator above BLE's User Data Service") -set(PROJECT_DESCRIPTION "AGL Identitity initiator above BLE's User Data Service") -set(PROJECT_URL "https://github.com/iotbzh/aia-binding") -set(PROJECT_ICON "icon.png") -set(PROJECT_AUTHOR "José Bollo") -set(PROJECT_AUTHOR_MAIL "jose.bollo@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) -# ---------------------------------- - -# 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 -) - -# 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 irrelevant) - -# 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/uds-ble-id-init-service/conf.d/wgt/config.xml.in b/uds-ble-id-init-service/conf.d/wgt/config.xml.in deleted file mode 100644 index 0ccd9b5..0000000 --- a/uds-ble-id-init-service/conf.d/wgt/config.xml.in +++ /dev/null @@ -1,19 +0,0 @@ -<?xml version="1.0" encoding="UTF-8"?> -<widget xmlns="http://www.w3.org/ns/widgets" id="@PROJECT_NAME@" version="@PROJECT_VERSION@"> - <name>@PROJECT_NAME@</name> - <icon src="@PROJECT_ICON@"/> - <content src="@WIDGET_ENTRY_POINT@" type="@WIDGET_TYPE@"/> - <description>@PROJECT_DESCRIPTION@</description> - <author>@PROJECT_AUTHOR@ <@PROJECT_AUTHOR_MAIL@></author> - <license>@PROJECT_LICENSE@</license> - <feature name="urn:AGL:widget:required-permission"> - <param name="urn:AGL:permission::public:hidden" value="required" /> - <param name="urn:AGL:permission::system:run-by-default" value="required" /> - </feature> - <feature name="urn:AGL:widget:provided-api"> - <param name="windowmanager" value="ws" /> - </feature> - <feature name="urn:AGL:widget:required-api"> - <param name="lib/afb-ll-database-binding.so" value="local" /> - </feature> -</widget> diff --git a/uds-ble-id-init-service/src/CMakeLists.txt b/uds-ble-id-init-service/src/CMakeLists.txt deleted file mode 100644 index 97e229a..0000000 --- a/uds-ble-id-init-service/src/CMakeLists.txt +++ /dev/null @@ -1,35 +0,0 @@ -########################################################################### -# Copyright 2017 IoT.bzh -# -# author: Jose Bollo <jose.bollo@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_TARGET_ADD(afb-uds-ble-id-init-binding) - -add_library(afb-uds-ble-id-init-binding MODULE - uds-ble-id-init-service.c - aia-uds-bluez.c -) - -set_target_properties(afb-uds-ble-id-init-binding PROPERTIES - LABELS "BINDING" - PREFIX "" - COMPILE_FLAGS "${libsystemd_CFLAGS}" - INCLUDE_DIRECTORIES "${libsystemd_INCLUDE_DIRS}" - LINK_FLAGS "${BINDINGS_LINK_FLAG}" - LINK_LIBRARIES "${libsystemd_LIBRARIES}" - OUTPUT_NAME "${TARGET_NAME}" -) - diff --git a/uds-ble-id-init-service/src/aia-uds-bluez.c b/uds-ble-id-init-service/src/aia-uds-bluez.c deleted file mode 100644 index 35ba61d..0000000 --- a/uds-ble-id-init-service/src/aia-uds-bluez.c +++ /dev/null @@ -1,607 +0,0 @@ -/* - * Copyright (C) 2015, 2016, 2017 "IoT.bzh" - * Author: José Bollo <jose.bollo@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. - */ -#define _GNU_SOURCE - -#include <stdlib.h> -#include <stdint.h> -#include <string.h> -#include <errno.h> - -#include <systemd/sd-bus.h> - -#include "aia-uds-bluez.h" - -#define ROOT "/uds" - -#define ITF_SERVICE "org.bluez.GattService1" -#define ITF_CHARACTERISTIC "org.bluez.GattCharacteristic1" -#define ITF_DESCRIPTOR "org.bluez.GattDescriptor1" - -/****** internal types **********/ - -struct item -{ - const char *uuid; - const char *path; - struct item *parent; - struct aia_uds_value *value; -}; - -/****** internal data **********/ - -static sd_bus *busini; -static int activation; - -static aia_uds_on_change on_change_callback; - -static struct aia_uds uds; - -static struct aia_uds uds_descs = -{ - .first_name = { .data = "First name of the user" }, - .last_name = { .data = "Last name of the user" }, - .email = { .data = "Email of the user" }, - .language = { .data = "The Language definition is based on ISO639-1" } -}; - -static struct aia_uds_value woutf8 = { .data = "\031\000\047\000\001\000\000", .length = 7 }; - -static struct item services[1] = -{ - { - .uuid = "0000181C-0000-1000-8000-00805f9b34fb", - .path = ROOT"/service0" - } -}; - -static struct item characteristics[4] = -{ - { - .uuid = "00002A8A-0000-1000-8000-00805f9b34fb", - .path = ROOT"/service0/char0", - .parent = &services[0], - .value = &uds.first_name - }, { - .uuid = "00002A90-0000-1000-8000-00805f9b34fb", - .path = ROOT"/service0/char1", - .parent = &services[0], - .value = &uds.last_name - }, { - .uuid = "00002A87-0000-1000-8000-00805f9b34fb", - .path = ROOT"/service0/char2", - .parent = &services[0], - .value = &uds.email - }, { - .uuid = "00002AA2-0000-1000-8000-00805f9b34fb", - .path = ROOT"/service0/char3", - .parent = &services[0], - .value = &uds.language - } -}; - -static struct item descriptors[8] = -{ - { - .uuid = "00002901-0000-1000-8000-00805f9b34fb", - .path = ROOT"/service0/char0/desc0", - .parent = &characteristics[0], - .value = &uds_descs.first_name - }, { - .uuid = "00002904-0000-1000-8000-00805f9b34fb", - .path = ROOT"/service0/char0/desc1", - .parent = &characteristics[0], - .value = &woutf8 - }, { - .uuid = "00002901-0000-1000-8000-00805f9b34fb", - .path = ROOT"/service0/char1/desc0", - .parent = &characteristics[1], - .value = &uds_descs.last_name - }, { - .uuid = "00002904-0000-1000-8000-00805f9b34fb", - .path = ROOT"/service0/char1/desc1", - .parent = &characteristics[1], - .value = &woutf8 - }, { - .uuid = "00002901-0000-1000-8000-00805f9b34fb", - .path = ROOT"/service0/char2/desc0", - .parent = &characteristics[2], - .value = &uds_descs.email - }, { - .uuid = "00002904-0000-1000-8000-00805f9b34fb", - .path = ROOT"/service0/char2/desc1", - .parent = &characteristics[2], - .value = &woutf8 - }, { - .uuid = "00002901-0000-1000-8000-00805f9b34fb", - .path = ROOT"/service0/char3/desc0", - .parent = &characteristics[3], - .value = &uds_descs.language - }, { - .uuid = "00002904-0000-1000-8000-00805f9b34fb", - .path = ROOT"/service0/char3/desc1", - .parent = &characteristics[3], - .value = &woutf8 - } -}; - -/****** utility ***********/ - -static uint16_t get_offset(sd_bus_message *m) -{ - uint16_t offset; - const char *key; - - if (0 < sd_bus_message_enter_container(m, SD_BUS_TYPE_DICT_ENTRY, "sv")) { - while (sd_bus_message_read_basic(m, 's', &key) > 0) { - if (strcmp(key,"offset")) - sd_bus_message_skip(m, "v"); - else { - if (sd_bus_message_enter_container(m, SD_BUS_TYPE_VARIANT, "q")) { - sd_bus_message_read_basic(m, 'q', &offset); - sd_bus_message_exit_container(m); - return offset; - } - } - } - sd_bus_message_exit_container(m); - } - return 0; -} - -static int message_append_strings(sd_bus_message *m, const char **s) -{ - int rc = sd_bus_message_open_container(m, SD_BUS_TYPE_ARRAY, "s"); - while (rc >= 0 && *s) - rc = sd_bus_message_append_basic(m, 's', *s++); - if (rc >= 0) - rc = sd_bus_message_close_container(m); - return rc; -} - -/****** common callbacks ***********/ - -static int get_uuid( - struct sd_bus *bus, - const char *path, - const char *interface, - const char *property, - sd_bus_message *reply, - void *userdata, - sd_bus_error *ret_error) -{ - struct item *item = userdata; - return sd_bus_message_append_basic(reply, 's', item->uuid); -} - -static int get_parent( - struct sd_bus *bus, - const char *path, - const char *interface, - const char *property, - sd_bus_message *reply, - void *userdata, - sd_bus_error *ret_error) -{ - struct item *item = userdata; - return sd_bus_message_append_basic(reply, 'o', item->parent->path); -} - -static int get_children( - struct sd_bus *bus, - const char *path, - const char *interface, - const char *property, - sd_bus_message *reply, - void *userdata, - sd_bus_error *ret_error) -{ - size_t i, n; - int rc; - - rc = sd_bus_message_open_container(reply, SD_BUS_TYPE_ARRAY, "o"); - n = sizeof characteristics / sizeof *characteristics; - i = 0; - while (rc >= 0 && i < n) { - if (characteristics[i].parent == userdata) - rc = sd_bus_message_append_basic(reply, 'o', characteristics[i].path); - i++; - } - n = sizeof descriptors / sizeof *descriptors; - i = 0; - while (rc >= 0 && i < n) { - if (descriptors[i].parent == userdata) - rc = sd_bus_message_append_basic(reply, 'o', descriptors[i].path); - i++; - } - if (rc >= 0) - rc = sd_bus_message_close_container(reply); - return rc; -} - -static int read_value_offset( - struct item *item, - size_t offset, - sd_bus_message *reply) -{ - struct aia_uds_value *value = item->value; - const char *data = value ? value->data : NULL; - size_t size = !value ? 0 : value->length ? value->length : data ? strlen(data) : 0; - return sd_bus_message_append_array(reply, 'y', &data[offset], offset > size ? 0 : size - offset); -} - -static int read_value( - sd_bus_message *m, - void *userdata, - sd_bus_error *ret_error) -{ - int rc; - sd_bus_message *r; - - rc = sd_bus_message_new_method_return(m, &r); - rc = read_value_offset(userdata, get_offset(m), r); - rc = sd_bus_send(NULL, r, NULL); - return 1; -} - -static int write_value_offset( - struct item *item, - size_t offset, - const char *buffer, - size_t length) -{ - struct aia_uds_value *value = item->value; - const char *data = value ? value->data : NULL; - size_t size = !value ? 0 : value->length ? value->length : data ? strlen(data) : 0; - - - char *next = malloc(offset + length + 1); - if (!next) - return -ENOMEM; - if (offset) { - if (size >= offset) - memcpy(next, data, offset); - else { - memcpy(next, data, size); - memset(&next[size], 0, offset - size); - } - } - memcpy(&next[offset], buffer, length); - next[offset + length] = 0; - value->data = next; - value->length = offset + length; - free((char*)data); - - return 0; -} - -static int write_value( - sd_bus_message *m, - void *userdata, - sd_bus_error *ret_error) -{ - int rc; - struct item *item = userdata; - const void *data; - size_t size; - sd_bus_message *r; - - rc = sd_bus_message_read_array(m, 'y', &data, &size); - rc = write_value_offset(item, get_offset(m), data, size); - - rc = sd_bus_message_new_method_return(m, &r); - rc = sd_bus_send(NULL, r, NULL); - - sd_bus_emit_properties_changed(sd_bus_message_get_bus(m), item->path, ITF_CHARACTERISTIC, "Value", NULL); - - if (on_change_callback) { - item->value->changed = 1; - on_change_callback(&uds); - item->value->changed = 0; - } - - return 1; -} - -static int get_value( - struct sd_bus *bus, - const char *path, - const char *interface, - const char *property, - sd_bus_message *reply, - void *userdata, - sd_bus_error *ret_error) -{ - return read_value_offset(userdata, 0, reply); -} - -static int get_true( - struct sd_bus *bus, - const char *path, - const char *interface, - const char *property, - sd_bus_message *reply, - void *userdata, - sd_bus_error *ret_error) -{ - int v = 1; - return sd_bus_message_append_basic(reply, 'b', &v); -} - -static int get_false( - struct sd_bus *bus, - const char *path, - const char *interface, - const char *property, - sd_bus_message *reply, - void *userdata, - sd_bus_error *ret_error) -{ - int v = 0; - return sd_bus_message_append_basic(reply, 'b', &v); -} - -static int not_supported( - sd_bus_message *m, - void *userdata, - sd_bus_error *ret_error) -{ - return sd_bus_reply_method_errorf(m, "org.bluez.Error.NotSupported", "not supported"); -} - -static int not_permitted( - sd_bus_message *m, - void *userdata, - sd_bus_error *ret_error) -{ - return sd_bus_reply_method_errorf(m, "org.bluez.Error.NotPermitted", "not permitted"); -} - -static int failed( - sd_bus_message *m, - void *userdata, - sd_bus_error *ret_error) -{ - return sd_bus_reply_method_errorf(m, "org.bluez.Error.Failed", "failed"); -} - -/****** service's callbacks ***********/ - -static int get_srv_includes( - struct sd_bus *bus, - const char *path, - const char *interface, - const char *property, - sd_bus_message *reply, - void *userdata, - sd_bus_error *ret_error) -{ - int rc = sd_bus_message_open_container(reply, SD_BUS_TYPE_ARRAY, "o"); - if (rc >= 0) - rc = sd_bus_message_close_container(reply); - return rc; -} - -/****** characteristic's callbacks ***********/ - -static int get_char_flags( - struct sd_bus *bus, - const char *path, - const char *interface, - const char *property, - sd_bus_message *reply, - void *userdata, - sd_bus_error *ret_error) -{ - static const char *flags[] = { "read", "write", NULL }; - return message_append_strings(reply, flags); -} - -/****** descriptor's callbacks ***********/ - -static int get_desc_flags( - struct sd_bus *bus, - const char *path, - const char *interface, - const char *property, - sd_bus_message *reply, - void *userdata, - sd_bus_error *ret_error) -{ - static const char *flags[] = { "read", NULL }; - return message_append_strings(reply, flags); -} - -/****** description ***********/ - -static struct sd_bus_vtable vservice[] = { - SD_BUS_VTABLE_START(0), - - SD_BUS_PROPERTY("UUID", "s", get_uuid, 0, SD_BUS_VTABLE_PROPERTY_CONST), - SD_BUS_PROPERTY("Primary", "b", get_true, 0, SD_BUS_VTABLE_PROPERTY_CONST), - SD_BUS_PROPERTY("Includes", "ao", get_srv_includes, 0, SD_BUS_VTABLE_PROPERTY_CONST), - SD_BUS_PROPERTY("Characteristics", "ao", get_children, 0, SD_BUS_VTABLE_PROPERTY_CONST), - - SD_BUS_VTABLE_END -}; - - -static struct sd_bus_vtable vcharacteristic[] = { - SD_BUS_VTABLE_START(0), - - SD_BUS_METHOD("ReadValue", "a{sv}", "ay", read_value, 0), - SD_BUS_METHOD("WriteValue", "aya{sv}", "", write_value, 0), - SD_BUS_METHOD("StartNotify", "", "", not_supported, 0), - SD_BUS_METHOD("StopNotify", "", "", failed, 0), - - SD_BUS_PROPERTY("UUID", "s", get_uuid, 0, SD_BUS_VTABLE_PROPERTY_CONST), - SD_BUS_PROPERTY("Service", "o", get_parent, 0, SD_BUS_VTABLE_PROPERTY_CONST), - SD_BUS_PROPERTY("Value", "ay", get_value, 0, 0), - SD_BUS_PROPERTY("WriteAcquired", "b", get_false, 0, 0), - SD_BUS_PROPERTY("NotifyAcquired", "b", get_false, 0, 0), - SD_BUS_PROPERTY("Notifying", "b", get_false, 0, 0), - SD_BUS_PROPERTY("Flags", "as", get_char_flags, 0, 0), - SD_BUS_PROPERTY("Descriptors", "ao", get_children, 0, 0), - - SD_BUS_VTABLE_END -}; - - -static struct sd_bus_vtable vdescriptor[] = { - SD_BUS_VTABLE_START(0), - - SD_BUS_METHOD("ReadValue", "a{sv}", "ay", read_value, 0), - SD_BUS_METHOD("WriteValue", "aya{sv}", "", not_permitted, 0), - - SD_BUS_PROPERTY("UUID", "s", get_uuid, 0, SD_BUS_VTABLE_PROPERTY_CONST), - SD_BUS_PROPERTY("Characteristic", "o", get_parent, 0, SD_BUS_VTABLE_PROPERTY_CONST), - SD_BUS_PROPERTY("Value", "ay", get_value, 0, 0), - SD_BUS_PROPERTY("Flags", "as", get_desc_flags, 0, 0), - - SD_BUS_VTABLE_END -}; - - -/******** Integration ***************/ - -aia_uds_on_change aia_uds_set_on_change(aia_uds_on_change callback) -{ - aia_uds_on_change prev = on_change_callback; - on_change_callback = callback; - return prev; -} - -int aia_uds_init(struct sd_bus *bus) -{ - int rc; - - if (busini) - return 0; - - rc = sd_bus_add_object_manager(bus, NULL, ROOT); - - rc = sd_bus_add_object_vtable(bus, NULL, services[0].path, - ITF_SERVICE, vservice, &services[0]); - - rc = sd_bus_add_object_vtable(bus, NULL, characteristics[0].path, - ITF_CHARACTERISTIC, vcharacteristic, &characteristics[0]); - rc = sd_bus_add_object_vtable(bus, NULL, characteristics[1].path, - ITF_CHARACTERISTIC, vcharacteristic, &characteristics[1]); - rc = sd_bus_add_object_vtable(bus, NULL, characteristics[2].path, - ITF_CHARACTERISTIC, vcharacteristic, &characteristics[2]); - rc = sd_bus_add_object_vtable(bus, NULL, characteristics[3].path, - ITF_CHARACTERISTIC, vcharacteristic, &characteristics[3]); - - rc = sd_bus_add_object_vtable(bus, NULL, descriptors[0].path, - ITF_DESCRIPTOR, vdescriptor, &descriptors[0]); - rc = sd_bus_add_object_vtable(bus, NULL, descriptors[1].path, - ITF_DESCRIPTOR, vdescriptor, &descriptors[1]); - rc = sd_bus_add_object_vtable(bus, NULL, descriptors[2].path, - ITF_DESCRIPTOR, vdescriptor, &descriptors[2]); - rc = sd_bus_add_object_vtable(bus, NULL, descriptors[3].path, - ITF_DESCRIPTOR, vdescriptor, &descriptors[3]); - rc = sd_bus_add_object_vtable(bus, NULL, descriptors[4].path, - ITF_DESCRIPTOR, vdescriptor, &descriptors[4]); - rc = sd_bus_add_object_vtable(bus, NULL, descriptors[5].path, - ITF_DESCRIPTOR, vdescriptor, &descriptors[5]); - rc = sd_bus_add_object_vtable(bus, NULL, descriptors[6].path, - ITF_DESCRIPTOR, vdescriptor, &descriptors[6]); - rc = sd_bus_add_object_vtable(bus, NULL, descriptors[7].path, - ITF_DESCRIPTOR, vdescriptor, &descriptors[7]); - - busini = sd_bus_ref(bus); - return 0; -} - -struct cb { - void *callback; - void *closure; - int onoff; -}; - -static struct cb *alloccb(void *callback, void *closure, int onoff) -{ - struct cb *cb = malloc(sizeof *cb); - if (cb) { - cb->callback = callback; - cb->closure = closure; - } - return cb; -} - -static int register_uds_cb(sd_bus_message *m, void *userdata, sd_bus_error *ret_error) -{ - struct cb *cb = userdata; - void (*callback)(void *closure, int error, int state); - int iserr; - - iserr = sd_bus_message_is_method_error(m, NULL); - if (!iserr) - activation = cb->onoff; - callback = cb->callback; - if (callback) - callback(cb->closure, iserr, activation); - free(cb); - - return 1; -} - -static int register_uds(int onoff, void *data) -{ - int rc; - sd_bus_message *m; - - rc = sd_bus_message_new_method_call(busini, &m, "org.bluez", - "/org/bluez/hci0", "org.bluez.GattManager1", - onoff ? "RegisterApplication" : "UnregisterApplication" ); - rc = sd_bus_message_append_basic(m, 'o', ROOT); - if (onoff) { - rc = sd_bus_message_open_container(m, 'a', "{sv}"); - rc = sd_bus_message_close_container(m); - } - rc = sd_bus_call_async(busini, NULL, m, register_uds_cb, data, 5*1000*1000); - sd_bus_message_unref(m); - return rc; -} - -int aia_uds_activate(int onoff, void (*callback)(void *closure, int error, int state), void *closure) -{ - int rc; - struct cb *cb; - - if (!busini) - return -EINVAL; - - onoff = !!onoff; - if (activation == onoff) - return 0; - - cb = alloccb(callback, closure, onoff); - if (!cb) - return -ENOMEM; - - rc = register_uds(onoff, cb); - if (rc < 0) - free(cb); - - return rc < 0 ? rc : 1; -} - -int aia_uds_advise(int onoff, void (*callback)(void *closure, int error, int state), void *closure) -{ - return aia_uds_activate(onoff, callback, closure); -} - diff --git a/uds-ble-id-init-service/src/aia-uds-bluez.h b/uds-ble-id-init-service/src/aia-uds-bluez.h deleted file mode 100644 index 856da4e..0000000 --- a/uds-ble-id-init-service/src/aia-uds-bluez.h +++ /dev/null @@ -1,46 +0,0 @@ -/* - * Copyright (C) 2015, 2016, 2017 "IoT.bzh" - * Author: José Bollo <jose.bollo@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. - */ -#define _GNU_SOURCE - - -#pragma once - -struct aia_uds_value -{ - const char *data; - size_t length; - int changed; -}; - -struct aia_uds -{ - struct aia_uds_value first_name; - struct aia_uds_value last_name; - struct aia_uds_value email; - struct aia_uds_value language; -}; - -typedef void (*aia_uds_on_change)(const struct aia_uds *); - -extern aia_uds_on_change aia_uds_set_on_change(aia_uds_on_change callback); - -extern int aia_uds_activate(int onoff, void (*callback)(void *closure, int error, int state), void *closure); - -extern int aia_uds_advise(int onoff, void (*callback)(void *closure, int error, int state), void *closure); - -extern int aia_uds_init(struct sd_bus *bus); - diff --git a/uds-ble-id-init-service/src/uds-ble-id-init-service.c b/uds-ble-id-init-service/src/uds-ble-id-init-service.c deleted file mode 100644 index f887963..0000000 --- a/uds-ble-id-init-service/src/uds-ble-id-init-service.c +++ /dev/null @@ -1,146 +0,0 @@ -/* - * Copyright (C) 2015, 2016, 2017 "IoT.bzh" - * Author: José Bollo <jose.bollo@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. - */ -#define _GNU_SOURCE - -#include <errno.h> -#include <stdint.h> -#include <unistd.h> -#include <stdlib.h> -#include <string.h> -#include <fcntl.h> -#include <sys/types.h> -#include <sys/stat.h> - -#include <json-c/json.h> -#include <systemd/sd-bus.h> - -#define AFB_BINDING_VERSION 2 -#include <afb/afb-binding.h> - -#include "aia-uds-bluez.h" - -#if !defined(AUTO_START_ADVISE) -#define AUTO_START_ADVISE 1 -#endif - -static int advising; - -static struct afb_event event; - -static int autoadvise = AUTO_START_ADVISE; - -/****************************************************************/ - -static void on_uds_change(const struct aia_uds *uds) -{ - struct json_object *object; - - AFB_INFO("UDS changed" - " first-name%s[%.*s]" - " last-name%s[%.*s]" - " email%s[%.*s]" - " language%s[%.*s]", - uds->first_name.changed ? "*" : "", (int)uds->first_name.length, uds->first_name.data ?:"", - uds->last_name.changed ? "*" : "", (int)uds->last_name.length, uds->last_name.data ?:"", - uds->email.changed ? "*" : "", (int)uds->email.length, uds->email.data ?:"", - uds->language.changed ? "*" : "", (int)uds->language.length, uds->language.data ?:""); - - if (uds->email.changed) { - object = json_object_new_object(); - json_object_object_add(object, "incoming", json_object_new_string(uds->email.data)); - afb_event_push(event, object); - } -} - -static void start (struct afb_req request) -{ - int rc; - - if (!advising) { - rc = aia_uds_advise(1, NULL, NULL); - if (rc < 0) { -/* -TODO: solve the issue - afb_req_fail(request, "failed", "start scan failed"); - return; -*/ - AFB_ERROR("Ignoring scan start failed, because probably already in progress"); - } - } - advising = advising + 1; - afb_req_subscribe(request, event); - afb_req_success(request, NULL, NULL); -} - - -static void stop (struct afb_req request) -{ - if (advising) { - advising = advising - 1; - if (!advising) - aia_uds_advise(0, NULL, NULL); - } - afb_req_success(request, NULL, NULL); -} - -static int init() -{ - sd_bus *bus; - int rc; - - bus = afb_daemon_get_system_bus(); - rc = bus ? aia_uds_init(bus) : -ENOTSUP; - if (rc < 0) { - errno = -rc; - return -1; - } - - aia_uds_set_on_change(on_uds_change); - - event = afb_daemon_make_event("event"); - if (!afb_event_is_valid(event)) - return -1; - - rc = aia_uds_advise(autoadvise, NULL, NULL); - advising = autoadvise && rc >= 0; - return rc < 0 ? rc : 0; -} - - -// NOTE: this sample does not use session to keep test a basic as possible -// in real application most APIs should be protected with AFB_SESSION_CHECK -static const struct afb_verb_v2 verbs[]= -{ - {"start" , start, NULL, "start User Data Service", AFB_SESSION_NONE }, - {"stop" , stop , NULL, "stop User Data Service" , AFB_SESSION_NONE }, - {NULL} -}; - -const struct afb_binding_v2 afbBindingV2 = -{ - .api = "uds-ble-init-id", - .specification = NULL, - .info = "AGL Identitity initiator above BLE's User Data Service", - .verbs = verbs, - .preinit = NULL, - .init = init, - .onevent = NULL, - .noconcurrency = 1 -}; - -/* vim: set colorcolumn=80: */ - |