summaryrefslogtreecommitdiffstats
path: root/signal-composer-binding
diff options
context:
space:
mode:
authorRomain Forlot <romain.forlot@iot.bzh>2018-04-24 15:08:22 +0200
committerRomain Forlot <romain.forlot@iot.bzh>2018-07-05 15:43:09 +0200
commit27776f5a89ba71cb102e5c2e08b813025c55c663 (patch)
treeb345853eea5e436f6021d3dcdd01a587dcee3429 /signal-composer-binding
parent4e68c9f6d3b303dd326a42e69556b22e0fe88438 (diff)
Use signal subscription args if present
By default subscription argument request from signal are passed if present, else the one from the signal's source if present. If nothing is specified for sources then argument is set as a NULL pointer. Change-Id: I18db0a9922039f41d475cd08758a2afd4acaa9d4 Signed-off-by: Romain Forlot <romain.forlot@iot.bzh>
Diffstat (limited to 'signal-composer-binding')
-rw-r--r--signal-composer-binding/signal.cpp8
-rw-r--r--signal-composer-binding/signal.hpp1
-rw-r--r--signal-composer-binding/source.cpp10
3 files changed, 16 insertions, 3 deletions
diff --git a/signal-composer-binding/signal.cpp b/signal-composer-binding/signal.cpp
index 84be8a7..d10dda6 100644
--- a/signal-composer-binding/signal.cpp
+++ b/signal-composer-binding/signal.cpp
@@ -178,6 +178,14 @@ struct signalCBT* Signal::get_context()
return &signalCtx_;
}
+/// @brief Accessor to getSignalsArgs_ json_object member
+///
+/// @return a pointer the json_object getSignalsArgs_ private member
+json_object *Signal::getSignalsArgs()
+{
+ return getSignalsArgs_;
+}
+
/// @brief Set Signal timestamp and value property when an incoming
/// signal arrived. Called by a plugin because treatment can't be
/// standard as signals sources format could changes. See low-can plugin
diff --git a/signal-composer-binding/signal.hpp b/signal-composer-binding/signal.hpp
index 5b35065..c825b37 100644
--- a/signal-composer-binding/signal.hpp
+++ b/signal-composer-binding/signal.hpp
@@ -103,6 +103,7 @@ public:
const std::string id() const;
json_object* toJSON() const;
struct signalCBT* get_context();
+ json_object *getSignalsArgs();
void set(uint64_t timestamp, struct signalValue& value);
void update(Signal* sig);
diff --git a/signal-composer-binding/source.cpp b/signal-composer-binding/source.cpp
index f34b88f..6832320 100644
--- a/signal-composer-binding/source.cpp
+++ b/signal-composer-binding/source.cpp
@@ -149,6 +149,7 @@ void SourceAPI::makeSubscription()
source.uid = api_.c_str();
source.api = nullptr; // We use binding v2, no dynamic API.
source.request = {nullptr, nullptr};
+ json_object *argsSaveJ = getSignals_->argsJ;
for(auto& sig: signalsM_)
{
@@ -162,15 +163,18 @@ void SourceAPI::makeSubscription()
}
source.uid = sig.first.c_str();
source.context = getSignals_->type == CTL_TYPE_CB ?
- getSignals_->exec.cb.plugin->context:
+ getSignals_->exec.cb.plugin->context :
nullptr;
+ getSignals_->argsJ = sig.second->getSignalsArgs() ?
+ sig.second->getSignalsArgs() :
+ argsSaveJ;
ActionExecOne(&source, getSignals_, signalJ);
// Considerate signal subscribed no matter what
sig.second->subscribed_ = true;
- json_object_put(signalJ);
}
}
- source.uid = "";
+ getSignals_->argsJ = argsSaveJ;
+ source.uid = uid_.c_str();
ActionExecOne(&source, getSignals_, nullptr);
}
}