summaryrefslogtreecommitdiffstats
path: root/plugins
diff options
context:
space:
mode:
authorRomain Forlot <romain.forlot@iot.bzh>2017-12-18 14:03:53 +0100
committerRomain Forlot <romain.forlot@iot.bzh>2017-12-18 14:03:53 +0100
commit9fe1a36ddfc85638958681dc3f929d47df117cd3 (patch)
tree1b92edbe82507692ec684297edd5b32b2cbf2c8e /plugins
parent41ea8b75daa57b1c7259bd42c7e5bc16f33b38ec (diff)
Several small fixes and improvements.
Cleaning Make some additionnals test avoiding segfault, Filling opitonnal response object to avoid warning Wrong plugins type register macro called Change-Id: I012cc3ddc5f89b75dbc46c3ea535717141823884 Signed-off-by: Romain Forlot <romain.forlot@iot.bzh>
Diffstat (limited to 'plugins')
-rw-r--r--plugins/builtin.cpp21
-rw-r--r--plugins/gps.c2
-rw-r--r--plugins/low-can.cpp6
3 files changed, 10 insertions, 19 deletions
diff --git a/plugins/builtin.cpp b/plugins/builtin.cpp
index ab85bb7..4f2d239 100644
--- a/plugins/builtin.cpp
+++ b/plugins/builtin.cpp
@@ -24,25 +24,12 @@
#include <string.h>
#include "signal-composer.hpp"
-#include "ctl-config.h"
#include "wrap-json.h"
extern "C"
{
CTLP_LUA_REGISTER("builtin");
-// Call at initialisation time
-/*CTLP_ONLOAD(plugin, handle) {
- pluginCtx = (struct signalCBT*)calloc (1, sizeof(struct signalCBT));
- pluginCtx = (struct signalCBT*)handle;
-
- AFB_NOTICE ("Signal Composer builtin plugin: label='%s' info='%s'",
- plugin->uid,
- plugin->info);
-
- return (void*)pluginCtx;
-}*/
-
CTLP_CAPI (defaultOnReceived, source, argsJ, eventJ)
{
struct signalCBT* ctx = (struct signalCBT*)source->context;
@@ -81,9 +68,15 @@ CTLP_LUA2C (setSignalValueWrap, source, argsJ, responseJ)
*responseJ = json_object_new_string("Fail to unpack JSON arguments value");
return -1;
}
+ *responseJ = json_object_new_string(json_object_to_json_string(argsJ));
struct signalValue result = resultNum;
- ctx->setSignalValue(ctx->aSignal, timestamp*MICRO, result);
+
+ if(ctx->aSignal)
+ {ctx->setSignalValue(ctx->aSignal, timestamp*MICRO, result);}
+ else
+ {ctx->searchNsetSignalValue(name, timestamp*MICRO, result);}
+
return 0;
}
diff --git a/plugins/gps.c b/plugins/gps.c
index a4dfdba..af594fa 100644
--- a/plugins/gps.c
+++ b/plugins/gps.c
@@ -28,7 +28,7 @@
#include "ctl-plugin.h"
#include "wrap-json.h"
-CTLP_LUA_REGISTER("gps");
+CTLP_CAPI_REGISTER("gps");
// Call at initialisation time
/*CTLP_ONLOAD(plugin, api) {
diff --git a/plugins/low-can.cpp b/plugins/low-can.cpp
index 27089e1..5d4ef10 100644
--- a/plugins/low-can.cpp
+++ b/plugins/low-can.cpp
@@ -17,20 +17,18 @@
*/
#define AFB_BINDING_VERSION 2
+#define CTL_PLUGIN_MAGIC 1286576532
#include <afb/afb-binding.h>
#include <systemd/sd-event.h>
#include <json-c/json_object.h>
#include <stdbool.h>
#include <string.h>
-#include "ctl-plugin.h"
-#include "wrap-json.h"
-
#include "signal-composer.hpp"
+#include "wrap-json.h"
extern "C"
{
-
CTLP_CAPI_REGISTER("low-can");
typedef struct {