summaryrefslogtreecommitdiffstats
path: root/signal-composer-binding/signal-composer-binding.cpp
diff options
context:
space:
mode:
authorRomain Forlot <romain.forlot@iot.bzh>2017-09-14 19:31:42 +0200
committerRomain Forlot <romain.forlot@iot.bzh>2017-12-14 11:00:25 +0100
commiteabae24ea592420de46e36f0b1af5d39eee5b8a4 (patch)
tree16cbc39e84eb71d655add40e715f7d87b4b02132 /signal-composer-binding/signal-composer-binding.cpp
parent140fd3d8f76a8cbbde8f6b0bf997808855f3da43 (diff)
Attach and recursion check working
Change-Id: I2f9509d4b6aa63a16df8db2187810337fd802ef4 Signed-off-by: Romain Forlot <romain.forlot@iot.bzh>
Diffstat (limited to 'signal-composer-binding/signal-composer-binding.cpp')
-rw-r--r--signal-composer-binding/signal-composer-binding.cpp23
1 files changed, 17 insertions, 6 deletions
diff --git a/signal-composer-binding/signal-composer-binding.cpp b/signal-composer-binding/signal-composer-binding.cpp
index 90401f2..860de07 100644
--- a/signal-composer-binding/signal-composer-binding.cpp
+++ b/signal-composer-binding/signal-composer-binding.cpp
@@ -15,6 +15,7 @@
* limitations under the License.
*/
+#include <string>
#include <string.h>
// afb-utilities
#include <wrap-json.h>
@@ -29,6 +30,14 @@
/// @brief callback for receiving message from low binding. Treatment itself is made in SigComp class.
void onEvent(const char *event, json_object *object)
{
+ AFB_DEBUG("Received event json: %s", json_object_to_json_string(object));
+ bindingApp& bApp = bindingApp::instance();
+
+ std::shared_ptr<Signal> sig = bApp.searchSignal(event);
+ if(sig != nullptr)
+ {
+ sig->onReceivedCB(object);
+ }
}
/// @brief entry point for client subscription request. Treatment itself is made in SigComp class.
void subscribe(afb_req request)
@@ -55,20 +64,18 @@ void loadConf(afb_req request)
const char* confd;
wrap_json_unpack(args, "{s:s}", "path", &confd);
- int ret = 0;
- if( ret == 0)
+ if(true)
afb_req_success(request, NULL, NULL);
else
- afb_req_fail_f(request, "Loading configuration or subscription error", "Error code: %d", ret);
+ afb_req_fail_f(request, "Loading configuration or subscription error", "Error code: -1");
}
/// @brief entry point for get requests. Treatment itself is made in SigComp class.
void get(afb_req request)
{
- json_object *jobj;
if(true)
{
- afb_req_success(request, jobj, NULL);
+ afb_req_success(request, NULL, NULL);
}
else
{
@@ -83,7 +90,7 @@ int loadConf()
sizeof(GetBindingDirPath()) - strlen(GetBindingDirPath()) -1);
bindingApp& bApp = bindingApp::instance();
- bApp.loadConfig(rootdir);
+ ret = bApp.loadConfig(rootdir);
#ifdef CONTROL_SUPPORT_LUA
ret += LuaConfigLoad();
@@ -98,6 +105,10 @@ int execConf()
int ret = CtlConfigExec(bApp.ctlConfig());
std::vector<std::shared_ptr<Signal>> allSignals = bApp.getAllSignals();
ssize_t sigCount = allSignals.size();
+ for( std::shared_ptr<Signal>& sig: allSignals)
+ {
+ sig->attachToSources(bApp);
+ }
for(auto& sig: allSignals)
{