From 5bbc6cb56995d23cb8a4eb584ef0161be092da1f Mon Sep 17 00:00:00 2001 From: Romain Forlot Date: Sat, 16 Sep 2017 19:52:41 +0200 Subject: Adding new verb, implemented basic signal method Change-Id: I453ddc0ca374436275e7d76cdc27b3d843a2770f Signed-off-by: Romain Forlot --- .../signal-composer-binding.cpp | 30 +++++++++++++++++++++- 1 file changed, 29 insertions(+), 1 deletion(-) (limited to 'signal-composer-binding/signal-composer-binding.cpp') diff --git a/signal-composer-binding/signal-composer-binding.cpp b/signal-composer-binding/signal-composer-binding.cpp index 5ff24b0..b0c6821 100644 --- a/signal-composer-binding/signal-composer-binding.cpp +++ b/signal-composer-binding/signal-composer-binding.cpp @@ -71,7 +71,7 @@ void loadConf(afb_req request) } /// @brief entry point for get requests. Treatment itself is made in SigComp class. -void get(afb_req request) +void list(afb_req request) { if(true) { @@ -83,6 +83,34 @@ void get(afb_req request) } } +/// @brief entry point for get requests. +void get(struct afb_req request) +{ + int err = 0; + struct json_object* args = nullptr, *ans = nullptr, + *options = nullptr; + const char* sig; + + args = afb_req_json(request); + + // Process about Raw CAN message on CAN bus directly + err = wrap_json_unpack(args, "{ss,s?o!}", "signals", &sig, + "options", &options); + if(err) + { + AFB_ERROR("Can't process your request '%s'. Valid arguments are: string for 'signal' and JSON object for 'options' (optionnal)", json_object_to_json_string_ext(args, JSON_C_TO_STRING_PRETTY)); + afb_req_fail(request, "error", NULL); + return; + } + + ans = bindingApp::instance().getSignalValue(sig, options); + + if (ans) + afb_req_success(request, ans, NULL); + else + afb_req_fail(request, "error", NULL); +} + int loadConf() { int err = 0; -- cgit 1.2.3-korg