2 * Copyright (c) 2018 Samsung Electronics Co., Ltd. All rights reserved.
4 * Licensed under the Apache License, Version 2.0 (the "License")
5 * you may not use this file except in compliance with the License.
6 * You may obtain a copy of the License at
8 * http://www.apache.org/licenses/LICENSE-2.0
10 * Unless required by applicable law or agreed to in writing, software
11 * distributed under the License is distributed on an "AS IS" BASIS,
12 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 * See the License for the specific language governing permissions and
14 * limitations under the License.
21 #include <ua-plugin.h>
22 #include <ua-plugin-manager.h>
23 #include "ua-pm-util.h"
25 void motion_state_changed_callback(int state)
29 UAM_DBG("Motion: %s", state == UAS_STATE_READY ? "READY" : "NOT_READY");
34 static void motion_detection_state_changed_cb(int state)
39 _uam_core_handle_detection_started(UAM_SENSOR_BITMASK_MOTION);
41 _uam_core_handle_detection_stopped(UAM_SENSOR_BITMASK_MOTION);
47 static void motion_detection_status_changed_cb(uas_detection_type_e type,
52 uas_sensor_info_t *info = NULL;
53 uam_sensor_info_s *motion_info = NULL;
55 UAM_DBG("Motion: %s", type == UAS_PRESENCE ? "PRESENCE" : "ABSENCE");
59 motion_info = _pm_util_uas_sensor_info_to_uam_sensor_info(info);
61 _uam_core_handle_status_changed(UAM_SENSOR_BITMASK_MOTION, type, motion_info);
68 void motion_detection_callback(uas_detection_type_e type, void *sensor_info)
71 uas_sensor_info_t *info = NULL;
72 uam_sensor_info_s *motion_info = NULL;
74 UAM_DBG("Motion: %s", type == UAS_PRESENCE ? "PRESENCE" : "ABSENCE");
78 motion_info = _pm_util_uas_sensor_info_to_uam_sensor_info(info);
80 if (UAS_PRESENCE == type) {
81 UAM_DBG("Presence detected by motion sensor");
82 _uam_core_handle_presence_detected(UAM_SENSOR_BITMASK_MOTION, 0, motion_info);
84 UAM_DBG("Absence detected by motion sensor");
85 _uam_core_handle_absence_detected(UAM_SENSOR_BITMASK_MOTION, 0, motion_info);
93 uas_callbacks_t motion_cbs = {
94 .state_changed_cb = motion_state_changed_callback,
95 .detection_state_cb = motion_detection_state_changed_cb,
96 .detection_status_cb = motion_detection_status_changed_cb,
97 .detected_cb = motion_detection_callback,
98 .device_detected_cb = NULL,
99 .device_added_cb = NULL,
100 .active_scan_cb = NULL,