aboutsummaryrefslogtreecommitdiffstats
path: root/plugins
diff options
context:
space:
mode:
authorRomain Forlot <romain.forlot@iot.bzh>2017-11-02 15:58:45 +0100
committerRomain Forlot <romain.forlot@iot.bzh>2017-12-14 11:00:25 +0100
commit6ee4db6878464642ddf9f0909748841a45b58a88 (patch)
tree4c3588d216e903174f1281b757e98816d7323afa /plugins
parented2c3d0267e3c5e1392635dacad2752de935d6b4 (diff)
Migrate to ctl-utilities library
New version of controller as a library. Loading additionnals files from each sections. Change-Id: I4f5e78d0baf9650cb8d1cc1da26f8e1fd73b792c Signed-off-by: Romain Forlot <romain.forlot@iot.bzh>
Diffstat (limited to 'plugins')
-rw-r--r--plugins/CMakeLists.txt6
-rw-r--r--plugins/builtin.cpp17
-rw-r--r--plugins/gps.c6
-rw-r--r--plugins/low-can.cpp13
4 files changed, 19 insertions, 23 deletions
diff --git a/plugins/CMakeLists.txt b/plugins/CMakeLists.txt
index 1776cf9..b6eec08 100644
--- a/plugins/CMakeLists.txt
+++ b/plugins/CMakeLists.txt
@@ -35,7 +35,7 @@ PROJECT_TARGET_ADD(builtin)
)
target_include_directories(${TARGET_NAME}
- PRIVATE "../controller"
+ PRIVATE "../ctl-utilities/ctl-lib"
PRIVATE "../signal-composer-binding")
PROJECT_TARGET_ADD(low-can)
@@ -57,7 +57,7 @@ PROJECT_TARGET_ADD(low-can)
)
target_include_directories(${TARGET_NAME}
- PRIVATE "../controller"
+ PRIVATE "../ctl-utilities/ctl-lib"
PRIVATE "../signal-composer-binding")
PROJECT_TARGET_ADD(gps)
@@ -79,5 +79,5 @@ PROJECT_TARGET_ADD(gps)
)
target_include_directories(${TARGET_NAME}
- PRIVATE "../controller"
+ PRIVATE "../ctl-utilities/ctl-lib"
PRIVATE "../signal-composer-binding")
diff --git a/plugins/builtin.cpp b/plugins/builtin.cpp
index e93d929..df6ba88 100644
--- a/plugins/builtin.cpp
+++ b/plugins/builtin.cpp
@@ -29,9 +29,7 @@
extern "C"
{
-
-CTLP_LUALOAD
-CTLP_REGISTER("builtin");
+CTLP_LUA_REGISTER("builtin");
static struct signalCBT* pluginCtx = NULL;
@@ -40,18 +38,17 @@ CTLP_ONLOAD(plugin, handle) {
pluginCtx = (struct signalCBT*)calloc (1, sizeof(struct signalCBT));
pluginCtx = (struct signalCBT*)handle;
- AFB_NOTICE ("Low-can plugin: label='%s' version='%s' info='%s'",
- plugin->label,
- plugin->version,
+ AFB_NOTICE ("Low-can plugin: label='%s' info='%s'",
+ plugin->uid,
plugin->info);
return (void*)pluginCtx;
}
-CTLP_CAPI (defaultOnReceived, source, argsJ, eventJ, context)
+CTLP_CAPI (defaultOnReceived, source, argsJ, eventJ)
{
struct signalCBT* ctx = (struct signalCBT*)source->context;
- AFB_NOTICE("source: %s argj: %s, eventJ %s", source->label,
+ AFB_NOTICE("source: %s argj: %s, eventJ %s", source->uid,
json_object_to_json_string(argsJ),
json_object_to_json_string(eventJ));
void* sig = ctx->aSignal;
@@ -70,7 +67,7 @@ CTLP_CAPI (defaultOnReceived, source, argsJ, eventJ, context)
return 0;
}
-CTLP_LUA2C (setSignalValueWrap, label, argsJ)
+CTLP_LUA2C (setSignalValueWrap, source, argsJ, responseJ)
{
const char* name = nullptr;
double resultNum;
@@ -80,7 +77,7 @@ CTLP_LUA2C (setSignalValueWrap, label, argsJ)
"value", &resultNum,
"timestamp", &timestamp))
{
- AFB_ERROR("Fail to set value for label: %s, argsJ: %s", label, json_object_to_json_string(argsJ));
+ AFB_ERROR("Fail to set value for uid: %s, argsJ: %s", source->uid, json_object_to_json_string(argsJ));
return -1;
}
struct signalValue result = resultNum;
diff --git a/plugins/gps.c b/plugins/gps.c
index 39b1f49..2aab040 100644
--- a/plugins/gps.c
+++ b/plugins/gps.c
@@ -28,15 +28,15 @@
#include "ctl-plugin.h"
#include "wrap-json.h"
-CTLP_REGISTER("gps");
+CTLP_LUA_REGISTER("gps");
// Call at initialisation time
CTLP_ONLOAD(plugin, api) {
- AFB_NOTICE ("GPS plugin: label='%s' version='%s' info='%s'", plugin->label, plugin->version, plugin->info);
+ AFB_NOTICE ("GPS plugin: uid='%s' 'info='%s'", plugin->uid, plugin->info);
return api;
}
-CTLP_CAPI (subscribeToLow, source, argsJ, eventJ, context) {
+CTLP_CAPI (subscribeToLow, source, argsJ, eventJ) {
json_object* subscribeArgsJ = NULL, *responseJ = NULL;
int err = 0;
diff --git a/plugins/low-can.cpp b/plugins/low-can.cpp
index a425296..8d09eda 100644
--- a/plugins/low-can.cpp
+++ b/plugins/low-can.cpp
@@ -31,7 +31,7 @@
extern "C"
{
-CTLP_REGISTER("low-can");
+CTLP_CAPI_REGISTER("low-can");
typedef struct {
bool door;
@@ -66,15 +66,14 @@ CTLP_ONLOAD(plugin, composerHandle)
pluginCtx->pluginHandle = (struct signalCBT*)composerHandle;
pluginCtx->subscriptionBatch = json_object_new_array();
- AFB_NOTICE ("Low-can plugin: label='%s' version='%s' info='%s'",
- plugin->label,
- plugin->version,
+ AFB_NOTICE ("Low-can plugin: label='%s' info='%s'",
+ plugin->uid,
plugin->info);
return (void*)pluginCtx;
}
-CTLP_CAPI (subscribeToLow, source, argsJ, eventJ, context) {
+CTLP_CAPI (subscribeToLow, source, argsJ, eventJ) {
lowCANCtxT *pluginCtx = (lowCANCtxT*)source->context;
json_object* dependsArrayJ = nullptr, *subscribeArgsJ = nullptr, *subscribeFilterJ = nullptr, *responseJ = nullptr, *filterJ = nullptr;
const char *id = nullptr, *event = nullptr, *unit = nullptr;
@@ -125,7 +124,7 @@ CTLP_CAPI (subscribeToLow, source, argsJ, eventJ, context) {
return err;
}
-CTLP_CAPI (isOpen, source, argsJ, eventJ, context) {
+CTLP_CAPI (isOpen, source, argsJ, eventJ) {
const char *eventName = nullptr;
int eventStatus;
uint64_t timestamp;
@@ -168,7 +167,7 @@ CTLP_CAPI (isOpen, source, argsJ, eventJ, context) {
}
AFB_DEBUG("This is the situation: source:%s, args:%s, event:%s,\n fld: %s, flw: %s, frd: %s, frw: %s, rld: %s, rlw: %s, rrd: %s, rrw: %s",
- source->label,
+ source->uid,
json_object_to_json_string(argsJ),
json_object_to_json_string(eventJ),
pluginCtx->allDoorsCtx.front_left.door ? "true":"false",