summaryrefslogtreecommitdiffstats
path: root/signal-composer-binding/signal-composer.cpp
diff options
context:
space:
mode:
authorRomain Forlot <romain.forlot@iot.bzh>2017-09-17 19:20:40 +0200
committerRomain Forlot <romain.forlot@iot.bzh>2017-12-14 11:00:25 +0100
commit12097251ec058b1fa9d9202998c829b27ee5554f (patch)
tree415d2592913bfa0b980232ffbee09d6cfb48fd02 /signal-composer-binding/signal-composer.cpp
parent5bbc6cb56995d23cb8a4eb584ef0161be092da1f (diff)
Get CPP controller plugin works
Context passing variables not working well Change-Id: Ibc67bef353e5cc2e53ef9e5579d106baab92a604 Signed-off-by: Romain Forlot <romain.forlot@iot.bzh>
Diffstat (limited to 'signal-composer-binding/signal-composer.cpp')
-rw-r--r--signal-composer-binding/signal-composer.cpp40
1 files changed, 33 insertions, 7 deletions
diff --git a/signal-composer-binding/signal-composer.cpp b/signal-composer-binding/signal-composer.cpp
index 9288e56..8ad8c3b 100644
--- a/signal-composer-binding/signal-composer.cpp
+++ b/signal-composer-binding/signal-composer.cpp
@@ -22,7 +22,7 @@
CtlSectionT bindingApp::ctlSections_[] = {
[0]={.key="plugins" ,.label = "plugins", .info=nullptr,
.loadCB=PluginConfig,
- .handle=nullptr},
+ .handle=&bindingApp::instance()},
[1]={.key="sources" ,.label = "sources", .info=nullptr,
.loadCB=loadSourcesAPI,
.handle=nullptr},
@@ -363,17 +363,43 @@ json_object* bindingApp::getSignalValue(const std::string& sig, json_object* opt
if (strcasestr(opts[idx], "last") && !last)
{
last = true;
- double value = sigP->last();
- json_object_object_add(response, "last",
- json_object_new_double(value));
+ struct SignalValue value = sigP->last();
+ if(value.hasBool)
+ {
+ json_object_object_add(response, "last",
+ json_object_new_boolean(value.boolVal));
+ }
+ if(value.hasNum)
+ {
+ json_object_object_add(response, "last",
+ json_object_new_double(value.numVal));
+ }
+ if(value.hasStr)
+ {
+ json_object_object_add(response, "last",
+ json_object_new_string(value.strVal.c_str()));
+ }
}
}
if (!opts)
{
- double value = sigP->last();
- json_object_object_add(response, "last",
- json_object_new_double(value));
+ struct SignalValue value = sigP->last();
+ if(value.hasBool)
+ {
+ json_object_object_add(response, "last",
+ json_object_new_boolean(value.boolVal));
+ }
+ if(value.hasNum)
+ {
+ json_object_object_add(response, "last",
+ json_object_new_double(value.numVal));
+ }
+ if(value.hasStr)
+ {
+ json_object_object_add(response, "last",
+ json_object_new_string(value.strVal.c_str()));
+ }
}
return response;