Add motion plugin handler
authorJihoon Jung <jh8801.jung@samsung.com>
Thu, 27 Dec 2018 07:23:35 +0000 (16:23 +0900)
committerAtul Kumar Rai/Advanced Platform Part /SRI-Delhi/Engineer/삼성전자 <a.rai@samsung.com>
Fri, 28 Dec 2018 11:39:33 +0000 (17:09 +0530)
Signed-off-by: Jihoon Jung <jh8801.jung@samsung.com>
ua-daemon/CMakeLists.txt
ua-daemon/src/pm/ua-motion-plugin-handler.c [new file with mode: 0755]
ua-daemon/src/pm/ua-plugin-manager.c

index 414d9a8..cd2f816 100644 (file)
@@ -12,6 +12,7 @@ SET(SRCS
        src/pm/ua-pm-util.c
        src/pm/ua-ble-plugin-handler.c
        src/pm/ua-light-plugin-handler.c
+       src/pm/ua-motion-plugin-handler.c
 )
 
 IF("${CMAKE_BUILD_TYPE}" STREQUAL "")
diff --git a/ua-daemon/src/pm/ua-motion-plugin-handler.c b/ua-daemon/src/pm/ua-motion-plugin-handler.c
new file mode 100755 (executable)
index 0000000..da6308d
--- /dev/null
@@ -0,0 +1,51 @@
+/*
+ * User Awareness Light plugin callback handler
+ *
+ * Copyright (c) 2018 Samsung Electronics Co., Ltd. All rights reserved.
+ *
+ *     Author: Atul Rai <a.rai@samsung.com>
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License")
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ *     http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+#include <stdio.h>
+#include <stdlib.h>
+#include <string.h>
+
+#include <ua-plugin.h>
+#include <ua-plugin-manager.h>
+
+void motion_state_changed_callback(int state)
+{
+       FUNC_ENTRY;
+
+       UAM_DBG("Motion: %s", state == UAS_STATE_READY ? "READY" : "NOT_READY");
+
+       FUNC_EXIT;
+}
+
+void motion_detection_callback(uas_detection_type_e type)
+{
+       FUNC_ENTRY;
+
+       UAM_DBG("Motion: %s", type == UAS_PRESENCE ? "PRESENCE" : "ABSENCE");
+
+       FUNC_EXIT;
+}
+
+uas_callbacks_t motion_cbs = {
+       .state_changed_cb = motion_state_changed_callback,
+       .detected_cb = motion_detection_callback,
+       .device_detected_cb = NULL,
+       .device_added_cb = NULL
+};
index 166cc23..fd827c8 100644 (file)
@@ -39,6 +39,7 @@ static unsigned int available_sensors = 0;
 
 extern const uas_callbacks_t ble_cbs;
 extern const uas_callbacks_t light_cbs;
+extern const uas_callbacks_t motion_cbs;
 
 typedef struct {
        void *handle;
@@ -212,6 +213,15 @@ static int __init_sensor_plugins(void)
 
                        available_sensors |= UAM_SENSOR_BITMASK_LIGHT;
                        break;
+               case UAS_PLUGIN_ID_MOTION:
+                       status = plugin->api->init(&motion_cbs);
+                       if (UAS_STATUS_SUCCESS != status) {
+                               /* Deinit plugin */
+                               continue;
+                       }
+
+                       available_sensors |= UAM_SENSOR_BITMASK_MOTION;
+                       break;
                default:
                        UAM_WARN("Unknown plugin %d", id);
                        break;