summaryrefslogtreecommitdiffstats
path: root/signal-composer-binding/signal-composer-binding.cpp
diff options
context:
space:
mode:
authorRomain Forlot <romain.forlot@iot.bzh>2017-09-16 19:52:41 +0200
committerRomain Forlot <romain.forlot@iot.bzh>2017-12-14 11:00:25 +0100
commit5bbc6cb56995d23cb8a4eb584ef0161be092da1f (patch)
tree0a63676d64a67f4323ed5e7fce1be147f95c2e69 /signal-composer-binding/signal-composer-binding.cpp
parentde24d7de2b87f5d8164f49fb130f8693b32362a0 (diff)
Adding new verb, implemented basic signal method
Change-Id: I453ddc0ca374436275e7d76cdc27b3d843a2770f 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.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;