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.
18 #ifndef __UAM_MANAGER_CORE_H__
19 #define __UAM_MANAGER_CORE_H__
31 UAM_ADDR_TYPE_BT = 0x01,
40 #define UAM_DETECTION_WINDOW_DEFAULT 55 /* 55 seconds */
41 #define UAM_DETECTION_WINDOW_MAX 55 /* 55 seconds */
42 #define UAM_DETECTION_WINDOW_STEP 5 /* 5 seconds */
44 #define UAM_DETECTION_CYCLE_DEFAULT 900 /* 900 seconds */
45 #define UAM_DETECTION_CYCLE_MIN 60 /* 60 seconds */
51 int presence_threshold;
52 int absence_threshold;
55 } uam_db_service_info_t;
59 uam_tech_type_e tech_type;
65 uam_addr_type_e addr_type;
67 } uam_db_address_info_t;
70 char service_id; /** Service Id */
71 char device_icon; /** Device icon */
72 char purpose; /** Purpose */
73 char *duid; /** DUID */
74 char *bt_mac; /** BT MAC Address */
75 } uam_db_ble_payload_t;
78 uam_tech_type_e tech_type;
81 unsigned long long timestamp;
82 gboolean discriminant;
83 struct uam_db_device_info *device;
85 uam_db_ble_payload_t *payload;
88 typedef struct uam_db_device_info {
92 unsigned int supported_techs;
93 // int presence_state;
95 struct uam_db_user_info *user;
96 gboolean discriminant; /**< Determines whether to judge PRESENCE/ABSENCE */
97 } uam_db_device_info_t;
99 typedef struct uam_db_user_info {
104 // int presence_state;
105 unsigned long long timestamp;
106 } uam_db_user_info_t;
110 UAM_ACTIVE_DEVICE_FOUND = 0x01,
111 UAM_ACTIVE_SCAN_COMPLETED = 0x02
112 } uam_active_scan_event_e;
114 int _uam_core_add_user(const char *account, const char *name);
116 int _uam_core_remove_user(const char *account);
118 int _uam_core_add_device(const char *account, const uam_device_info_s *dev_info);
120 int _uam_core_remove_device(const char *account, const uam_device_info_s *dev_info);
122 int _uam_core_remove_device_by_device_id(const char *device_id, int tech_type);
124 int _uam_core_remove_device_by_mac(const char *mac);
126 int _uam_core_get_default_user(uam_user_info_s *user_info);
128 int _uam_core_get_users(int *count, uam_user_info_s **user_list);
130 int _uam_core_get_user_by_account(const char *account, uam_user_info_s *user);
132 int _uam_core_get_devcie_by_device_id(
133 const char *device_id, int tech_type, uam_device_info_s *device);
135 int _uam_core_get_devcie_by_mac(const char *mac, uam_device_info_s *device);
137 int _uam_core_get_user_by_device_id(const char *device_id, uam_user_info_s *user);
139 int _uam_core_get_user_by_mac(const char *mac, uam_user_info_s *user);
141 int _uam_core_get_devices(int *count, uam_device_info_s **device_list);
143 int _uam_core_get_user_devices(const char *account,
144 int *count, uam_device_info_s **device_list);
146 int _uam_core_is_device_added(uam_device_info_s *dev, gboolean *is_added);
148 int _uam_core_get_available_sensors(unsigned int *sensor_bitmask);
150 gboolean _uam_core_is_sensor_ready(unsigned int sensor);
152 int _uam_core_set_detection_threshold(unsigned int sensor,
153 int presence_threshold, int absence_threshold);
155 int _uam_core_start_presence_detection(const char *svc_name, char *sender, unsigned int sensors);
157 int _uam_core_stop_presence_detection(const char *svc_name, char *sender, unsigned int sensors);
159 int _uam_core_start_absence_detection(const char *svc_name, char *sender, unsigned int sensors);
161 int _uam_core_stop_absence_detection(const char *svc_name, char *sender, unsigned int sensors);
163 int _uam_core_set_low_power_mode(unsigned int bit_mask, gboolean mode);
165 int _uam_core_get_detection_window(unsigned int *window);
167 int _uam_core_set_detection_window(unsigned int window);
169 int _uam_core_init(void);
171 void _uam_core_deinit(void);
173 void _uam_core_handle_sensor_ready(unsigned int sensor, gboolean is_ready);
175 int _uam_core_handle_device_added(int status,
176 int user_id, const uam_device_info_s *dev_info);
178 void _uam_core_handle_presence_detected(unsigned int sensor,
179 int user_id, void *sensor_info);
181 void _uam_core_handle_absence_detected(unsigned int sensor,
182 int user_id, void *sensor_info);
184 void _uam_core_cleanup_monitor(char *name);
186 void _uam_core_reset_database(void);
188 unsigned int _uam_core_get_active_sensors(int detection_mode);
190 void _uam_core_handle_detection_started(unsigned int sensor);
192 void _uam_core_handle_detection_stopped(unsigned int sensor);
194 int _uam_core_start_active_device_scan(char *sender, unsigned int sensors, int detection_period);
196 int _uam_core_stop_active_device_scan(char *sender, unsigned int sensors);
198 void _uam_core_handle_active_device(uam_active_scan_event_e event, unsigned int sensor, const uam_device_info_s *dev_info);
200 int _uam_core_get_default_service(uam_service_info_s *service_info);
202 int _uam_core_register_service(uam_service_info_s *svc);
204 int _uam_core_update_service(uam_service_info_s *svc);
206 int _uam_core_unregister_service(const char *svc_name);
208 int _uam_core_get_service_devices(const char *svc_name, int *count, uam_device_info_s **device_list);
210 int _uam_core_get_service_users(const char *svc_name, int *count, uam_user_info_s **user_list);
212 int _uam_core_get_services(int *count, uam_service_info_s **service_list);
214 int _uam_core_service_add_user(const char *service_name, const char *account);
216 int _uam_core_service_remove_user(const char *service, const char *account);
218 int _uam_core_service_add_device(const char *service_name, const char *device_id, int tech_type);
220 int _uam_core_service_remove_device(const char *service_name, const char *device_id, int tech_type);
222 int _uam_core_service_set_device_discriminant(const char *service_name, const char *device_id, int tech_type, gboolean discriminant);
224 int _uam_core_service_get_device_discriminant(const char *service_name, const char *device_id, int tech_type, gboolean *discriminant);
226 int _uam_core_set_service_detection_cycle(const char *svc_name, unsigned int cycle);
228 int _uam_core_get_service_detection_cycle(const char *svc_name, unsigned int *cycle);
230 int _uam_core_update_device(const uam_device_info_s *a_device);
232 int _uam_core_add_ibeacon_adv(unsigned int adv_len, const char *iadv);
234 void _uam_core_handle_status_changed(unsigned int sensor,
235 unsigned int type, void *info);
240 #endif /* __UAM_MANAGER_CORE_H__ */