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 __TIZEN_UA_NETWORK_UA_API_H__
19 #define __TIZEN_UA_NETWORK_UA_API_H__
22 #include <tizen_error.h>
24 #ifndef TIZEN_ERROR_UA
25 #define TIZEN_ERROR_UA 0x11170000 /**< To-Do: This should move to tizen_error.h */
33 * @brief Bitmask for sensors.
37 UAM_SENSOR_BITMASK_BT = 0x00000001, /**< Bitmask for BT */
38 UAM_SENSOR_BITMASK_BLE = 0x00000002, /**< Bitmask for BLE */
39 UAM_SENSOR_BITMASK_WIFI = 0x00000004, /**< Bitmask for Wi-Fi */
40 UAM_SENSOR_BITMASK_MOTION = 0x00000008, /**< Bitmask for motion */
41 UAM_SENSOR_BITMASK_LIGHT = 0x00000010, /**< Bitmask for light */
42 UAM_SENSOR_BITMASK_AUDIO = 0x00000020, /**< Bitmask for autio */
43 UAM_SENSOR_ALL = 0xFFFFFFFF, /**< Bitmask for all sensors */
44 } uam_sensor_bitmask_e;
47 * @brief Max. MAC address length.
50 #define UAM_MAC_ADDRESS_STRING_LEN 18
53 * @brief Max. device id length.
56 #define UAM_DEVICE_ID_MAX_STRING_LEN 50
59 * @brief Device's BLE payload DUID length.
62 #define UAM_BLE_PAYLOAD_DUID_LEN 17
65 * @brief Max. BT MAC address length.
68 #define UAM_BT_MAC_ADDRESS_STRING_LEN 18
71 * @brief Max. IP address length.
74 #define UAM_IP_ADDRESS_MAX_STRING_LEN 50
77 * @brief Max. user name length.
80 #define UAM_USER_NAME_MAX_STRING_LEN 254
83 * @brief Max. user account length.
86 #define UAM_USER_ACCOUNT_MAX_STRING_LEN 254
89 * @brief Max. application id length.
92 #define UAM_APP_ID_MAX_STRING_LEN 100
95 * @brief Max. service id length.
98 #define UAM_SERVICE_MAX_STRING_LEN 50
101 * @brief Default service name.
104 #define UAM_SERVICE_DEFAULT "ua.service.default"
107 * @brief Default presence threshold.
110 #define UAM_PRESENCE_THRESHOLD_DEFAULT 2
113 * @brief Default absence threshold.
116 #define UAM_ABSENCE_THRESHOLD_DEFAULT 0
119 * @brief Macro for event enum.
122 #define GENERATE_EVENT_ENUM(ENUM) ENUM,
125 * @brief Macro to print event string out.
128 #define GENERATE_EVENT_STRING(STRING) #STRING,
131 * @brief Max. ibeacon adv length.
134 #define UAM_IBEACON_ADV_MAX_LEN 31
137 * @brief Maximum number of values from sensor.
140 #define UAM_SENSOR_MAX_VALUES 4
143 * @brief Enumerations macro of UA framework event codes.
147 UAM_EVENT_USER_ADDED, /**< User added */
148 UAM_EVENT_USER_REMOVED, /**< User removed */
149 UAM_EVENT_DEVICE_ADDED, /**< Device added */
150 UAM_EVENT_DEVICE_REMOVED, /**< Device removed */
151 UAM_EVENT_PRESENCE_DETECTED, /**< Presence detected */
152 UAM_EVENT_USER_PRESENCE_DETECTED, /**< User presence detected */
153 UAM_EVENT_ABSENCE_DETECTED, /**< Absence detected */
154 UAM_EVENT_USER_ABSENCE_DETECTED, /**< User absence detected */
155 UAM_EVENT_AMBIANT_MODE_ENABLED, /**< Ambient mode enabled */
156 UAM_EVENT_AMBIANT_MODE_DISABLED, /**< Ambient mode disabled */
157 UAM_EVENT_SENSOR_STATE_READY, /**< Sensor state ready */
158 UAM_EVENT_SENSOR_STATE_NOT_READY, /**< Sensor state not ready */
159 UAM_EVENT_DETECTION_STARTED, /**< Detection started */
160 UAM_EVENT_DETECTION_STOPPED, /**< Detection stopped */
161 UAM_EVENT_DEVICE_FOUND, /**< Device found */
162 UAM_EVENT_SCAN_COMPLETED, /**< Scan completed */
163 UAM_EVENT_SERVICE_REGISTERED, /**< Service registered */
164 UAM_EVENT_SERVICE_UNREGISTERED, /**< Service registered */
165 UAM_EVENT_SENSOR_STATUS_CHANGED, /**< Sensor status changed */
166 UAM_EVENT_MAX, /**< Max. event number */
170 * @brief Macro to print error string out.
173 #define GENERATE_ERROR_CASE(STRING, offset) case STRING: return #STRING;
176 * @brief Enumerations macro of UA framework error codes.
180 UAM_ERROR_NONE = TIZEN_ERROR_NONE, /**< Succsssful */
181 UAM_ERROR_INVALID_PARAMETER = TIZEN_ERROR_INVALID_PARAMETER, /**< Invalid parameter */
182 UAM_ERROR_OUT_OF_MEMORY = TIZEN_ERROR_OUT_OF_MEMORY, /**< Out of memory */
183 UAM_ERROR_PERMISSION_DENIED = TIZEN_ERROR_PERMISSION_DENIED, /**< Permission denied */
184 UAM_ERROR_RESOURCE_BUSY = TIZEN_ERROR_RESOURCE_BUSY, /**< Resource busy */
185 UAM_ERROR_TIMED_OUT = TIZEN_ERROR_TIMED_OUT, /**< Time out */
186 UAM_ERROR_NOW_IN_PROGRESS = TIZEN_ERROR_NOW_IN_PROGRESS, /**< Now in progress */
187 UAM_ERROR_NOT_SUPPORTED = TIZEN_ERROR_NOT_SUPPORTED, /**< Not supported */
188 UAM_ERROR_NOT_INITIALIZED = TIZEN_ERROR_UA | 0x01, /**< Not initiaized */
189 UAM_ERROR_NOT_IN_OPERATION = TIZEN_ERROR_UA | 0x02, /**< Not in progress */
190 UAM_ERROR_ALREADY_DONE = TIZEN_ERROR_UA | 0x03, /**< Already done */
191 UAM_ERROR_INTERNAL = TIZEN_ERROR_UA | 0x04, /**< Internal error */
192 UAM_ERROR_NOT_FOUND = TIZEN_ERROR_UA | 0x10, /**< Not found */
193 UAM_ERROR_ALREADY_REGISTERED = TIZEN_ERROR_UA | 0x11, /**< Already registered */
194 UAM_ERROR_DB_FAILED = TIZEN_ERROR_UA | 0x12, /**< DB operation failed */
195 UAM_ERROR_NOT_REGISTERED = TIZEN_ERROR_UA | 0x13, /**< Not registered */
199 * @brief Eevent data structure.
203 int result; /**< Result code */
204 void *data; /**< Data pointer */
208 * @brief Callback to be invoked when receiving events.
211 * @remarks The @a event_param should not be released.
212 * @remarks The @a event_param can be used only in the callback.
214 * @param[in] event Event type.
215 * @param[in] event_param The event data structure.
216 * @param[in] user_data The user data passed in _uam_init()
224 typedef void (*uam_event_cb)(int event, uam_event_data_s *event_param, void *user_data);
227 * @brief Initializes client library.
230 * @param[in] cb Callback handler
231 * @param[in] user_data The user data.
233 * @return 0 on success, otherwise a negative error value
234 * @retval #UAM_ERROR_NONE Successful
235 * @retval #UAM_ERROR_INVALID_PARAMETER Invalid parameters
236 * @rerval #UAM_ERROR_ALREADY_REGISTERED Already registered
237 * @retval #UAM_ERROR_INTERNAL Internal error
243 int _uam_init(uam_event_cb cb, void *user_data);
246 * @brief De-initializes client library.
249 * @return 0 on success, otherwise a negative error value
250 * @retval #UAM_ERROR_NONE Successful
251 * @rerval #UAM_ERROR_NOT_REGISTERED Not registered
252 * @retval #UAM_ERROR_INTERNAL Internal error
258 int _uam_deinit(void);
261 * @brief Gets available sensor list.
264 * @param[out] bitmask Available sensor list
266 * @return 0 on success, otherwise a negative error value
267 * @retval #UAM_ERROR_NONE Successful
268 * @retval #UAM_ERROR_INVALID_PARAMETER Invalid parameters
269 * @retval #UAM_ERROR_INTERNAL Internal error
275 int _uam_get_available_sensors(unsigned int *bitmask);
278 * @brief Gets a specific sensor availability.
281 * @param[in] sensor Sensor type
282 * @param[out] status Sensor state
284 * @return 0 on success, otherwise a negative error value
285 * @retval #UAM_ERROR_NONE Successful
286 * @retval #UAM_ERROR_INVALID_PARAMETER Invalid parameters
287 * @retval #UAM_ERROR_INTERNAL Internal error
293 int _uam_is_sensor_ready(unsigned int sensor, gboolean* status);
296 * @brief Starts presence detection.
299 * @param[in] bitmask Bitmask to detect
300 * @param[in] service Service name
302 * @return 0 on success, otherwise a negative error value
303 * @retval #UAM_ERROR_NONE Successful
304 * @retval #UAM_ERROR_INVALID_PARAMETER Invalid parameters
305 * @retval #UAM_ERROR_INTERNAL Internal error
311 int _uam_start_presence_detection(unsigned int bitmask, const char *service);
314 * @brief Stops presence detection.
317 * @param[in] bitmask Bitmask to detect
318 * @param[in] service Service name
320 * @return 0 on success, otherwise a negative error value
321 * @retval #UAM_ERROR_NONE Successful
322 * @retval #UAM_ERROR_INVALID_PARAMETER Invalid parameters
323 * @retval #UAM_ERROR_INTERNAL Internal error
329 int _uam_stop_presence_detection(unsigned int bitmask, const char *service);
332 * @brief Starts absence detection.
335 * @param[in] bitmask Bitmask to detect
336 * @param[in] service Service name
338 * @return 0 on success, otherwise a negative error value
339 * @retval #UAM_ERROR_NONE Successful
340 * @retval #UAM_ERROR_INVALID_PARAMETER Invalid parameters
341 * @retval #UAM_ERROR_INTERNAL Internal error
347 int _uam_start_absence_detection(unsigned int bitmask, const char *service);
350 * @brief Stops absence detection.
353 * @param[in] bitmask Bitmask to detect
354 * @param[in] service Service name
356 * @return 0 on success, otherwise a negative error value
357 * @retval #UAM_ERROR_NONE Successful
358 * @retval #UAM_ERROR_INVALID_PARAMETER Invalid parameters
359 * @retval #UAM_ERROR_INTERNAL Internal error
365 int _uam_stop_absence_detection(unsigned int bitmask, const char *service);
368 * @brief Starts active devices searching.
371 * @param[in] bitmask Bitmask to detect
372 * @param[in] detection_period Detection period
374 * @return 0 on success, otherwise a negative error value
375 * @retval #UAM_ERROR_NONE Successful
376 * @retval #UAM_ERROR_INVALID_PARAMETER Invalid parameters
377 * @retval #UAM_ERROR_INTERNAL Internal error
383 int _uam_start_search_active_devices(unsigned int bitmask, int detection_period);
386 * @brief Stops active devices searching.
389 * @param[in] bitmask Bitmask to detect
391 * @return 0 on success, otherwise a negative error value
392 * @retval #UAM_ERROR_NONE Successful
393 * @retval #UAM_ERROR_INVALID_PARAMETER Invalid parameters
394 * @retval #UAM_ERROR_INTERNAL Internal error
400 int _uam_stop_search_active_devices(unsigned int bitmask);
403 * @brief Registers application id.
406 * @param[in] app_id Application id
407 * @param[in] uid User id
409 * @return 0 on success, otherwise a negative error value
410 * @retval #UAM_ERROR_NONE Successful
411 * @retval #UAM_ERROR_INVALID_PARAMETER Invalid parameters
412 * @retval #UAM_ERROR_INTERNAL Internal error
418 int _uam_register_app(const char *app_id, unsigned short uid);
421 * @brief Unregisters application id.
424 * @param[in] app_id Application id
425 * @param[in] uid User id
427 * @return 0 on success, otherwise a negative error value
428 * @retval #UAM_ERROR_NONE Successful
429 * @retval #UAM_ERROR_INVALID_PARAMETER Invalid parameters
430 * @retval #UAM_ERROR_INTERNAL Internal error
436 int _uam_deregister_app(const char *app_id, unsigned short uid);
439 * @brief Enumerations for presence state.
443 UAM_PRESENCE_STATE_INVALID = 0x00, /**< Invaild state */
444 UAM_PRESENCE_STATE_PRESENT, /**< Presence state */
445 UAM_PRESENCE_STATE_ABSENT, /**< Absence state */
446 } uam_presence_state_e;
449 * @brief Enumerations for detection cycle state.
453 UAM_DETECTION_CYCLE_MID = 0x00, /**< Ongoing detection cycle in mid */
454 UAM_DETECTION_CYCLE_END, /**< Detection cycle ends */
458 * @brief Enumerations for OS type.
462 UAM_OS_TYPE_UNDEFINED = 0x00, /**< Undefined */
463 UAM_OS_TYPE_TIZEN, /**< Tizen */
464 UAM_OS_TYPE_ANDROID, /**< Android */
465 UAM_OS_TYPE_IOS, /**< iOS */
466 UAM_OS_TYPE_INVALID /**< Invalid */
470 * @brief Enumerations for connectivity type.
474 UAM_TECH_TYPE_NONE = 0x00, /**< None */
475 UAM_TECH_TYPE_BT = 0x01, /**< BT */
476 UAM_TECH_TYPE_BLE = 0x02, /**< BLE */
477 UAM_TECH_TYPE_WIFI = 0x04, /**< Wi-Fi */
478 UAM_TECH_TYPE_P2P = 0x08, /**< Wi-Fi p2p */
479 UAM_TECH_TYPE_MAX /**< Max. connectivity type */
483 * @brief BLE Payload info structure.
487 char service_id; /** Service Id */
488 char device_icon; /** Device icon */
489 char purpose; /** Purpose */
490 char duid[UAM_BLE_PAYLOAD_DUID_LEN + 1]; /** DUID */
491 char bt_mac[UAM_BT_MAC_ADDRESS_STRING_LEN]; /** BT MAC Address */
495 * @brief Device info structure.
499 uam_os_type_e operating_system; /**< Operating system */
500 uam_tech_type_e type; /**< Device's mac address type (BT/BLE/WIFI/P2p/...) */
501 char mac[UAM_MAC_ADDRESS_STRING_LEN]; /**< Device's MAC ADDRESS */
502 char ipv4_addr[UAM_IP_ADDRESS_MAX_STRING_LEN];/**< Device's IPv4 address optional */
503 char device_id[UAM_DEVICE_ID_MAX_STRING_LEN]; /**< Device's uniquie ID */
504 uam_ble_payload_s payload; /**< BLE Payload to parse BLE devices*/
505 gboolean discriminant; /**< Determines whether to judge PRESENCE/ABSENCE */
506 unsigned long long last_seen; /**< Latest seen time when device was discoverd */
510 * @brief Sensor info structure.
514 unsigned int status; /**< Sensor status */
515 unsigned int sensor_bitmask; /**< sensor bitmask of discovered sensor */
516 unsigned long long timestamp; /**< Latest timestamp when sensor was discoverd */
517 int accuracy; /**< Accuracy info from sensor sensor */
518 int count; /**< count of values from sensor sensor */
519 double values[UAM_SENSOR_MAX_VALUES]; /**< info from sensor */
523 * @brief User info structure.
527 char account[UAM_USER_ACCOUNT_MAX_STRING_LEN]; /**< User account */
528 char name[UAM_USER_NAME_MAX_STRING_LEN]; /**< User name */
532 * @brief Service info structure.
536 char name[UAM_SERVICE_MAX_STRING_LEN]; /**< Service name */
537 unsigned int presence_threshold;
538 unsigned int absence_threshold;
539 } uam_service_info_s;
542 * @brief Detection event structure.
546 unsigned int sensor_bitmask; /**< Detecting sensor's bitmask */
547 char account[UAM_USER_ACCOUNT_MAX_STRING_LEN]; /**< User account */
548 char service[UAM_SERVICE_MAX_STRING_LEN]; /**< Service name */
549 unsigned long long last_seen; /**< The last time of detection */
550 char device_id[UAM_DEVICE_ID_MAX_STRING_LEN]; /**< Device's unique ID */
551 } uam_detection_event_data_s;
554 * @brief User event structure.
558 char account[UAM_USER_ACCOUNT_MAX_STRING_LEN]; /**< User account */
559 char name[UAM_USER_NAME_MAX_STRING_LEN]; /**< User name */
560 } uam_user_event_data_s;
563 * @brief Detection stopped event structure.
567 char service[UAM_SERVICE_MAX_STRING_LEN]; /**< Service name */
568 uam_cycle_state_e cycle_state; /**< detection cycle state */
569 } uam_detection_stopped_event_data_s;
572 * @brief Application info structure.
576 char *sender; /**< Dbus sender */
577 unsigned short uid; /**< UID */
578 char app_id[UAM_APP_ID_MAX_STRING_LEN]; /**< Application id */
582 * @brief Gets registered user list.
585 * @remarks The @a user_list should be destroyed by using #g_free() and #g_ptr_array_free().
587 * @param[out] user_list User list array
589 * @return 0 on success, otherwise a negative error value
590 * @retval #UAM_ERROR_NONE Successful
591 * @retval #UAM_ERROR_INVALID_PARAMETER Invalid parameters
592 * @retval #UAM_ERROR_INTERNAL Internal error
598 int _uam_get_registered_users(GPtrArray **user_list);
601 * @brief Checks registerd device.
604 * @param[in] dev_info Device info
605 * @param[out] is_registered Registered or not
607 * @return 0 on success, otherwise a negative error value
608 * @retval #UAM_ERROR_NONE Successful
609 * @retval #UAM_ERROR_INVALID_PARAMETER Invalid parameters
610 * @retval #UAM_ERROR_INTERNAL Internal error
616 int _uam_is_device_registered(
617 uam_device_info_s *dev_info, gboolean *is_registered);
620 * @brief Callback to be called when receiving events.
623 * @remarks The @a event_param should not be released.
624 * @remarks The @a event_param can be used only in the callback.
626 * @param[in] event Event type
627 * @param[in] event_param Event data
628 * @param[in] user_data User data passed in _uam_init().
630 * @return 0 on success, otherwise a negative error value
631 * @retval #UAM_ERROR_NONE Successful
632 * @retval #UAM_ERROR_INVALID_PARAMETER Invalid parameters
633 * @retval #UAM_ERROR_INTERNAL Internal error
639 typedef void (*uam_event_cb)(int event, uam_event_data_s *event_param, void *user_data);
642 * @brief Intializes a client library of ua-manager.
645 * @param[in] cb Event callback
646 * @param[in] user_data User data passed in _uam_init().
648 * @return 0 on success, otherwise a negative error value
649 * @retval #UAM_ERROR_NONE Successful
650 * @retval #UAM_ERROR_INVALID_PARAMETER Invalid parameters
651 * @retval #UAM_ERROR_INTERNAL Internal error
657 int _uam_init(uam_event_cb cb, void *user_data);
660 * @brief De-intializes a client library of ua-manager.
663 * @return 0 on success, otherwise a negative error value
664 * @retval #UAM_ERROR_NONE Successful
665 * @retval #UAM_ERROR_INTERNAL Internal error
671 int _uam_deinit(void);
674 * @brief Retrieves available sensor list.
677 * @param[in] bitmask Available sensor list
679 * @return 0 on success, otherwise a negative error value
680 * @retval #UAM_ERROR_NONE Successful
681 * @retval #UAM_ERROR_INVALID_PARAMETER Invalid parameters
682 * @retval #UAM_ERROR_INTERNAL Internal error
688 int _uam_get_available_sensors(unsigned int *bitmask);
691 * @brief Gets default user info.
694 * @param[in] uam_user User information
696 * @return 0 on success, otherwise a negative error value
697 * @retval #UAM_ERROR_NONE Successful
698 * @retval #UAM_ERROR_INVALID_PARAMETER Invalid parameters
699 * @retval #UAM_ERROR_INTERNAL Internal error
705 int _uam_get_default_user(uam_user_info_s *uam_user);
708 * @brief Adds user info.
711 * @param[in] user User information.
713 * @return 0 on success, otherwise a negative error value
714 * @retval #UAM_ERROR_NONE Successful
715 * @retval #UAM_ERROR_INVALID_PARAMETER Invalid parameters
716 * @retval #UAM_ERROR_INTERNAL Internal error
722 int _uam_add_user(uam_user_info_s *user);
725 * @brief Removes user info.
728 * @param[in] account User account.
730 * @return 0 on success, otherwise a negative error value
731 * @retval #UAM_ERROR_NONE Successful
732 * @retval #UAM_ERROR_INVALID_PARAMETER Invalid parameters
733 * @retval #UAM_ERROR_INTERNAL Internal error
739 int _uam_remove_user(char *account);
742 * @brief Updates user info.
745 * @param[in] user User information.
747 * @return 0 on success, otherwise a negative error value
748 * @retval #UAM_ERROR_NONE Successful
749 * @retval #UAM_ERROR_INVALID_PARAMETER Invalid parameters
750 * @retval #UAM_ERROR_INTERNAL Internal error
756 int _uam_update_user(uam_user_info_s *user);
759 * @brief Brings user information that meet the user account.
762 * @remarks The @a user should not be released.
763 * @remarks The @a user can be used only in the function.
765 * @param[in] account User account.
766 * @param[out] user User information.
768 * @return 0 on success, otherwise a negative error value
769 * @retval #UAM_ERROR_NONE Successful
770 * @retval #UAM_ERROR_INVALID_PARAMETER Invalid parameters
771 * @retval #UAM_ERROR_INTERNAL Internal error
777 int _uam_request_get_user_by_account(char *account, uam_user_info_s *user);
780 * @brief Brings user information that meet the device id.
783 * @remarks The @a user should not be released.
784 * @remarks The @a user can be used only in the function.
786 * @param[in] device_id Device id.
787 * @param[out] user User information.
789 * @return 0 on success, otherwise a negative error value
790 * @retval #UAM_ERROR_NONE Successful
791 * @retval #UAM_ERROR_INVALID_PARAMETER Invalid parameters
792 * @retval #UAM_ERROR_INTERNAL Internal error
798 int _uam_request_get_user_by_deviceid(char *device_id, uam_user_info_s *user);
801 * @brief Brings user information that meet the MAC address.
804 * @remarks The @a user should not be released.
805 * @remarks The @a user can be used only in the function.
807 * @param[in] mac Mac address.
808 * @param[out] user User information.
810 * @return 0 on success, otherwise a negative error value
811 * @retval #UAM_ERROR_NONE Successful
812 * @retval #UAM_ERROR_INVALID_PARAMETER Invalid parameters
813 * @retval #UAM_ERROR_INTERNAL Internal error
819 int _uam_request_get_user_by_mac(char *mac, uam_user_info_s *user);
822 * @brief Requests to add a device info to the user.
825 * @param[in] account User account.
826 * @param[in] device Device information.
828 * @return 0 on success, otherwise a negative error value
829 * @retval #UAM_ERROR_NONE Successful
830 * @retval #UAM_ERROR_INVALID_PARAMETER Invalid parameters
831 * @retval #UAM_ERROR_INTERNAL Internal error
837 int _uam_request_add_device(char *account, uam_device_info_s *device);
840 * @brief Requests to remove a device info to the user.
843 * @param[in] account User account.
844 * @param[in] device Device information.
846 * @return 0 on success, otherwise a negative error value
847 * @retval #UAM_ERROR_NONE Successful
848 * @retval #UAM_ERROR_INVALID_PARAMETER Invalid parameters
849 * @retval #UAM_ERROR_INTERNAL Internal error
855 int _uam_request_remove_device(char *account, uam_device_info_s *device);
858 * @brief Deletes device information matching device id and sensor type.
861 * @param[in] device_id Device id.
862 * @param[in] tech_type Sensor type.
864 * @return 0 on success, otherwise a negative error value
865 * @retval #UAM_ERROR_NONE Successful
866 * @retval #UAM_ERROR_INVALID_PARAMETER Invalid parameters
867 * @retval #UAM_ERROR_INTERNAL Internal error
873 int _uam_request_remove_device_by_deviceid(const char *device_id,
874 uam_tech_type_e tech_type);
877 * @brief Deletes device information matching device MAC.
880 * @param[in] mac MAC address.
882 * @return 0 on success, otherwise a negative error value
883 * @retval #UAM_ERROR_NONE Successful
884 * @retval #UAM_ERROR_INVALID_PARAMETER Invalid parameters
885 * @retval #UAM_ERROR_INTERNAL Internal error
891 int _uam_request_remove_device_by_mac(const char *mac);
894 * @brief Retrieves device information matching device id.
897 * @remarks The @a device should not be released.
898 * @remarks The @a device can be used only in the function.
900 * @param[in] device_id Device id.
901 * @param[in] tech_type Sensor type.
902 * @param[out] device Device information.
904 * @return 0 on success, otherwise a negative error value
905 * @retval #UAM_ERROR_NONE Successful
906 * @retval #UAM_ERROR_INVALID_PARAMETER Invalid parameters
907 * @retval #UAM_ERROR_INTERNAL Internal error
913 int _uam_request_get_device_by_deviceid(const char *device_id,
914 uam_tech_type_e tech_type, uam_device_info_s *device);
917 * @brief Retrieves device information matching MAC address.
920 * @remarks The @a device should not be released.
921 * @remarks The @a device can be used only in the function.
923 * @param[in] mac MAC address.
924 * @param[out] device Device information.
926 * @return 0 on success, otherwise a negative error value
927 * @retval #UAM_ERROR_NONE Successful
928 * @retval #UAM_ERROR_INVALID_PARAMETER Invalid parameters
929 * @retval #UAM_ERROR_INTERNAL Internal error
935 int _uam_request_get_device_by_mac(const char *mac, uam_device_info_s *device);
938 * @brief Gets registered devices list.
941 * @remarks The @a devices_list should be destroyed by using #g_free() and #g_ptr_array_free().
943 * @param[out] devices_list Device list array
945 * @return 0 on success, otherwise a negative error value
946 * @retval #UAM_ERROR_NONE Successful
947 * @retval #UAM_ERROR_INVALID_PARAMETER Invalid parameters
948 * @retval #UAM_ERROR_INTERNAL Internal error
954 int _uam_request_get_devices(GPtrArray **devices_list);
957 * @brief Gets registered devices list per a user.
960 * @remarks The @a devices_list should be destroyed by using #g_free() and #g_ptr_array_free().
962 * @param[in] account User account.
963 * @param[out] devices_list Devices list
965 * @return 0 on success, otherwise a negative error value
966 * @retval #UAM_ERROR_NONE Successful
967 * @retval #UAM_ERROR_INVALID_PARAMETER Invalid parameters
968 * @retval #UAM_ERROR_INTERNAL Internal error
974 int _uam_request_get_user_devices(char *account, GPtrArray **devices_list);
977 * @brief Sets detection threshold.
980 * @param[in] sensor_type Sensor type.
981 * @param[in] presence_threshold Threshold value for presence.
982 * @param[in] absence_threshold Threshold value for absence.
984 * @return 0 on success, otherwise a negative error value
985 * @retval #UAM_ERROR_NONE Successful
986 * @retval #UAM_ERROR_INVALID_PARAMETER Invalid parameters
987 * @retval #UAM_ERROR_INTERNAL Internal error
993 int _uam_request_set_detection_threshold(unsigned int sensor_type,
994 int presence_threshold, int absence_threshold);
997 * @brief Sets low-power mode.
1000 * @param[in] sensor The sensor type
1001 * @param[in] on_off Low power mode enable or not
1003 * @return 0 on success, otherwise a negative error value
1004 * @retval #UAM_ERROR_NONE Successful
1005 * @retval #UAM_ERROR_INTERNAL Internal error
1011 int _uam_set_low_power_mode(unsigned int sensor_bitmask,
1015 * @brief Gets default service info.
1018 * @param[in] service Service information
1020 * @return 0 on success, otherwise a negative error value
1021 * @retval #UAM_ERROR_NONE Successful
1022 * @retval #UAM_ERROR_INVALID_PARAMETER Invalid parameters
1023 * @retval #UAM_ERROR_INTERNAL Internal error
1029 int _uam_get_default_service(uam_service_info_s *service);
1032 * @brief Registers service info.
1035 * @param[in] service Service information.
1037 * @return 0 on success, otherwise a negative error value
1038 * @retval #UAM_ERROR_NONE Successful
1039 * @retval #UAM_ERROR_INVALID_PARAMETER Invalid parameters
1040 * @retval #UAM_ERROR_INTERNAL Internal error
1046 int _uam_register_service(uam_service_info_s *service);
1049 * @brief Updates service info.
1052 * @param[in] service Service information.
1054 * @return 0 on success, otherwise a negative error value
1055 * @retval #UAM_ERROR_NONE Successful
1056 * @retval #UAM_ERROR_INVALID_PARAMETER Invalid parameters
1057 * @retval #UAM_ERROR_INTERNAL Internal error
1063 int _uam_update_service(uam_service_info_s *service);
1066 * @brief Unregisters service info.
1069 * @param[in] service Service information.
1071 * @return 0 on success, otherwise a negative error value
1072 * @retval #UAM_ERROR_NONE Successful
1073 * @retval #UAM_ERROR_INVALID_PARAMETER Invalid parameters
1074 * @retval #UAM_ERROR_INTERNAL Internal error
1080 int _uam_unregister_service(uam_service_info_s *service);
1083 * @brief Gets detction window size.
1086 * @param[out] window Window size
1088 * @return 0 on success, otherwise a negative error value
1089 * @retval #UAM_ERROR_NONE Successful
1090 * @retval #UAM_ERROR_INVALID_PARAMETER Invalid parameters
1091 * @retval #UAM_ERROR_INTERNAL Internal error
1097 int _uam_get_detection_window(unsigned int *window);
1100 * @brief Gets registered service list.
1103 * @remarks The @a service_list should be destroyed by using #g_free() and #g_ptr_array_free().
1105 * @param[out] service_list Service list array
1107 * @return 0 on success, otherwise a negative error value
1108 * @retval #UAM_ERROR_NONE Successful
1109 * @retval #UAM_ERROR_INVALID_PARAMETER Invalid parameters
1110 * @retval #UAM_ERROR_INTERNAL Internal error
1116 int _uam_get_registered_services(GPtrArray **service_list);
1119 * @brief Gets registered users list for a service.
1122 * @remarks The @a users_list should be destroyed by using #g_free() and #g_ptr_array_free().
1124 * @param[in] svc_name The service name
1125 * @param[out] users_list Users list array
1127 * @return 0 on success, otherwise a negative error value
1128 * @retval #UAM_ERROR_NONE Successful
1129 * @retval #UAM_ERROR_INVALID_PARAMETER Invalid parameters
1130 * @retval #UAM_ERROR_INTERNAL Internal error
1136 int _uam_request_get_service_users(char *svc_name, GPtrArray **users_list);
1139 * @brief Gets registered devices list for a service.
1142 * @remarks The @a devices_list should be destroyed by using #g_free() and #g_ptr_array_free().
1144 * @param[in] svc_name The service name
1145 * @param[out] devices_list Devices list array
1147 * @return 0 on success, otherwise a negative error value
1148 * @retval #UAM_ERROR_NONE Successful
1149 * @retval #UAM_ERROR_INVALID_PARAMETER Invalid parameters
1150 * @retval #UAM_ERROR_INTERNAL Internal error
1156 int _uam_request_get_service_devices(char *svc_name, GPtrArray **devices_list);
1159 * @brief Sets detction window.
1162 * @param[in] window Window size
1164 * @return 0 on success, otherwise a negative error value
1165 * @retval #UAM_ERROR_NONE Successful
1166 * @retval #UAM_ERROR_INVALID_PARAMETER Invalid parameters
1167 * @retval #UAM_ERROR_INTERNAL Internal error
1173 int _uam_set_detection_window(unsigned int window);
1176 * @brief Adds a user to the service.
1179 * @param[in] service Service idt.
1180 * @param[in] account User account.
1182 * @return 0 on success, otherwise a negative error value
1183 * @retval #UAM_ERROR_NONE Successful
1184 * @retval #UAM_ERROR_INVALID_PARAMETER Invalid parameters
1185 * @retval #UAM_ERROR_INTERNAL Internal error
1191 int _uam_service_add_user(const char *service, const char *account);
1194 * @brief Removes a user from the service.
1197 * @param[in] service Service idt.
1198 * @param[in] account User account.
1200 * @return 0 on success, otherwise a negative error value
1201 * @retval #UAM_ERROR_NONE Successful
1202 * @retval #UAM_ERROR_INVALID_PARAMETER Invalid parameters
1203 * @retval #UAM_ERROR_INTERNAL Internal error
1209 int _uam_service_remove_user(const char *service, const char *account);
1212 * @brief Adds a device to the service.
1215 * @param[in] service Service idt.
1216 * @param[in] device_id Device id.
1217 * @param[in] tech_type Sensor type.
1219 * @return 0 on success, otherwise a negative error value
1220 * @retval #UAM_ERROR_NONE Successful
1221 * @retval #UAM_ERROR_INVALID_PARAMETER Invalid parameters
1222 * @retval #UAM_ERROR_INTERNAL Internal error
1228 int _uam_service_add_device(const char *service, char *device_id,
1229 uam_tech_type_e tech_type);
1232 * @brief Removes a device from the service.
1235 * @param[in] service Service idt.
1236 * @param[in] device_id Device id.
1237 * @param[in] tech_type Sensor type.
1239 * @return 0 on success, otherwise a negative error value
1240 * @retval #UAM_ERROR_NONE Successful
1241 * @retval #UAM_ERROR_INVALID_PARAMETER Invalid parameters
1242 * @retval #UAM_ERROR_INTERNAL Internal error
1248 int _uam_service_remove_device(const char *service, char *device_id,
1249 uam_tech_type_e tech_type);
1252 * @brief Sets a device discriminant for the service.
1255 * @param[in] service Service idt.
1256 * @param[in] device_id Device id.
1257 * @param[in] tech_type Sensor type.
1258 * @param[in] discriminant Device discriminant.
1260 * @return 0 on success, otherwise a negative error value
1261 * @retval #UAM_ERROR_NONE Successful
1262 * @retval #UAM_ERROR_INVALID_PARAMETER Invalid parameters
1263 * @retval #UAM_ERROR_INTERNAL Internal error
1269 int _uam_service_set_device_discriminant(const char *service,
1270 const char *device_id, uam_tech_type_e tech_type, gboolean discriminant);
1273 * @brief Gets a device discriminant for the service.
1276 * @param[in] service Service idt.
1277 * @param[in] device_id Device id.
1278 * @param[in] tech_type Sensor type.
1279 * @param[out] discriminant Device discriminant.
1281 * @return 0 on success, otherwise a negative error value
1282 * @retval #UAM_ERROR_NONE Successful
1283 * @retval #UAM_ERROR_INVALID_PARAMETER Invalid parameters
1284 * @retval #UAM_ERROR_INTERNAL Internal error
1290 int _uam_service_get_device_discriminant(const char *service,
1291 const char *device_id, uam_tech_type_e tech_type, gboolean *discriminant);
1294 * @brief Gets the last seen time for the device linked in the service.
1297 * @param[in] service Service idt.
1298 * @param[in] device_id Device id.
1299 * @param[in] tech_type Sensor type.
1300 * @param[out] last_seen The last seen time.
1302 * @return 0 on success, otherwise a negative error value
1303 * @retval #UAM_ERROR_NONE Successful
1304 * @retval #UAM_ERROR_INVALID_PARAMETER Invalid parameters
1305 * @retval #UAM_ERROR_INTERNAL Internal error
1311 int _uam_service_get_device_last_seen(const char *service,
1312 const char *device_id, uam_tech_type_e tech_type, unsigned long long *last_seen);
1315 * @brief Sets detction cycle per eash service.
1318 * @param[in] service Service id
1319 * @param[in] cycle The cycle number of the service.
1321 * @return 0 on success, otherwise a negative error value
1322 * @retval #UAM_ERROR_NONE Successful
1323 * @retval #UAM_ERROR_INVALID_PARAMETER Invalid parameters
1324 * @retval #UAM_ERROR_INTERNAL Internal error
1330 int _uam_set_service_detection_cycle(const char *service, unsigned int cycle);
1333 * @brief Gets detction cycle per eash service.
1336 * @param[in] service Service id
1337 * @param[out] cycle The cycle number of the service.
1339 * @return 0 on success, otherwise a negative error value
1340 * @retval #UAM_ERROR_NONE Successful
1341 * @retval #UAM_ERROR_INVALID_PARAMETER Invalid parameters
1342 * @retval #UAM_ERROR_INTERNAL Internal error
1348 int _uam_get_service_detection_cycle(const char *service, unsigned int *cycle);
1351 * @brief Resets contents in database.
1354 * @return 0 on success, otherwise a negative error value
1355 * @retval #UAM_ERROR_NONE Successful
1356 * @retval #UAM_ERROR_INTERNAL Internal error
1362 int _uam_db_reset(void);
1365 * @brief Updates the device.
1368 * @param[in] device Device information.
1370 * @return 0 on success, otherwise a negative error value
1371 * @retval #UAM_ERROR_NONE Successful
1372 * @retval #UAM_ERROR_INVALID_PARAMETER Invalid parameters
1373 * @retval #UAM_ERROR_INTERNAL Internal error
1379 int _uam_request_update_device(uam_device_info_s *device);
1382 * @brief Sets iBeacon ibeacon adevertising data.
1385 * @param[in] adv_len The iBeacon adevertising data's length.
1386 * @param[in] ibeacon_adv The iBeacon adevertising data.
1388 * @return 0 on success, otherwise a negative error value
1389 * @retval #UAM_ERROR_NONE Successful
1390 * @retval #UAM_ERROR_INVALID_PARAMETER Invalid parameter
1396 int _uam_add_ibeacon_adv_data(unsigned int adv_len, const char *ibeacon_adv);
1401 #endif /* __TIZEN_UA_NETWORK_UA_API_H__ */