summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorRomain Forlot <romain.forlot@iot.bzh>2017-09-18 14:32:57 +0200
committerRomain Forlot <romain.forlot@iot.bzh>2017-12-14 11:00:25 +0100
commit9f61a83961cdbf133fdeb80cb978e6c79f4a9547 (patch)
tree2ceea5b6d566f931cce40a66bed06bd6c66ecbe3
parente338ed346a9596e67b0b6d2921ec2595c00e983d (diff)
Implement list verb
Change-Id: Id0e5c087ba17b2a2aee6f8ce9482f80a54926a7d Signed-off-by: Romain Forlot <romain.forlot@iot.bzh>
-rw-r--r--signal-composer-binding/signal-composer-binding.cpp12
1 files changed, 9 insertions, 3 deletions
diff --git a/signal-composer-binding/signal-composer-binding.cpp b/signal-composer-binding/signal-composer-binding.cpp
index 3ce60b8..c70941a 100644
--- a/signal-composer-binding/signal-composer-binding.cpp
+++ b/signal-composer-binding/signal-composer-binding.cpp
@@ -73,13 +73,19 @@ void loadConf(afb_req request)
/// @brief entry point to list available signals
void list(afb_req request)
{
- if(true)
+ struct json_object *allSignalsJ = json_object_new_array();
+
+ std::vector<std::shared_ptr<Signal>> allSignals = bindingApp::instance().getAllSignals();
+ for(auto& sig: allSignals)
+ {json_object_array_add(allSignalsJ, sig->toJSON());}
+
+ if(json_object_array_length(allSignalsJ))
{
- afb_req_success(request, NULL, NULL);
+ afb_req_success(request, allSignalsJ, NULL);
}
else
{
- afb_req_fail(request, "error", NULL);
+ afb_req_fail(request, "error", "No Signals recorded so far");
}
}