From 42cd0f2e981a53faf45d0eb45a419b5e570afb5c Mon Sep 17 00:00:00 2001 From: Romain Forlot Date: Thu, 4 Jan 2018 11:31:03 +0100 Subject: Remove lua dependency and rename to high-viwi And upgrade submodules Change-Id: I19dd52da56280afa0725f0a9a96efb20ad02812e Signed-off-by: Romain Forlot --- afb-utilities | 1 + conf.d/app-templates | 2 +- conf.d/autobuild/agl/autobuild | 28 +++++++++-- conf.d/autobuild/linux/autobuild | 28 +++++++++-- conf.d/cmake/00-debian-specific.cmake | 3 -- conf.d/cmake/00-default-osconfig.cmake | 1 - high-can-binding/CMakeLists.txt | 6 --- high-can-binding/high-can-binding-hat.cpp | 36 --------------- high-can-binding/high-can-binding-hat.hpp | 15 ------ high-can-binding/high-can-binding.cpp | 74 ------------------------------ high-can-binding/high-viwi-binding-hat.cpp | 36 +++++++++++++++ high-can-binding/high-viwi-binding-hat.hpp | 15 ++++++ high-can-binding/high-viwi-binding.cpp | 74 ++++++++++++++++++++++++++++++ 13 files changed, 175 insertions(+), 144 deletions(-) create mode 160000 afb-utilities delete mode 100644 conf.d/cmake/00-debian-specific.cmake delete mode 100644 conf.d/cmake/00-default-osconfig.cmake delete mode 100644 high-can-binding/high-can-binding-hat.cpp delete mode 100644 high-can-binding/high-can-binding-hat.hpp delete mode 100644 high-can-binding/high-can-binding.cpp create mode 100644 high-can-binding/high-viwi-binding-hat.cpp create mode 100644 high-can-binding/high-viwi-binding-hat.hpp create mode 100644 high-can-binding/high-viwi-binding.cpp diff --git a/afb-utilities b/afb-utilities new file mode 160000 index 0000000..c98436f --- /dev/null +++ b/afb-utilities @@ -0,0 +1 @@ +Subproject commit c98436f85a94d621ef7236b0f32360437fcf4abf diff --git a/conf.d/app-templates b/conf.d/app-templates index e9a682f..bb3c541 160000 --- a/conf.d/app-templates +++ b/conf.d/app-templates @@ -1 +1 @@ -Subproject commit e9a682f1c694eec242c3cebccc09380f621ade0b +Subproject commit bb3c5413dd0e2ff098a99748a53be1c66186f235 diff --git a/conf.d/autobuild/agl/autobuild b/conf.d/autobuild/agl/autobuild index 31e29f7..3a1ba5f 100755 --- a/conf.d/autobuild/agl/autobuild +++ b/conf.d/autobuild/agl/autobuild @@ -16,10 +16,28 @@ THISFILE := $(lastword $(MAKEFILE_LIST)) BUILD_DIR := $(abspath $(dir $(THISFILE)/../../../../..)/build) +DEST := ${BUILD_DIR}/target -.PHONY: all clean distclean configure build package +.PHONY: all clean distclean configure build package help update -all: build +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 @@ -38,9 +56,11 @@ package: build @mkdir -p ${BUILD_DIR}/$@/lib @mkdir -p ${BUILD_DIR}/$@/htdocs @mkdir -p ${BUILD_DIR}/$@/data - @[ "${DEST}" ] && mkdir -p ${DEST} @cmake --build ${BUILD_DIR} --target widget - @[ "${DEST}" ] && cp ${BUILD_DIR}/*wgt ${DEST} + @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} diff --git a/conf.d/autobuild/linux/autobuild b/conf.d/autobuild/linux/autobuild index 31e29f7..3a1ba5f 100755 --- a/conf.d/autobuild/linux/autobuild +++ b/conf.d/autobuild/linux/autobuild @@ -16,10 +16,28 @@ THISFILE := $(lastword $(MAKEFILE_LIST)) BUILD_DIR := $(abspath $(dir $(THISFILE)/../../../../..)/build) +DEST := ${BUILD_DIR}/target -.PHONY: all clean distclean configure build package +.PHONY: all clean distclean configure build package help update -all: build +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 @@ -38,9 +56,11 @@ package: build @mkdir -p ${BUILD_DIR}/$@/lib @mkdir -p ${BUILD_DIR}/$@/htdocs @mkdir -p ${BUILD_DIR}/$@/data - @[ "${DEST}" ] && mkdir -p ${DEST} @cmake --build ${BUILD_DIR} --target widget - @[ "${DEST}" ] && cp ${BUILD_DIR}/*wgt ${DEST} + @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} diff --git a/conf.d/cmake/00-debian-specific.cmake b/conf.d/cmake/00-debian-specific.cmake deleted file mode 100644 index dbdcdca..0000000 --- a/conf.d/cmake/00-debian-specific.cmake +++ /dev/null @@ -1,3 +0,0 @@ -list(APPEND PKG_REQUIRED_LIST lua-5.3>=5.3) -set (EXTRA_REQUIRED_LIST lua5.3) -set(LUA_CHECKER "luac5.3" "-p" CACHE STRING "LUA compiler") diff --git a/conf.d/cmake/00-default-osconfig.cmake b/conf.d/cmake/00-default-osconfig.cmake deleted file mode 100644 index a2b9325..0000000 --- a/conf.d/cmake/00-default-osconfig.cmake +++ /dev/null @@ -1 +0,0 @@ -list(APPEND PKG_REQUIRED_LIST lua>=5.3) diff --git a/high-can-binding/CMakeLists.txt b/high-can-binding/CMakeLists.txt index f8f1dc3..127f461 100644 --- a/high-can-binding/CMakeLists.txt +++ b/high-can-binding/CMakeLists.txt @@ -35,9 +35,3 @@ PROJECT_TARGET_ADD(high-viwi) TARGET_LINK_LIBRARIES(${TARGET_NAME} ${link_libraries} ) - - # installation directory - INSTALL(TARGETS ${TARGET_NAME} - LIBRARY DESTINATION ${BINDINGS_INSTALL_DIR}) - - #build_widget("BINDING") diff --git a/high-can-binding/high-can-binding-hat.cpp b/high-can-binding/high-can-binding-hat.cpp deleted file mode 100644 index 6376cf0..0000000 --- a/high-can-binding/high-can-binding-hat.cpp +++ /dev/null @@ -1,36 +0,0 @@ -#include "high-viwi-binding-hat.hpp" -#include -/// Interface between the daemon and the binding - -static int init_service(); - -static const struct afb_verb_v2 verbs[]= -{ - { .verb= "subscribe", .callback= subscribe, .auth = NULL, .info = "subscribe to an ViWi object", .session = 0 }, - { .verb= "unsubscribe", .callback= unsubscribe, .auth = NULL, .info = "unsubscribe to a ViWi object", .session = 0 }, - { .verb= "get", .callback= get, .auth = NULL, .info = "Get informations about a resource or element", .session = 0 }, - { .verb= NULL, .callback=NULL, .auth = NULL, .info = NULL, .session = 0 } -}; - -const struct afb_binding_v2 afbBindingV2 = { - .api = "high-viwi", - .specification = "", - .info = "High CAN ViWi API connected to low-can AGL service", - .verbs = verbs, - .preinit = NULL, - .init = init_service, - .onevent = onEvent, - .noconcurrency = 1 -}; - -/// @brief Initialize the binding. -/// -/// @return Exit code, zero if success. -int init_service() -{ - AFB_NOTICE("high level binding is initializing"); - afb_daemon_require_api("low-can", 1); - initHigh(); - AFB_NOTICE("high level binding is initialized and running"); - return 0; -} diff --git a/high-can-binding/high-can-binding-hat.hpp b/high-can-binding/high-can-binding-hat.hpp deleted file mode 100644 index 28e8306..0000000 --- a/high-can-binding/high-can-binding-hat.hpp +++ /dev/null @@ -1,15 +0,0 @@ -#pragma once -#include -#include -extern "C" -{ - #define AFB_BINDING_VERSION 2 - #include -}; - - void onEvent(const char *event, struct json_object *object); - void subscribe(afb_req request); - void unsubscribe(afb_req request); - void get(afb_req request); - void initHigh(); - int ticked(sd_event_source *source, uint64_t t, void *data); diff --git a/high-can-binding/high-can-binding.cpp b/high-can-binding/high-can-binding.cpp deleted file mode 100644 index 2ded902..0000000 --- a/high-can-binding/high-can-binding.cpp +++ /dev/null @@ -1,74 +0,0 @@ -/* - * Copyright (C) 2015, 2016 "IoT.bzh" - * Author "Romain Forlot" - * Author "Loic Collignon" - * - * 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 "high-viwi-binding-hat.hpp" -#include -#include "high.hpp" -High high; - -/// @brief callback for receiving message from low binding. Treatment itself is made in High class. -void onEvent(const char *event, json_object *object) -{ - high.treatMessage(object); -} -/// @brief entry point for client subscription request. Treatment itself is made in High class. -void subscribe(afb_req request) -{ - if(high.subscribe(request)) - afb_req_success(request, NULL, NULL); - else - afb_req_fail(request, "error", NULL); -} - -/// @brief entry point for client un-subscription request. Treatment itself is made in High class. -void unsubscribe(afb_req request) -{ - if(high.unsubscribe(request)) - afb_req_success(request, NULL, NULL); - else - afb_req_fail(request, "error", NULL); -} - -/// @brief entry point for get requests. Treatment itself is made in High class. -void get(afb_req request) -{ - json_object *jobj; - if(high.get(request, &jobj)) { - afb_req_success(request, jobj, NULL); - } else { - afb_req_fail(request, "error", NULL); - } -} - -/// @brief entry point for systemD timers. Treatment itself is made in High class. -/// @param[in] source: systemD timer, t: time of tick, data: interval (ms). -int ticked(sd_event_source *source, uint64_t t, void* data) -{ - high.tick(source, t, data); - return 0; -} - -/// @brief Initialize the binding. -/// -/// @param[in] service Structure which represent the Application Framework Binder. -void initHigh() -{ - high.parseConfigAndSubscribe(); -} - - diff --git a/high-can-binding/high-viwi-binding-hat.cpp b/high-can-binding/high-viwi-binding-hat.cpp new file mode 100644 index 0000000..6376cf0 --- /dev/null +++ b/high-can-binding/high-viwi-binding-hat.cpp @@ -0,0 +1,36 @@ +#include "high-viwi-binding-hat.hpp" +#include +/// Interface between the daemon and the binding + +static int init_service(); + +static const struct afb_verb_v2 verbs[]= +{ + { .verb= "subscribe", .callback= subscribe, .auth = NULL, .info = "subscribe to an ViWi object", .session = 0 }, + { .verb= "unsubscribe", .callback= unsubscribe, .auth = NULL, .info = "unsubscribe to a ViWi object", .session = 0 }, + { .verb= "get", .callback= get, .auth = NULL, .info = "Get informations about a resource or element", .session = 0 }, + { .verb= NULL, .callback=NULL, .auth = NULL, .info = NULL, .session = 0 } +}; + +const struct afb_binding_v2 afbBindingV2 = { + .api = "high-viwi", + .specification = "", + .info = "High CAN ViWi API connected to low-can AGL service", + .verbs = verbs, + .preinit = NULL, + .init = init_service, + .onevent = onEvent, + .noconcurrency = 1 +}; + +/// @brief Initialize the binding. +/// +/// @return Exit code, zero if success. +int init_service() +{ + AFB_NOTICE("high level binding is initializing"); + afb_daemon_require_api("low-can", 1); + initHigh(); + AFB_NOTICE("high level binding is initialized and running"); + return 0; +} diff --git a/high-can-binding/high-viwi-binding-hat.hpp b/high-can-binding/high-viwi-binding-hat.hpp new file mode 100644 index 0000000..28e8306 --- /dev/null +++ b/high-can-binding/high-viwi-binding-hat.hpp @@ -0,0 +1,15 @@ +#pragma once +#include +#include +extern "C" +{ + #define AFB_BINDING_VERSION 2 + #include +}; + + void onEvent(const char *event, struct json_object *object); + void subscribe(afb_req request); + void unsubscribe(afb_req request); + void get(afb_req request); + void initHigh(); + int ticked(sd_event_source *source, uint64_t t, void *data); diff --git a/high-can-binding/high-viwi-binding.cpp b/high-can-binding/high-viwi-binding.cpp new file mode 100644 index 0000000..2ded902 --- /dev/null +++ b/high-can-binding/high-viwi-binding.cpp @@ -0,0 +1,74 @@ +/* + * Copyright (C) 2015, 2016 "IoT.bzh" + * Author "Romain Forlot" + * Author "Loic Collignon" + * + * 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 "high-viwi-binding-hat.hpp" +#include +#include "high.hpp" +High high; + +/// @brief callback for receiving message from low binding. Treatment itself is made in High class. +void onEvent(const char *event, json_object *object) +{ + high.treatMessage(object); +} +/// @brief entry point for client subscription request. Treatment itself is made in High class. +void subscribe(afb_req request) +{ + if(high.subscribe(request)) + afb_req_success(request, NULL, NULL); + else + afb_req_fail(request, "error", NULL); +} + +/// @brief entry point for client un-subscription request. Treatment itself is made in High class. +void unsubscribe(afb_req request) +{ + if(high.unsubscribe(request)) + afb_req_success(request, NULL, NULL); + else + afb_req_fail(request, "error", NULL); +} + +/// @brief entry point for get requests. Treatment itself is made in High class. +void get(afb_req request) +{ + json_object *jobj; + if(high.get(request, &jobj)) { + afb_req_success(request, jobj, NULL); + } else { + afb_req_fail(request, "error", NULL); + } +} + +/// @brief entry point for systemD timers. Treatment itself is made in High class. +/// @param[in] source: systemD timer, t: time of tick, data: interval (ms). +int ticked(sd_event_source *source, uint64_t t, void* data) +{ + high.tick(source, t, data); + return 0; +} + +/// @brief Initialize the binding. +/// +/// @param[in] service Structure which represent the Application Framework Binder. +void initHigh() +{ + high.parseConfigAndSubscribe(); +} + + -- cgit 1.2.3-korg