summaryrefslogtreecommitdiffstats
path: root/plugins/builtin.cpp
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/builtin.cpp
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/builtin.cpp')
-rw-r--r--plugins/builtin.cpp21
1 files changed, 7 insertions, 14 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;
}