From 12cb9d534fca1eb57f93462900f305a148fd3f16 Mon Sep 17 00:00:00 2001 From: Romain Forlot Date: Thu, 14 Dec 2017 23:20:41 +0100 Subject: Get back on track l2c functions Adjust to the new controller behavior lua2c functions calls Change-Id: I52d385101d5205a2dd2c996810feccb1f00c20c7 Signed-off-by: Romain Forlot --- plugins/builtin.cpp | 10 ++++++---- 1 file changed, 6 insertions(+), 4 deletions(-) (limited to 'plugins') diff --git a/plugins/builtin.cpp b/plugins/builtin.cpp index 0989935..ab85bb7 100644 --- a/plugins/builtin.cpp +++ b/plugins/builtin.cpp @@ -31,8 +31,6 @@ extern "C" { CTLP_LUA_REGISTER("builtin"); -static struct signalCBT* pluginCtx = NULL; - // Call at initialisation time /*CTLP_ONLOAD(plugin, handle) { pluginCtx = (struct signalCBT*)calloc (1, sizeof(struct signalCBT)); @@ -72,16 +70,20 @@ CTLP_LUA2C (setSignalValueWrap, source, argsJ, responseJ) const char* name = nullptr; double resultNum; uint64_t timestamp; + + struct signalCBT* ctx = (struct signalCBT*)source->context; + if(! wrap_json_unpack(argsJ, "{ss, sF, sI? !}", "name", &name, "value", &resultNum, "timestamp", ×tamp)) { - AFB_ERROR("Fail to set value for uid: %s, argsJ: %s", source->uid, json_object_to_json_string(argsJ)); + *responseJ = json_object_new_string("Fail to unpack JSON arguments value"); return -1; } + struct signalValue result = resultNum; - pluginCtx->searchNsetSignalValue(name, timestamp*MICRO, result); + ctx->setSignalValue(ctx->aSignal, timestamp*MICRO, result); return 0; } -- cgit 1.2.3-korg