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 OS type.
453 UAM_OS_TYPE_UNDEFINED = 0x00, /**< Undefined */
454 UAM_OS_TYPE_TIZEN, /**< Tizen */
455 UAM_OS_TYPE_ANDROID, /**< Android */
456 UAM_OS_TYPE_IOS, /**< iOS */
457 UAM_OS_TYPE_INVALID /**< Invalid */
461 * @brief Enumerations for connectivity type.
465 UAM_TECH_TYPE_NONE = 0x00, /**< None */
466 UAM_TECH_TYPE_BT = 0x01, /**< BT */
467 UAM_TECH_TYPE_BLE = 0x02, /**< BLE */
468 UAM_TECH_TYPE_WIFI = 0x04, /**< Wi-Fi */
469 UAM_TECH_TYPE_P2P = 0x08, /**< Wi-Fi p2p */
470 UAM_TECH_TYPE_MAX /**< Max. connectivity type */
474 * @brief BLE Payload info structure.
478 char service_id; /** Service Id */
479 char device_icon; /** Device icon */
480 char purpose; /** Purpose */
481 char duid[UAM_BLE_PAYLOAD_DUID_LEN + 1]; /** DUID */
482 char bt_mac[UAM_BT_MAC_ADDRESS_STRING_LEN]; /** BT MAC Address */
486 * @brief Device info structure.
490 uam_os_type_e operating_system; /**< Operating system */
491 uam_tech_type_e type; /**< Device's mac address type (BT/BLE/WIFI/P2p/...) */
492 char mac[UAM_MAC_ADDRESS_STRING_LEN]; /**< Device's MAC ADDRESS */
493 char ipv4_addr[UAM_IP_ADDRESS_MAX_STRING_LEN];/**< Device's IPv4 address optional */
494 char device_id[UAM_DEVICE_ID_MAX_STRING_LEN]; /**< Device's uniquie ID */
495 uam_ble_payload_s payload; /**< BLE Payload to parse BLE devices*/
496 gboolean discriminant; /**< Determines whether to judge PRESENCE/ABSENCE */
497 long last_seen; /**< Latest timestamp when device was discoverd */
501 * @brief Sensor info structure.
505 unsigned int status; /**< Sensor status */
506 unsigned int sensor_bitmask; /**< sensor bitmask of discovered sensor */
507 long timestamp; /**< Latest timestamp when sensor was discoverd */
508 int accuracy; /**< Accuracy info from sensor sensor */
509 int count; /**< count of values from sensor sensor */
510 double values[UAM_SENSOR_MAX_VALUES]; /**< info from sensor */
514 * @brief User info structure.
518 char account[UAM_USER_ACCOUNT_MAX_STRING_LEN]; /**< User account */
519 char name[UAM_USER_NAME_MAX_STRING_LEN]; /**< User name */
523 * @brief Service info structure.
527 char name[UAM_SERVICE_MAX_STRING_LEN]; /**< Service name */
528 unsigned int presence_threshold;
529 unsigned int absence_threshold;
530 } uam_service_info_s;
533 * @brief Detection event structure.
537 unsigned int sensor_bitmask; /**< Detecting sensor's bitmask */
538 char account[UAM_USER_ACCOUNT_MAX_STRING_LEN]; /**< User account */
539 char service[UAM_SERVICE_MAX_STRING_LEN]; /**< Service name */
540 long timestamp; /**< Timestamp of detection */
541 char device_id[UAM_DEVICE_ID_MAX_STRING_LEN]; /**< Device's unique ID */
542 } uam_detection_event_data_s;
545 * @brief User event structure.
549 char account[UAM_USER_ACCOUNT_MAX_STRING_LEN]; /**< User account */
550 char name[UAM_USER_NAME_MAX_STRING_LEN]; /**< User name */
551 } uam_user_event_data_s;
554 * @brief Application info structure.
558 char *sender; /**< Dbus sender */
559 unsigned short uid; /**< UID */
560 char app_id[UAM_APP_ID_MAX_STRING_LEN]; /**< Application id */
564 * @brief Gets registered user list.
567 * @remarks The @a user_list should be destroyed by using #g_free() and #g_ptr_array_free().
569 * @param[out] user_list User list array
571 * @return 0 on success, otherwise a negative error value
572 * @retval #UAM_ERROR_NONE Successful
573 * @retval #UAM_ERROR_INVALID_PARAMETER Invalid parameters
574 * @retval #UAM_ERROR_INTERNAL Internal error
580 int _uam_get_registered_users(GPtrArray **user_list);
583 * @brief Checks registerd device.
586 * @param[in] dev_info Device info
587 * @param[out] is_registered Registered or not
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_is_device_registered(
599 uam_device_info_s *dev_info, gboolean *is_registered);
602 * @brief Callback to be called when receiving events.
605 * @remarks The @a event_param should not be released.
606 * @remarks The @a event_param can be used only in the callback.
608 * @param[in] event Event type
609 * @param[in] event_param Event data
610 * @param[in] user_data User data passed in _uam_init().
612 * @return 0 on success, otherwise a negative error value
613 * @retval #UAM_ERROR_NONE Successful
614 * @retval #UAM_ERROR_INVALID_PARAMETER Invalid parameters
615 * @retval #UAM_ERROR_INTERNAL Internal error
621 typedef void (*uam_event_cb)(int event, uam_event_data_s *event_param, void *user_data);
624 * @brief Intializes a client library of ua-manager.
627 * @param[in] cb Event callback
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 int _uam_init(uam_event_cb cb, void *user_data);
642 * @brief De-intializes a client library of ua-manager.
645 * @return 0 on success, otherwise a negative error value
646 * @retval #UAM_ERROR_NONE Successful
647 * @retval #UAM_ERROR_INTERNAL Internal error
653 int _uam_deinit(void);
656 * @brief Retrieves available sensor list.
659 * @param[in] bitmask Available sensor list
661 * @return 0 on success, otherwise a negative error value
662 * @retval #UAM_ERROR_NONE Successful
663 * @retval #UAM_ERROR_INVALID_PARAMETER Invalid parameters
664 * @retval #UAM_ERROR_INTERNAL Internal error
670 int _uam_get_available_sensors(unsigned int *bitmask);
673 * @brief Gets default user info.
676 * @param[in] uam_user User information
678 * @return 0 on success, otherwise a negative error value
679 * @retval #UAM_ERROR_NONE Successful
680 * @retval #UAM_ERROR_INVALID_PARAMETER Invalid parameters
681 * @retval #UAM_ERROR_INTERNAL Internal error
687 int _uam_get_default_user(uam_user_info_s *uam_user);
690 * @brief Adds user info.
693 * @param[in] user User information.
695 * @return 0 on success, otherwise a negative error value
696 * @retval #UAM_ERROR_NONE Successful
697 * @retval #UAM_ERROR_INVALID_PARAMETER Invalid parameters
698 * @retval #UAM_ERROR_INTERNAL Internal error
704 int _uam_add_user(uam_user_info_s *user);
707 * @brief Removes user info.
710 * @param[in] account User account.
712 * @return 0 on success, otherwise a negative error value
713 * @retval #UAM_ERROR_NONE Successful
714 * @retval #UAM_ERROR_INVALID_PARAMETER Invalid parameters
715 * @retval #UAM_ERROR_INTERNAL Internal error
721 int _uam_remove_user(char *account);
724 * @brief Brings user information that meet the user account.
727 * @remarks The @a user should not be released.
728 * @remarks The @a user can be used only in the function.
730 * @param[in] account User account.
731 * @param[out] user User information.
733 * @return 0 on success, otherwise a negative error value
734 * @retval #UAM_ERROR_NONE Successful
735 * @retval #UAM_ERROR_INVALID_PARAMETER Invalid parameters
736 * @retval #UAM_ERROR_INTERNAL Internal error
742 int _uam_request_get_user_by_account(char *account, uam_user_info_s *user);
745 * @brief Brings user information that meet the device id.
748 * @remarks The @a user should not be released.
749 * @remarks The @a user can be used only in the function.
751 * @param[in] device_id Device id.
752 * @param[out] user User information.
754 * @return 0 on success, otherwise a negative error value
755 * @retval #UAM_ERROR_NONE Successful
756 * @retval #UAM_ERROR_INVALID_PARAMETER Invalid parameters
757 * @retval #UAM_ERROR_INTERNAL Internal error
763 int _uam_request_get_user_by_deviceid(char *device_id, uam_user_info_s *user);
766 * @brief Brings user information that meet the MAC address.
769 * @remarks The @a user should not be released.
770 * @remarks The @a user can be used only in the function.
772 * @param[in] mac Mac address.
773 * @param[out] user User information.
775 * @return 0 on success, otherwise a negative error value
776 * @retval #UAM_ERROR_NONE Successful
777 * @retval #UAM_ERROR_INVALID_PARAMETER Invalid parameters
778 * @retval #UAM_ERROR_INTERNAL Internal error
784 int _uam_request_get_user_by_mac(char *mac, uam_user_info_s *user);
787 * @brief Requests to add a device info to the user.
790 * @param[in] account User account.
791 * @param[in] device Device information.
793 * @return 0 on success, otherwise a negative error value
794 * @retval #UAM_ERROR_NONE Successful
795 * @retval #UAM_ERROR_INVALID_PARAMETER Invalid parameters
796 * @retval #UAM_ERROR_INTERNAL Internal error
802 int _uam_request_add_device(char *account, uam_device_info_s *device);
805 * @brief Requests to remove a device info to the user.
808 * @param[in] account User account.
809 * @param[in] device Device information.
811 * @return 0 on success, otherwise a negative error value
812 * @retval #UAM_ERROR_NONE Successful
813 * @retval #UAM_ERROR_INVALID_PARAMETER Invalid parameters
814 * @retval #UAM_ERROR_INTERNAL Internal error
820 int _uam_request_remove_device(char *account, uam_device_info_s *device);
823 * @brief Deletes device information matching device id and sensor type.
826 * @param[in] device_id Device id.
827 * @param[in] tech_type Sensor type.
829 * @return 0 on success, otherwise a negative error value
830 * @retval #UAM_ERROR_NONE Successful
831 * @retval #UAM_ERROR_INVALID_PARAMETER Invalid parameters
832 * @retval #UAM_ERROR_INTERNAL Internal error
838 int _uam_request_remove_device_by_deviceid(const char *device_id,
839 uam_tech_type_e tech_type);
842 * @brief Deletes device information matching device MAC.
845 * @param[in] mac MAC address.
847 * @return 0 on success, otherwise a negative error value
848 * @retval #UAM_ERROR_NONE Successful
849 * @retval #UAM_ERROR_INVALID_PARAMETER Invalid parameters
850 * @retval #UAM_ERROR_INTERNAL Internal error
856 int _uam_request_remove_device_by_mac(const char *mac);
859 * @brief Retrieves device information matching device id.
862 * @remarks The @a device should not be released.
863 * @remarks The @a device can be used only in the function.
865 * @param[in] device_id Device id.
866 * @param[in] tech_type Sensor type.
867 * @param[out] device Device information.
869 * @return 0 on success, otherwise a negative error value
870 * @retval #UAM_ERROR_NONE Successful
871 * @retval #UAM_ERROR_INVALID_PARAMETER Invalid parameters
872 * @retval #UAM_ERROR_INTERNAL Internal error
878 int _uam_request_get_device_by_deviceid(const char *device_id,
879 uam_tech_type_e tech_type, uam_device_info_s *device);
882 * @brief Retrieves device information matching MAC address.
885 * @remarks The @a device should not be released.
886 * @remarks The @a device can be used only in the function.
888 * @param[in] mac MAC address.
889 * @param[out] device Device information.
891 * @return 0 on success, otherwise a negative error value
892 * @retval #UAM_ERROR_NONE Successful
893 * @retval #UAM_ERROR_INVALID_PARAMETER Invalid parameters
894 * @retval #UAM_ERROR_INTERNAL Internal error
900 int _uam_request_get_device_by_mac(const char *mac, uam_device_info_s *device);
903 * @brief Gets registered devices list.
906 * @remarks The @a devices_list should be destroyed by using #g_free() and #g_ptr_array_free().
908 * @param[out] devices_list Device list array
910 * @return 0 on success, otherwise a negative error value
911 * @retval #UAM_ERROR_NONE Successful
912 * @retval #UAM_ERROR_INVALID_PARAMETER Invalid parameters
913 * @retval #UAM_ERROR_INTERNAL Internal error
919 int _uam_request_get_devices(GPtrArray **devices_list);
922 * @brief Gets registered devices list per a user.
925 * @remarks The @a devices_list should be destroyed by using #g_free() and #g_ptr_array_free().
927 * @param[in] account User account.
928 * @param[out] devices_list Devices list
930 * @return 0 on success, otherwise a negative error value
931 * @retval #UAM_ERROR_NONE Successful
932 * @retval #UAM_ERROR_INVALID_PARAMETER Invalid parameters
933 * @retval #UAM_ERROR_INTERNAL Internal error
939 int _uam_request_get_user_devices(char *account, GPtrArray **devices_list);
942 * @brief Sets detection threshold.
945 * @param[in] sensor_type Sensor type.
946 * @param[in] presence_threshold Threshold value for presence.
947 * @param[in] absence_threshold Threshold value for absence.
949 * @return 0 on success, otherwise a negative error value
950 * @retval #UAM_ERROR_NONE Successful
951 * @retval #UAM_ERROR_INVALID_PARAMETER Invalid parameters
952 * @retval #UAM_ERROR_INTERNAL Internal error
958 int _uam_request_set_detection_threshold(unsigned int sensor_type,
959 int presence_threshold, int absence_threshold);
962 * @brief Sets low-power mode.
965 * @param[in] sensor The sensor type
966 * @param[in] on_off Low power mode enable or not
968 * @return 0 on success, otherwise a negative error value
969 * @retval #UAM_ERROR_NONE Successful
970 * @retval #UAM_ERROR_INTERNAL Internal error
976 int _uam_set_low_power_mode(unsigned int sensor_bitmask,
980 * @brief Gets default service info.
983 * @param[in] service Service information
985 * @return 0 on success, otherwise a negative error value
986 * @retval #UAM_ERROR_NONE Successful
987 * @retval #UAM_ERROR_INVALID_PARAMETER Invalid parameters
988 * @retval #UAM_ERROR_INTERNAL Internal error
994 int _uam_get_default_service(uam_service_info_s *service);
997 * @brief Registers service info.
1000 * @param[in] service Service information.
1002 * @return 0 on success, otherwise a negative error value
1003 * @retval #UAM_ERROR_NONE Successful
1004 * @retval #UAM_ERROR_INVALID_PARAMETER Invalid parameters
1005 * @retval #UAM_ERROR_INTERNAL Internal error
1011 int _uam_register_service(uam_service_info_s *service);
1014 * @brief Updates service info.
1017 * @param[in] service Service information.
1019 * @return 0 on success, otherwise a negative error value
1020 * @retval #UAM_ERROR_NONE Successful
1021 * @retval #UAM_ERROR_INVALID_PARAMETER Invalid parameters
1022 * @retval #UAM_ERROR_INTERNAL Internal error
1028 int _uam_update_service(uam_service_info_s *service);
1031 * @brief Unregisters service info.
1034 * @param[in] service Service information.
1036 * @return 0 on success, otherwise a negative error value
1037 * @retval #UAM_ERROR_NONE Successful
1038 * @retval #UAM_ERROR_INVALID_PARAMETER Invalid parameters
1039 * @retval #UAM_ERROR_INTERNAL Internal error
1045 int _uam_unregister_service(uam_service_info_s *service);
1048 * @brief Gets detction window size.
1051 * @param[out] window Window size
1053 * @return 0 on success, otherwise a negative error value
1054 * @retval #UAM_ERROR_NONE Successful
1055 * @retval #UAM_ERROR_INVALID_PARAMETER Invalid parameters
1056 * @retval #UAM_ERROR_INTERNAL Internal error
1062 int _uam_get_detection_window(unsigned int *window);
1065 * @brief Gets registered service list.
1068 * @remarks The @a service_list should be destroyed by using #g_free() and #g_ptr_array_free().
1070 * @param[out] service_list Service list array
1072 * @return 0 on success, otherwise a negative error value
1073 * @retval #UAM_ERROR_NONE Successful
1074 * @retval #UAM_ERROR_INVALID_PARAMETER Invalid parameters
1075 * @retval #UAM_ERROR_INTERNAL Internal error
1081 int _uam_get_registered_services(GPtrArray **service_list);
1084 * @brief Gets registered users list for a service.
1087 * @remarks The @a users_list should be destroyed by using #g_free() and #g_ptr_array_free().
1089 * @param[in] svc_name The service name
1090 * @param[out] users_list Users list array
1092 * @return 0 on success, otherwise a negative error value
1093 * @retval #UAM_ERROR_NONE Successful
1094 * @retval #UAM_ERROR_INVALID_PARAMETER Invalid parameters
1095 * @retval #UAM_ERROR_INTERNAL Internal error
1101 int _uam_request_get_service_users(char *svc_name, GPtrArray **users_list);
1104 * @brief Gets registered devices list for a service.
1107 * @remarks The @a devices_list should be destroyed by using #g_free() and #g_ptr_array_free().
1109 * @param[in] svc_name The service name
1110 * @param[out] devices_list Devices list array
1112 * @return 0 on success, otherwise a negative error value
1113 * @retval #UAM_ERROR_NONE Successful
1114 * @retval #UAM_ERROR_INVALID_PARAMETER Invalid parameters
1115 * @retval #UAM_ERROR_INTERNAL Internal error
1121 int _uam_request_get_service_devices(char *svc_name, GPtrArray **devices_list);
1124 * @brief Sets detction window.
1127 * @param[in] window Window size
1129 * @return 0 on success, otherwise a negative error value
1130 * @retval #UAM_ERROR_NONE Successful
1131 * @retval #UAM_ERROR_INVALID_PARAMETER Invalid parameters
1132 * @retval #UAM_ERROR_INTERNAL Internal error
1138 int _uam_set_detection_window(unsigned int window);
1141 * @brief Adds a user to the service.
1144 * @param[in] service Service idt.
1145 * @param[in] account User account.
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_service_add_user(const char *service, const char *account);
1159 * @brief Removes a user from the service.
1162 * @param[in] service Service idt.
1163 * @param[in] account User account.
1165 * @return 0 on success, otherwise a negative error value
1166 * @retval #UAM_ERROR_NONE Successful
1167 * @retval #UAM_ERROR_INVALID_PARAMETER Invalid parameters
1168 * @retval #UAM_ERROR_INTERNAL Internal error
1174 int _uam_service_remove_user(const char *service, const char *account);
1177 * @brief Adds a device to the service.
1180 * @param[in] service Service idt.
1181 * @param[in] device_id Device id.
1182 * @param[in] tech_type Sensor type.
1184 * @return 0 on success, otherwise a negative error value
1185 * @retval #UAM_ERROR_NONE Successful
1186 * @retval #UAM_ERROR_INVALID_PARAMETER Invalid parameters
1187 * @retval #UAM_ERROR_INTERNAL Internal error
1193 int _uam_service_add_device(const char *service, char *device_id,
1194 uam_tech_type_e tech_type);
1197 * @brief Removes a device from the service.
1200 * @param[in] service Service idt.
1201 * @param[in] device_id Device id.
1202 * @param[in] tech_type Sensor type.
1204 * @return 0 on success, otherwise a negative error value
1205 * @retval #UAM_ERROR_NONE Successful
1206 * @retval #UAM_ERROR_INVALID_PARAMETER Invalid parameters
1207 * @retval #UAM_ERROR_INTERNAL Internal error
1213 int _uam_service_remove_device(const char *service, char *device_id,
1214 uam_tech_type_e tech_type);
1217 * @brief Sets a device discriminant for the service.
1220 * @param[in] service Service idt.
1221 * @param[in] device_id Device id.
1222 * @param[in] tech_type Sensor type.
1223 * @param[in] discriminant Device discriminant.
1225 * @return 0 on success, otherwise a negative error value
1226 * @retval #UAM_ERROR_NONE Successful
1227 * @retval #UAM_ERROR_INVALID_PARAMETER Invalid parameters
1228 * @retval #UAM_ERROR_INTERNAL Internal error
1234 int _uam_service_set_device_discriminant(const char *service,
1235 const char *device_id, uam_tech_type_e tech_type, gboolean discriminant);
1238 * @brief Gets a device discriminant for the service.
1241 * @param[in] service Service idt.
1242 * @param[in] device_id Device id.
1243 * @param[in] tech_type Sensor type.
1244 * @param[out] discriminant Device discriminant.
1246 * @return 0 on success, otherwise a negative error value
1247 * @retval #UAM_ERROR_NONE Successful
1248 * @retval #UAM_ERROR_INVALID_PARAMETER Invalid parameters
1249 * @retval #UAM_ERROR_INTERNAL Internal error
1255 int _uam_service_get_device_discriminant(const char *service,
1256 const char *device_id, uam_tech_type_e tech_type, gboolean *discriminant);
1259 * @brief Sets detction cycle per eash service.
1262 * @param[in] service Service id
1263 * @param[in] cycle The cycle number of the service.
1265 * @return 0 on success, otherwise a negative error value
1266 * @retval #UAM_ERROR_NONE Successful
1267 * @retval #UAM_ERROR_INVALID_PARAMETER Invalid parameters
1268 * @retval #UAM_ERROR_INTERNAL Internal error
1274 int _uam_set_service_detection_cycle(const char *service, unsigned int cycle);
1277 * @brief Gets detction cycle per eash service.
1280 * @param[in] service Service id
1281 * @param[out] cycle The cycle number of the service.
1283 * @return 0 on success, otherwise a negative error value
1284 * @retval #UAM_ERROR_NONE Successful
1285 * @retval #UAM_ERROR_INVALID_PARAMETER Invalid parameters
1286 * @retval #UAM_ERROR_INTERNAL Internal error
1292 int _uam_get_service_detection_cycle(const char *service, unsigned int *cycle);
1295 * @brief Resets contents in database.
1298 * @return 0 on success, otherwise a negative error value
1299 * @retval #UAM_ERROR_NONE Successful
1300 * @retval #UAM_ERROR_INTERNAL Internal error
1306 int _uam_db_reset(void);
1309 * @brief Updates the device.
1312 * @param[in] device Device information.
1314 * @return 0 on success, otherwise a negative error value
1315 * @retval #UAM_ERROR_NONE Successful
1316 * @retval #UAM_ERROR_INVALID_PARAMETER Invalid parameters
1317 * @retval #UAM_ERROR_INTERNAL Internal error
1323 int _uam_request_update_device(uam_device_info_s *device);
1326 * @brief Sets iBeacon ibeacon adevertising data.
1329 * @param[in] adv_len The iBeacon adevertising data's length.
1330 * @param[in] ibeacon_adv The iBeacon adevertising data.
1332 * @return 0 on success, otherwise a negative error value
1333 * @retval #UAM_ERROR_NONE Successful
1334 * @retval #UAM_ERROR_INVALID_PARAMETER Invalid parameter
1340 int _uam_add_ibeacon_adv_data(unsigned int adv_len, const char *ibeacon_adv);
1345 #endif /* __TIZEN_UA_NETWORK_UA_API_H__ */