summaryrefslogtreecommitdiffstats
path: root/signal-composer-binding/signal-composer-binding.cpp
diff options
context:
space:
mode:
authorRomain Forlot <romain.forlot@iot.bzh>2017-09-19 01:17:28 +0200
committerRomain Forlot <romain.forlot@iot.bzh>2017-12-14 11:00:25 +0100
commitf4fba8a2744991ff8c5cb8af4a67c7d9456f1057 (patch)
tree352231c9342344599ec2af08ef82495deefb238f /signal-composer-binding/signal-composer-binding.cpp
parent9f61a83961cdbf133fdeb80cb978e6c79f4a9547 (diff)
Modification about conf definition
- Argument for each signal subscription. (getSignalsArgs) - differentiation between Signal as raw signal from another API and virtual signal depending upon other signals - changing way to specify function with uri that specify everythings that could be needed to invoke a function. Change-Id: I8917c5ae3c2c1e3fa48ddfdda41fc75eaba32bb7 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.cpp20
1 files changed, 13 insertions, 7 deletions
diff --git a/signal-composer-binding/signal-composer-binding.cpp b/signal-composer-binding/signal-composer-binding.cpp
index c70941a..4f12150 100644
--- a/signal-composer-binding/signal-composer-binding.cpp
+++ b/signal-composer-binding/signal-composer-binding.cpp
@@ -39,6 +39,7 @@ void onEvent(const char *event, json_object *object)
sig->onReceivedCB(object);
}
}
+
/// @brief entry point for client subscription request.
void subscribe(afb_req request)
{
@@ -60,14 +61,19 @@ void unsubscribe(afb_req request)
/// @brief verb that loads JSON configuration (old SigComp.json file now)
void loadConf(afb_req request)
{
- json_object* args = afb_req_json(request);
- const char* confd;
+ json_object* args = afb_req_json(request), *fileJ;
+ const char* filepath;
- wrap_json_unpack(args, "{s:s}", "path", &confd);
- if(true)
- afb_req_success(request, NULL, NULL);
+ wrap_json_unpack(args, "{s:s}", "filepath", &filepath);
+ fileJ = json_object_from_file(filepath);
+
+ if(bindingApp::instance().loadSignals(fileJ))
+ {afb_req_fail_f(request, "Loading configuration or subscription error", "Error code: -1");}
else
- afb_req_fail_f(request, "Loading configuration or subscription error", "Error code: -1");
+ {
+
+ afb_req_success(request, NULL, NULL);
+ }
}
/// @brief entry point to list available signals
@@ -79,7 +85,7 @@ void list(afb_req request)
for(auto& sig: allSignals)
{json_object_array_add(allSignalsJ, sig->toJSON());}
- if(json_object_array_length(allSignalsJ))
+ if(json_object_array_length(allSignalsJ) && !execConf())
{
afb_req_success(request, allSignalsJ, NULL);
}