aboutsummaryrefslogtreecommitdiffstats
path: root/src/main.cpp
diff options
context:
space:
mode:
authorYuta Doi <yuta-d@witz-inc.co.jp>2018-05-18 17:16:14 +0900
committerYuta Doi <yuta-d@witz-inc.co.jp>2018-05-18 17:16:14 +0900
commit7b62eefaf33b9bb69eb324333232ae0919fc295f (patch)
tree3cbaf1c253f3744607ab2c0685f58ae3a78e3e40 /src/main.cpp
parent9f61fdc39edd93c7da5b77b4bc92963e4df31b82 (diff)
Add API which can get information about the car state
getCarInfo() can get the car state informations as follows: - parking brake state : true/false - accelerator pedal position : 0-127.5 - car state : "stop"/"run" The details are described in doc/ApplicationGuide.md in project apps/agl-service-windowmanager-2017. Change-Id: I2a4a06ceeedbd2d3b1188a7fb442e1272e46897b Signed-off-by: Yuta Doi <yuta-d@witz-inc.co.jp>
Diffstat (limited to 'src/main.cpp')
-rw-r--r--src/main.cpp35
1 files changed, 35 insertions, 0 deletions
diff --git a/src/main.cpp b/src/main.cpp
index 1db33a4..99ad323 100644
--- a/src/main.cpp
+++ b/src/main.cpp
@@ -452,6 +452,40 @@ void windowmanager_getareainfo_thunk(afb_req req) noexcept {
}
+void windowmanager_getcarinfo_thunk(afb_req req) noexcept {
+ std::lock_guard<std::mutex> guard(binding_m);
+ #ifdef ST
+ ST();
+ #endif
+ if (g_afb_instance == nullptr) {
+ afb_req_fail(req, "failed", "Binding not initialized, did the compositor die?");
+ return;
+ }
+
+ try {
+ json_object *jreq = afb_req_json(req);
+
+ json_object *j_label = nullptr;
+ if (! json_object_object_get_ex(jreq, "label", &j_label)) {
+ afb_req_fail(req, "failed", "Need char const* argument label");
+ return;
+ }
+ char const* a_label = json_object_get_string(j_label);
+
+ auto ret = g_afb_instance->app.api_get_car_info(a_label);
+ if (ret.is_err()) {
+ afb_req_fail(req, "failed", ret.unwrap_err());
+ return;
+ }
+
+ afb_req_success(req, ret.unwrap(), "success");
+ } catch (std::exception &e) {
+ afb_req_fail_f(req, "failed", "Uncaught exception while calling getcarinfo: %s", e.what());
+ return;
+ }
+
+}
+
void windowmanager_wm_subscribe(afb_req req) noexcept {
std::lock_guard<std::mutex> guard(binding_m);
#ifdef ST
@@ -650,6 +684,7 @@ const struct afb_verb_v2 windowmanager_verbs[] = {
{ "getdisplayinfo", windowmanager_getdisplayinfo_thunk, nullptr, nullptr, AFB_SESSION_NONE },
{ "getareainfo", windowmanager_getareainfo_thunk, nullptr, nullptr, AFB_SESSION_NONE },
{ "wm_subscribe", windowmanager_wm_subscribe, nullptr, nullptr, AFB_SESSION_NONE },
+ { "getcarinfo", windowmanager_getcarinfo_thunk, nullptr, nullptr, AFB_SESSION_NONE },
{ "list_drawing_names", windowmanager_list_drawing_names, nullptr, nullptr, AFB_SESSION_NONE },
{ "ping", windowmanager_ping, nullptr, nullptr, AFB_SESSION_NONE },
{ "debug_status", windowmanager_debug_status, nullptr, nullptr, AFB_SESSION_NONE },