aboutsummaryrefslogtreecommitdiffstats
path: root/signal-composer-binding/signal-composer-binding.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'signal-composer-binding/signal-composer-binding.cpp')
-rw-r--r--signal-composer-binding/signal-composer-binding.cpp30
1 files changed, 29 insertions, 1 deletions
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;