aboutsummaryrefslogtreecommitdiffstats
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
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>
-rw-r--r--conf.d/project/lua.d/signal-composer-daemon-04-oncall.lua9
-rw-r--r--plugins/builtin.cpp21
-rw-r--r--plugins/gps.c2
-rw-r--r--plugins/low-can.cpp6
-rw-r--r--signal-composer-binding/signal-composer.cpp2
5 files changed, 15 insertions, 25 deletions
diff --git a/conf.d/project/lua.d/signal-composer-daemon-04-oncall.lua b/conf.d/project/lua.d/signal-composer-daemon-04-oncall.lua
index 21f516a..0295b6d 100644
--- a/conf.d/project/lua.d/signal-composer-daemon-04-oncall.lua
+++ b/conf.d/project/lua.d/signal-composer-daemon-04-oncall.lua
@@ -50,8 +50,6 @@ function _Unit_Converter(source, args, event)
end
event["value"] = value/base
- _lua2c['setSignalValueWrap'](source, event)
-
elseif sourcei>targeti then
local base=1
@@ -60,12 +58,13 @@ function _Unit_Converter(source, args, event)
end
event["value"] = value/base
-
- _lua2c["setSignalValueWrap"](source, event)
-
else
print("No conversion")
end
+
+ print('Converted value is: '.. event['value'] .. args["to"])
+
+ _lua2c['setSignalValueWrap'](source, event)
end
-- Display receive arguments and echo them to caller
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 {
diff --git a/signal-composer-binding/signal-composer.cpp b/signal-composer-binding/signal-composer.cpp
index e6a2963..7ba9c27 100644
--- a/signal-composer-binding/signal-composer.cpp
+++ b/signal-composer-binding/signal-composer.cpp
@@ -313,7 +313,7 @@ int Composer::loadOneSourceAPI(json_object* sourceJ)
if(ctlConfig_ && ctlConfig_->requireJ)
{
const char* requireS = json_object_to_json_string(ctlConfig_->requireJ);
- if(!strcasestr(requireS, api))
+ if(!strcasestr(requireS, api) && !strcasestr(api, afbBindingV2.api))
{AFB_WARNING("Caution! You don't specify the API source as required in the metadata section. This API '%s' may not be initialized", api);}
}