diff options
author | Abhay agarwal <ay.agarwal@samsung.com> | 2019-11-28 17:07:18 +0530 |
---|---|---|
committer | DoHyun Pyun <dh79.pyun@samsung.com> | 2019-12-30 16:45:56 +0900 |
commit | 81f5eb29a74ca3f165063159fd72e5fed447121c (patch) | |
tree | cb2920fe5ef3e088f7a5cac674a5b8750f6e472e /include | |
parent | 9066a346acbb313a18344bcf93303823ee6996ba (diff) | |
download | user-awareness-81f5eb29a74ca3f165063159fd72e5fed447121c.tar.gz user-awareness-81f5eb29a74ca3f165063159fd72e5fed447121c.tar.bz2 user-awareness-81f5eb29a74ca3f165063159fd72e5fed447121c.zip |
Add handle for payload
Signed-off-by: Abhay agarwal <ay.agarwal@samsung.com>
Diffstat (limited to 'include')
-rw-r--r-- | include/user-awareness-private.h | 33 | ||||
-rw-r--r-- | include/user-awareness.h | 317 |
2 files changed, 213 insertions, 137 deletions
diff --git a/include/user-awareness-private.h b/include/user-awareness-private.h index bd83179..7e047f7 100644 --- a/include/user-awareness-private.h +++ b/include/user-awareness-private.h @@ -69,7 +69,6 @@ extern "C" { return UA_ERROR_NOT_FOUND; \ } - /** * @brief Prints arg. * @since_tizen 5.5 @@ -81,6 +80,13 @@ extern "C" { * @brief Prints arg. * @since_tizen 5.5 */ +#define UA_PRINT_PAYLOAD_HANDLE(arg) \ + UA_INFO("Payload Handle [%p]", #arg); \ + +/** + * @brief Prints arg. + * @since_tizen 5.5 + */ #define UA_PRINT_USER_HANDLE(arg) \ UA_INFO("User Handle [%p]", #arg); \ @@ -289,12 +295,14 @@ typedef enum { * @since_tizen 5.5 */ typedef struct { + ua_payload_h handle; /**< Payload handle */ char primary_key; /**< primary key for manufacturer data */ - char device_icon; /**< device icon for manufacturer data */ char secondary_key; /**< secondary_key for manufacturer data */ + char device_icon; /**< device icon for manufacturer data */ char *device_uid; /**< device_uid for manufacturer data */ char *bt_mac; /**< bt mac address of device */ -} ua_ble_payload_s; + gboolean isadded; /**< Is the payload addition completed? */ +} ua_payload_info_s; /** * @brief Device info data structure. @@ -316,7 +324,6 @@ typedef struct { gboolean create_by_app; /**< Did app add this device information? */ gboolean discriminant; /**< Determines whether to judge PRESENCE/ABSENCE */ unsigned long long last_seen; /**< The time of last presence */ - ua_ble_payload_s *payload; /**< BLE payload to filter device*/ } ua_dev_info_s; /** @@ -471,9 +478,9 @@ void _ua_free_ua_service_info_s(gpointer data); * @pre * @post * - * @see _ua_free_ua_ble_payload_s() + * @see _ua_free_ua_payload_info_s() */ -void _ua_create_ua_ble_payload_s(ua_ble_payload_s **payload_handle); +void _ua_create_ua_payload_info_s(ua_payload_info_s **payload_handle); /** * @brief Destroys a payload handle. @@ -485,9 +492,9 @@ void _ua_create_ua_ble_payload_s(ua_ble_payload_s **payload_handle); * @pre * @post * - * @see _ua_create_ua_ble_payload_s() + * @see _ua_create_ua_payload_info_s() */ -void _ua_free_ua_ble_payload_s(gpointer data); +void _ua_free_ua_payload_info_s(gpointer data); /** * @brief Return payload handle from uam_ble_payload_s. @@ -500,12 +507,12 @@ void _ua_free_ua_ble_payload_s(gpointer data); * @pre * @post * - * @see _ua_free_ua_ble_payload_s() + * @see _ua_free_ua_payload_info_s() */ -ua_ble_payload_s* _ua_get_payload_from_uam(uam_ble_payload_s *uam_payload); +ua_payload_info_s* _ua_get_payload_from_uam(uam_ble_payload_s *uam_payload); /** - * @brief Creates payload handle of uam_ble_payload_s type from ua_ble_payload_s. + * @brief Creates payload handle of uam_ble_payload_s type from ua_payload_info_s. * @since_tizen 5.5 * * @param[in] payload Payload handle. @@ -515,7 +522,7 @@ ua_ble_payload_s* _ua_get_payload_from_uam(uam_ble_payload_s *uam_payload); * @pre * @post */ -void _ua_get_uam_payload_from_ua(uam_ble_payload_s *uam_payload, ua_ble_payload_s *payload); +void _ua_get_uam_payload_from_ua(uam_ble_payload_s *uam_payload, ua_payload_info_s *payload); /** * @brief Returns a cloned copy of payload handle. @@ -528,7 +535,7 @@ void _ua_get_uam_payload_from_ua(uam_ble_payload_s *uam_payload, ua_ble_payload_ * @pre * @post */ -ua_ble_payload_s* _ua_payload_clone(ua_ble_payload_s *org_payload); +ua_payload_info_s* _ua_payload_clone(ua_payload_info_s *org_payload); /** * @brief Add a device handle to internal device-list. diff --git a/include/user-awareness.h b/include/user-awareness.h index 6229bbc..21fdc2d 100644 --- a/include/user-awareness.h +++ b/include/user-awareness.h @@ -292,6 +292,13 @@ typedef void *ua_device_h; /** * @ingroup CAPI_NETWORK_UA_MODULE + * @brief The handle of payload information. + * @since_tizen 5.5 + */ +typedef void *ua_payload_h; + +/** + * @ingroup CAPI_NETWORK_UA_MODULE * @brief Callback to be invoked if a sensor state changed (ready <-> not ready). * @since_tizen 5.5 * @@ -2618,156 +2625,185 @@ int ua_device_get_discriminant( * @see ua_device_set_os_info() * @see ua_device_set_wifi_ipv4_address() * @see ua_device_set_discriminant() - * @see ua_device_set_payload_primary_key() - * @see ua_device_set_payload_device_icon() - * @see ua_device_set_payload_secondary_key() - * @see ua_device_set_payload_device_uid() */ int ua_device_update( ua_device_h device_handle); /** * @ingroup CAPI_NETWORK_UA_MODULE - * @brief Sets BLE payload primary_key for device. + * @brief Gets device handle by MAC address. * @since_tizen 5.5 * - * @param[in] handle The device handle. - * @param[in] primary_key The BLE payload primary_key. + * @remarks The @a device_handle should not be released. + * @remarks The @a device_handle can be used only in the function. + * + * @param[in] mac The device's MAC address + * @param[out] device_handle The device handle * * @return 0 on success, otherwise a negative error value * @retval #UA_ERROR_NONE Successful * @retval #UA_ERROR_INVALID_PARAMETER Invalid parameter + * @retval #UA_ERROR_OUT_OF_MEMORY Out of memory * * @exception * @pre * @post * - * @see ua_device_get_payload_primary_key() */ -int ua_device_set_payload_primary_key( - ua_device_h handle, - const char primary_key); +int ua_device_get_by_mac_address( + const char *mac, + ua_device_h *device_handle); /** * @ingroup CAPI_NETWORK_UA_MODULE - * @brief Sets BLE payload device_icon for device. + * @brief Gets device handle by device ID. * @since_tizen 5.5 * - * @param[in] handle The device handle. - * @param[in] device_icon The BLE payload device_icon. + * @remarks The @a device_handle should not be released. + * @remarks The @a device_handle can be used only in the function. + * + * @param[in] device_id The device ID + * @param[in] mac_type The device's MAC type + * @param[out] device_handle The device handle. * * @return 0 on success, otherwise a negative error value * @retval #UA_ERROR_NONE Successful * @retval #UA_ERROR_INVALID_PARAMETER Invalid parameter + * @retval #UA_ERROR_OUT_OF_MEMORY Out of memory * * @exception * @pre * @post * - * @see ua_device_get_payload_device_icon() */ -int ua_device_set_payload_device_icon( - ua_device_h handle, - const char device_icon); +int ua_device_get_by_device_id( + const char *device_id, + ua_mac_type_e mac_type, + ua_device_h * device_handle); /** * @ingroup CAPI_NETWORK_UA_MODULE - * @brief Sets BLE payload secondary_key for device. + * @brief Removes the device by MAC address. * @since_tizen 5.5 * - * @param[in] handle The device handle. - * @param[in] secondary_key The BLE payload secondary_key. + * @param[in] mac The device's MAC address. * * @return 0 on success, otherwise a negative error value * @retval #UA_ERROR_NONE Successful + * @retcal #UA_ERROR_RESOURCE_BUSY Remove done. but another service uses thie device. * @retval #UA_ERROR_INVALID_PARAMETER Invalid parameter * * @exception * @pre * @post * - * @see ua_device_get_payload_secondary_key() + * @see ua_user_remove_device_by_device_id() */ -int ua_device_set_payload_secondary_key( - ua_device_h handle, - const char secondary_key); +int ua_user_remove_device_by_mac_address( + const char *mac); /** * @ingroup CAPI_NETWORK_UA_MODULE - * @brief Sets BLE payload DEVICE_UID for device. + * @brief Removes the device ID. * @since_tizen 5.5 * - * @remarks The @a device_uid is expected to be exact 17 bytes long data - * and may have intermediate NULLs + * @param[in] device_id The device ID. + * @param[in] mac_type The device's MAC address type. * - * @param[in] handle The device handle. - * @param[in] device_uid_len The BLE payload DEVICE_UID's length. - * @param[in] device_uid The BLE payload DEVICE_UID. + * @return 0 on success, otherwise a negative error value + * @retval #UA_ERROR_NONE Successful + * @retcal #UA_ERROR_RESOURCE_BUSY Remove done. but another service uses thie device. + * @retval #UA_ERROR_INVALID_PARAMETER Invalid parameter + * + * @exception + * @pre + * @post + * + * @see ua_user_remove_device_by_mac_address() + */ +int ua_user_remove_device_by_device_id( + const char *device_id, + ua_mac_type_e mac_type); + +/** + * @ingroup CAPI_NETWORK_UA_MODULE + * @brief Retrieves the device handle of all the registered devices. + * @since_tizen 5.5 + * + * @param[in] foreach_cb Callback function to be invoked with all device handle. + * @param[in] user_data The user data to be passed when callback is called. * * @return 0 on success, otherwise a negative error value * @retval #UA_ERROR_NONE Successful * @retval #UA_ERROR_INVALID_PARAMETER Invalid parameter + * @retval #UA_ERROR_OUT_OF_MEMORY Out of memory * * @exception * @pre * @post * - * @see ua_device_get_payload_device_uid() + * @see ua_registered_dev_cb() */ -int ua_device_set_payload_device_uid( - ua_device_h handle, - unsigned int device_uid_len, - const char *device_uid); +int ua_device_foreach_added( + ua_registered_dev_cb foreach_cb, + void *user_data); /** * @ingroup CAPI_NETWORK_UA_MODULE - * @brief Sets iBeacon adevertising data. + * @brief Retrieves the device handle of all the registered devices for one specific user. * @since_tizen 5.5 * - * @param[in] adv_len The iBeacon adevertising data's length. - * @param[in] ibeacon_adv The iBeacon adevertising data. + * @param[in] user_handle The user handle. + * @param[in] foreach_cb Callback function to be invoked with user device handle. + * @param[in] user_data The user data to be passed when callback is called. * * @return 0 on success, otherwise a negative error value * @retval #UA_ERROR_NONE Successful * @retval #UA_ERROR_INVALID_PARAMETER Invalid parameter + * @retval #UA_ERROR_OUT_OF_MEMORY Out of memory * * @exception * @pre * @post + * + * @see ua_registered_dev_cb() */ -int ua_add_ibeacon_adv_data( - unsigned int adv_len, - const char *ibeacon_adv); +int ua_device_foreach_added_by_user( + ua_user_h user_handle, + ua_registered_dev_cb foreach_cb, + void *user_data); /** * @ingroup CAPI_NETWORK_UA_MODULE - * @brief Gets device's BLE payload primary_key. + * @brief Creates the payload handle. * @since_tizen 5.5 * - * @param[in] handle The device handle. - * @param[out] primary_key The BLE payload primary_key. + * @remarks The @a payload_handle should be destroyed by using #ua_payload_destroy(). + * + * @param[out] payload_handle The payload handle * * @return 0 on success, otherwise a negative error value * @retval #UA_ERROR_NONE Successful * @retval #UA_ERROR_INVALID_PARAMETER Invalid parameter + * @retval #UA_ERROR_OUT_OF_MEMORY Out of memory * * @exception * @pre * @post * - * @see ua_device_set_payload_primary_key() + * @see ua_payload_destroy() */ -int ua_device_get_payload_primary_key( - ua_device_h handle, - char *primary_key); +int ua_payload_create( + ua_payload_h * payload_handle); /** * @ingroup CAPI_NETWORK_UA_MODULE - * @brief Gets device's BLE payload device_icon. + * @brief Destroys the payload handle. * @since_tizen 5.5 * - * @param[in] handle The device handle. - * @param[out] device_icon The BLE payload device_icon. + * @remarks Payload context will removed and all allocated memory (if any) will be released. + * + * @param[in] payload_handle The payload handle * * @return 0 on success, otherwise a negative error value * @retval #UA_ERROR_NONE Successful @@ -2777,19 +2813,18 @@ int ua_device_get_payload_primary_key( * @pre * @post * - * @see ua_device_set_payload_device_icon() + * @see ua_payload_create() */ -int ua_device_get_payload_device_icon( - ua_device_h handle, - char *device_icon); +int ua_payload_destroy( + ua_payload_h payload_handle); /** * @ingroup CAPI_NETWORK_UA_MODULE - * @brief Gets device's BLE payload secondary_key. + * @brief Sets BLE payload primary_key for device. * @since_tizen 5.5 * - * @param[in] handle The device handle. - * @param[out] secondary_key The BLE payload secondary_key. + * @param[in] handle The payload handle. + * @param[in] primary_key The BLE payload primary_key. * * @return 0 on success, otherwise a negative error value * @retval #UA_ERROR_NONE Successful @@ -2799,21 +2834,41 @@ int ua_device_get_payload_device_icon( * @pre * @post * - * @see ua_device_set_payload_secondary_key() + * @see ua_payload_get_primary_key() */ -int ua_device_get_payload_secondary_key( - ua_device_h handle, - char *secondary_key); +int ua_payload_set_primary_key( + ua_payload_h handle, + const char primary_key); /** * @ingroup CAPI_NETWORK_UA_MODULE - * @brief Gets device's BLE payload DEVICE_UID. + * @brief Sets BLE payload device_icon for device. * @since_tizen 5.5 * - * @remarks You must release @a device_uid using g_free(). + * @param[in] handle The payload handle. + * @param[in] device_icon The BLE payload device_icon. * - * @param[in] handle The device handle. - * @param[out] device_uid The BLE payload DEVICE_UID. + * @return 0 on success, otherwise a negative error value + * @retval #UA_ERROR_NONE Successful + * @retval #UA_ERROR_INVALID_PARAMETER Invalid parameter + * + * @exception + * @pre + * @post + * + * @see ua_payload_get_device_icon() + */ +int ua_payload_set_device_icon( + ua_payload_h handle, + const char device_icon); + +/** + * @ingroup CAPI_NETWORK_UA_MODULE + * @brief Sets BLE payload secondary_key for device. + * @since_tizen 5.5 + * + * @param[in] handle The payload handle. + * @param[in] secondary_key The BLE payload secondary_key. * * @return 0 on success, otherwise a negative error value * @retval #UA_ERROR_NONE Successful @@ -2823,155 +2878,169 @@ int ua_device_get_payload_secondary_key( * @pre * @post * - * @see ua_device_set_payload_device_uid() + * @see ua_payload_get_secondary_key() */ -int ua_device_get_payload_device_uid( - ua_device_h handle, - char **device_uid); +int ua_payload_set_secondary_key( + ua_payload_h handle, + const char secondary_key); /** * @ingroup CAPI_NETWORK_UA_MODULE - * @brief Gets device handle by MAC address. + * @brief Sets BLE payload DEVICE_UID for device. * @since_tizen 5.5 * - * @remarks The @a device_handle should not be released. - * @remarks The @a device_handle can be used only in the function. + * @remarks The @a device_uid is expected to be exact 17 bytes long data + * and may have intermediate NULLs * - * @param[in] mac The device's MAC address - * @param[out] device_handle The device handle + * @param[in] handle The payload handle. + * @param[in] device_uid_len The BLE payload DEVICE_UID's length. + * @param[in] device_uid The BLE payload DEVICE_UID. * * @return 0 on success, otherwise a negative error value * @retval #UA_ERROR_NONE Successful * @retval #UA_ERROR_INVALID_PARAMETER Invalid parameter - * @retval #UA_ERROR_OUT_OF_MEMORY Out of memory * * @exception * @pre * @post * + * @see ua_payload_get_device_uid() */ -int ua_device_get_by_mac_address( - const char *mac, - ua_device_h *device_handle); +int ua_payload_set_device_uid( + ua_payload_h handle, + unsigned int device_uid_len, + const char *device_uid); /** * @ingroup CAPI_NETWORK_UA_MODULE - * @brief Gets device handle by device ID. + * @brief Sets iBeacon adevertising data. * @since_tizen 5.5 * - * @remarks The @a device_handle should not be released. - * @remarks The @a device_handle can be used only in the function. + * @param[in] adv_len The iBeacon adevertising data's length. + * @param[in] ibeacon_adv The iBeacon adevertising data. * - * @param[in] device_id The device ID - * @param[in] mac_type The device's MAC type - * @param[out] device_handle The device handle. + * @return 0 on success, otherwise a negative error value + * @retval #UA_ERROR_NONE Successful + * @retval #UA_ERROR_INVALID_PARAMETER Invalid parameter + * + * @exception + * @pre + * @post + */ +int ua_add_ibeacon_adv_data( + unsigned int adv_len, + const char *ibeacon_adv); + +/** + * @ingroup CAPI_NETWORK_UA_MODULE + * @brief Gets device's BLE payload primary_key. + * @since_tizen 5.5 + * + * @param[in] handle The payload handle. + * @param[out] primary_key The BLE payload primary_key. * * @return 0 on success, otherwise a negative error value * @retval #UA_ERROR_NONE Successful * @retval #UA_ERROR_INVALID_PARAMETER Invalid parameter - * @retval #UA_ERROR_OUT_OF_MEMORY Out of memory * * @exception * @pre * @post * + * @see ua_payload_set_primary_key() */ -int ua_device_get_by_device_id( - const char *device_id, - ua_mac_type_e mac_type, - ua_device_h * device_handle); +int ua_payload_get_primary_key( + ua_payload_h handle, + char *primary_key); /** * @ingroup CAPI_NETWORK_UA_MODULE - * @brief Removes the device by MAC address. + * @brief Gets device's BLE payload device_icon. * @since_tizen 5.5 * - * @param[in] mac The device's MAC address. + * @param[in] handle The payload handle. + * @param[out] device_icon The BLE payload device_icon. * * @return 0 on success, otherwise a negative error value * @retval #UA_ERROR_NONE Successful - * @retcal #UA_ERROR_RESOURCE_BUSY Remove done. but another service uses thie device. * @retval #UA_ERROR_INVALID_PARAMETER Invalid parameter * * @exception * @pre * @post * - * @see ua_user_remove_device_by_device_id() + * @see ua_payload_set_device_icon() */ -int ua_user_remove_device_by_mac_address( - const char *mac); +int ua_payload_get_device_icon( + ua_payload_h handle, + char *device_icon); /** * @ingroup CAPI_NETWORK_UA_MODULE - * @brief Removes the device ID. + * @brief Gets device's BLE payload secondary_key. * @since_tizen 5.5 * - * @param[in] device_id The device ID. - * @param[in] mac_type The device's MAC address type. + * @param[in] handle The payload handle. + * @param[out] secondary_key The BLE payload secondary_key. * - * @return 0 on success, otherwise a negative error value + * @return 0 on success, otherwise a negative error value * @retval #UA_ERROR_NONE Successful - * @retcal #UA_ERROR_RESOURCE_BUSY Remove done. but another service uses thie device. * @retval #UA_ERROR_INVALID_PARAMETER Invalid parameter * * @exception * @pre * @post * - * @see ua_user_remove_device_by_mac_address() + * @see ua_payload_set_secondary_key() */ -int ua_user_remove_device_by_device_id( - const char *device_id, - ua_mac_type_e mac_type); +int ua_payload_get_secondary_key( + ua_payload_h handle, + char *secondary_key); /** * @ingroup CAPI_NETWORK_UA_MODULE - * @brief Retrieves the device handle of all the registered devices. + * @brief Gets device's BLE payload DEVICE_UID. * @since_tizen 5.5 * - * @param[in] foreach_cb Callback function to be invoked with all device handle. - * @param[in] user_data The user data to be passed when callback is called. + * @remarks You must release @a device_uid using g_free(). + * + * @param[in] handle The payload handle. + * @param[out] device_uid The BLE payload DEVICE_UID. * * @return 0 on success, otherwise a negative error value * @retval #UA_ERROR_NONE Successful * @retval #UA_ERROR_INVALID_PARAMETER Invalid parameter - * @retval #UA_ERROR_OUT_OF_MEMORY Out of memory * * @exception * @pre * @post * - * @see ua_registered_dev_cb() + * @see ua_payload_set_device_uid() */ -int ua_device_foreach_added( - ua_registered_dev_cb foreach_cb, - void *user_data); +int ua_payload_get_device_uid( + ua_payload_h handle, + char **device_uid); /** * @ingroup CAPI_NETWORK_UA_MODULE - * @brief Retrieves the device handle of all the registered devices for one specific user. + * @brief Adds device's payload. * @since_tizen 5.5 * - * @param[in] user_handle The user handle. - * @param[in] foreach_cb Callback function to be invoked with user device handle. - * @param[in] user_data The user data to be passed when callback is called. + * @param[in] payload_handle The payload handle. + * @param[in] device_handle The device handle. * * @return 0 on success, otherwise a negative error value * @retval #UA_ERROR_NONE Successful * @retval #UA_ERROR_INVALID_PARAMETER Invalid parameter - * @retval #UA_ERROR_OUT_OF_MEMORY Out of memory * * @exception * @pre * @post * - * @see ua_registered_dev_cb() */ -int ua_device_foreach_added_by_user( - ua_user_h user_handle, - ua_registered_dev_cb foreach_cb, - void *user_data); +int ua_payload_add( + ua_payload_h payload_handle, + ua_device_h device_handle); /** * @ingroup CAPI_NETWORK_UA_MODULE |