src/user-awareness-users.c
src/user-awareness-util.c
src/user-awareness-event-handler.c
+ src/user-awareness-payload.c
)
INCLUDE_DIRECTORIES(${CMAKE_CURRENT_SOURCE_DIR}/include)
return UA_ERROR_NOT_FOUND; \
}
-
/**
* @brief Prints arg.
* @since_tizen 5.5
#define UA_PRINT_DEVICE_HANDLE(arg) \
UA_INFO("Device Handle [%p]", #arg); \
+/**
+ * @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
* @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.
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;
/**
* @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.
* @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.
* @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.
* @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.
* @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.
*/
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).
* @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
* @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
* @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
* @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
return dev;
}
-void _ua_create_ua_ble_payload_s(ua_ble_payload_s **payload_handle)
-{
- FUNC_ENTRY;
- ua_ble_payload_s *payload = NULL;
-
- ret_if(NULL == payload_handle);
-
- payload = g_malloc0(sizeof(ua_ble_payload_s));
- if (!payload) {
- UA_ERR("g_malloc0 failed");
- *payload_handle = NULL;
- return;
- }
-
- payload->primary_key = 13;
- payload->device_icon = 1;
- payload->secondary_key = 1;
- payload->device_uid = NULL;
- payload->bt_mac = NULL;
-
- *payload_handle = payload;
- FUNC_EXIT;
-}
-
-void _ua_free_ua_ble_payload_s(gpointer data)
-{
- FUNC_ENTRY;
- ua_ble_payload_s *payload = data;
-
- ret_if(NULL == payload);
-
- g_free(payload->device_uid);
- g_free(payload->bt_mac);
-
- g_free(payload);
- FUNC_EXIT;
-}
-
-ua_ble_payload_s* _ua_get_payload_from_uam(uam_ble_payload_s *uam_payload)
-{
- FUNC_ENTRY;
- ua_ble_payload_s *payload = NULL;
-
- retv_if(NULL == uam_payload, NULL);
-
- payload = g_malloc0(sizeof(ua_ble_payload_s));
- if (!payload) {
- UA_ERR("g_malloc0 failed");
- return NULL;
- }
-
- payload->primary_key = uam_payload->primary_key;
- payload->device_icon = uam_payload->device_icon;
- payload->secondary_key = uam_payload->secondary_key;
-
- payload->device_uid = g_memdup(uam_payload->device_uid, UA_BLE_PAYLOAD_DEVICE_UID_LEN + 1);
- if (!payload->device_uid) {
- UA_ERR("g_malloc0 failed");
- _ua_free_ua_ble_payload_s(payload);
- return NULL;
- }
-
- payload->bt_mac = g_strdup(uam_payload->bt_mac);
- if (!payload->bt_mac) {
- UA_ERR("g_malloc0 failed");
- _ua_free_ua_ble_payload_s(payload);
- return NULL;
- }
-
- FUNC_EXIT;
- return payload;
-}
-
-void _ua_get_uam_payload_from_ua(uam_ble_payload_s *uam_payload,
- ua_ble_payload_s *payload)
-{
- FUNC_ENTRY;
- memset(uam_payload, 0, sizeof(uam_ble_payload_s));
-
- if (NULL == payload) {
- uam_payload->primary_key = 13;
- uam_payload->device_icon = 1;
- uam_payload->secondary_key = 1;
- UA_DBG("(NULL == payload) return");
- return;
- }
-
- uam_payload->primary_key = payload->primary_key;
- uam_payload->device_icon = payload->device_icon;
- uam_payload->secondary_key = payload->secondary_key;
-
- if (payload->device_uid)
- memcpy(uam_payload->device_uid, payload->device_uid, UA_BLE_PAYLOAD_DEVICE_UID_LEN + 1);
-
- if (payload->bt_mac)
- g_strlcpy(uam_payload->bt_mac, payload->bt_mac, UA_BT_MAC_MAX_LEN);
-
- FUNC_EXIT;
-}
-
-ua_ble_payload_s* _ua_payload_clone(ua_ble_payload_s *org_payload)
-{
- FUNC_ENTRY;
- ua_ble_payload_s *payload = NULL;
-
- retv_if(NULL == org_payload, NULL);
-
- payload = g_malloc0(sizeof(ua_ble_payload_s));
- if (!payload) {
- UA_ERR("g_malloc0 failed");
- return NULL;
- }
-
- payload->primary_key = org_payload->primary_key;
- payload->device_icon = org_payload->device_icon;
- payload->secondary_key = org_payload->secondary_key;
-
- payload->device_uid = g_memdup(org_payload->device_uid, UA_BLE_PAYLOAD_DEVICE_UID_LEN + 1);
- if (!payload->device_uid && org_payload->device_uid) {
- UA_ERR("g_malloc0 failed");
- _ua_free_ua_ble_payload_s(payload);
- return NULL;
- }
-
- payload->bt_mac = g_strdup(org_payload->bt_mac);
- if (!payload->bt_mac && org_payload->bt_mac) {
- UA_ERR("g_malloc0 failed");
- _ua_free_ua_ble_payload_s(payload);
- return NULL;
- }
-
- FUNC_EXIT;
- return payload;
-}
-
void _ua_free_ua_device_info_t(gpointer data)
{
FUNC_ENTRY;
g_free(device->ipv4);
g_free(device->ipv6); // LCOV_EXCL_LINE
g_free(device->device_id);
- _ua_free_ua_ble_payload_s(device->payload);
g_free(device);
FUNC_EXIT;
device->os = UA_OS_TYPE_NOT_DEFINE;
device->isadded = false;
device->discriminant = true;
- device->payload = NULL;
/* Add device to list of devices */
*device_handle = (ua_device_h)device;
return UA_ERROR_NONE;
}
-int ua_device_set_payload_primary_key(
- ua_device_h handle,
- const char primary_key)
-{
- FUNC_ENTRY;
- ua_dev_info_s *device = (ua_dev_info_s *)handle;
-
- UA_VALIDATE_INPUT_PARAMETER(handle);
- UA_PRINT_DEVICE_HANDLE(handle);
- retv_if(device->type != UA_MAC_TYPE_BLE, UA_ERROR_INVALID_PARAMETER);
-
- if (!device->payload) {
- _ua_create_ua_ble_payload_s(&device->payload);
- if (!device->payload) {
- UA_ERR("_ua_create_ua_ble_payload_s() failed");
- return UA_ERROR_OUT_OF_MEMORY;
- }
- }
-
- device->payload->primary_key = primary_key;
-
- FUNC_EXIT;
- return UA_ERROR_NONE;
-}
-
-int ua_device_set_payload_device_icon(
- ua_device_h handle,
- const char device_icon)
-{
- FUNC_ENTRY;
- ua_dev_info_s *device = (ua_dev_info_s *)handle;
-
- UA_VALIDATE_INPUT_PARAMETER(handle);
- UA_PRINT_DEVICE_HANDLE(handle);
- retv_if(device->type != UA_MAC_TYPE_BLE, UA_ERROR_INVALID_PARAMETER);
-
- if (!device->payload) {
- _ua_create_ua_ble_payload_s(&device->payload);
- if (!device->payload) {
- UA_ERR("_ua_create_ua_ble_payload_s() failed");
- return UA_ERROR_OUT_OF_MEMORY;
- }
- }
-
- device->payload->device_icon = device_icon;
-
- FUNC_EXIT;
- return UA_ERROR_NONE;
-}
-
-int ua_device_set_payload_secondary_key(
- ua_device_h handle,
- const char secondary_key)
-{
- FUNC_ENTRY;
- ua_dev_info_s *device = (ua_dev_info_s *)handle;
-
- UA_VALIDATE_INPUT_PARAMETER(handle);
- UA_PRINT_DEVICE_HANDLE(handle);
- retv_if(device->type != UA_MAC_TYPE_BLE, UA_ERROR_INVALID_PARAMETER);
-
- if (!device->payload) {
- _ua_create_ua_ble_payload_s(&device->payload);
- if (!device->payload) {
- UA_ERR("_ua_create_ua_ble_payload_s() failed");
- return UA_ERROR_OUT_OF_MEMORY;
- }
- }
-
- device->payload->secondary_key = secondary_key;
-
- FUNC_EXIT;
- return UA_ERROR_NONE;
-}
-
-int ua_device_set_payload_device_uid(
- ua_device_h handle,
- unsigned int device_uid_len,
- const char *device_uid)
-{
- FUNC_ENTRY;
- ua_dev_info_s *device = (ua_dev_info_s *)handle;
-
- UA_VALIDATE_INPUT_PARAMETER(handle);
- UA_VALIDATE_INPUT_PARAMETER(device_uid);
- UA_PRINT_DEVICE_HANDLE(handle);
- retv_if(device->type != UA_MAC_TYPE_BLE, UA_ERROR_INVALID_PARAMETER);
- retv_if(device_uid_len != UA_BLE_PAYLOAD_DEVICE_UID_LEN, UA_ERROR_INVALID_PARAMETER);
-
- if (!device->payload) {
- _ua_create_ua_ble_payload_s(&device->payload);
- if (!device->payload) {
- UA_ERR("_ua_create_ua_ble_payload_s() failed");
- return UA_ERROR_OUT_OF_MEMORY;
- }
- }
-
- g_free(device->payload->device_uid);
- device->payload->device_uid = NULL;
-
- device->payload->device_uid = g_malloc0(UA_BLE_PAYLOAD_DEVICE_UID_LEN + 1);
- if (device->payload->device_uid == NULL) {
- UA_ERR("g_malloc0 failed");
- _ua_free_ua_ble_payload_s((gpointer)device->payload);
- return UA_ERROR_OUT_OF_MEMORY;
- }
-
- memcpy(device->payload->device_uid, device_uid, UA_BLE_PAYLOAD_DEVICE_UID_LEN);
-
- FUNC_EXIT;
- return UA_ERROR_NONE;
-}
-
int ua_device_get_mac_address(
ua_device_h device_handle,
char **mac_address)
return UA_ERROR_NONE;
}
-int ua_device_get_payload_primary_key(
- ua_device_h handle,
- char *primary_key)
-{
- FUNC_ENTRY;
- ua_dev_info_s *device = (ua_dev_info_s *)handle;
-
- UA_VALIDATE_INPUT_PARAMETER(handle);
- UA_VALIDATE_INPUT_PARAMETER(primary_key);
- UA_PRINT_DEVICE_HANDLE(handle);
- retv_if(device->type != UA_MAC_TYPE_BLE, UA_ERROR_INVALID_PARAMETER);
-
- if (!device->payload) {
- *primary_key = 0x00;
- UA_DBG("payload(primary_key) is not found");
- goto done;
- }
-
- *primary_key = device->payload->primary_key;
-
-done:
- FUNC_EXIT;
- return UA_ERROR_NONE;
-}
-
-int ua_device_get_payload_device_icon(
- ua_device_h handle,
- char *device_icon)
-{
- FUNC_ENTRY;
- ua_dev_info_s *device = (ua_dev_info_s *)handle;
-
- UA_VALIDATE_INPUT_PARAMETER(handle);
- UA_VALIDATE_INPUT_PARAMETER(device_icon);
- UA_PRINT_DEVICE_HANDLE(handle);
- retv_if(device->type != UA_MAC_TYPE_BLE, UA_ERROR_INVALID_PARAMETER);
-
- if (!device->payload) {
- *device_icon = 0x00;
- UA_DBG("payload(device_icon) is not found");
- goto done;
- }
-
- *device_icon = device->payload->device_icon;
-
-done:
- FUNC_EXIT;
- return UA_ERROR_NONE;
-}
-int ua_device_get_payload_secondary_key(
- ua_device_h handle,
- char *secondary_key)
-{
- FUNC_ENTRY;
- ua_dev_info_s *device = (ua_dev_info_s *)handle;
-
- UA_VALIDATE_INPUT_PARAMETER(handle);
- UA_VALIDATE_INPUT_PARAMETER(secondary_key);
- UA_PRINT_DEVICE_HANDLE(handle);
- retv_if(device->type != UA_MAC_TYPE_BLE, UA_ERROR_INVALID_PARAMETER);
-
- if (!device->payload) {
- *secondary_key = 0x00;
- UA_DBG("payload(secondary_key) is not found");
- goto done;
- }
-
- *secondary_key = device->payload->secondary_key;
-
-done:
- FUNC_EXIT;
- return UA_ERROR_NONE;
-}
-
-int ua_device_get_payload_device_uid(
- ua_device_h handle,
- char **device_uid)
-{
- FUNC_ENTRY;
- ua_dev_info_s *device = (ua_dev_info_s *)handle;
-
- UA_VALIDATE_INPUT_PARAMETER(handle);
- UA_VALIDATE_INPUT_PARAMETER(device_uid);
- UA_PRINT_DEVICE_HANDLE(handle);
- retv_if(device->type != UA_MAC_TYPE_BLE, UA_ERROR_INVALID_PARAMETER);
-
- if (!device->payload || !device->payload->device_uid) {
- *device_uid = NULL;
- UA_DBG("payload(device_uid) is not found");
- goto done;
- }
-
- *device_uid = g_memdup(device->payload->device_uid, UA_BLE_PAYLOAD_DEVICE_UID_LEN);
- if (*device_uid == NULL) {
- /* LCOV_EXCL_START */
- UA_ERR("g_memdup failed");
- return UA_ERROR_OUT_OF_MEMORY;
- /* LCOV_EXCL_STOP */
- }
-
-done:
- FUNC_EXIT;
- return UA_ERROR_NONE;
-}
-
int ua_device_get_by_mac_address(
const char *mac,
ua_device_h *device_handle)
return UA_ERROR_OUT_OF_MEMORY;
}
- dev->payload = _ua_get_payload_from_uam(&uam_dev.payload);
- if (dev->payload == NULL) {
- UA_ERR("_ua_get_payload_from_uam() failed");
- *device_handle = NULL;
- _ua_free_ua_device_info_t((gpointer)dev);
- return UA_ERROR_OUT_OF_MEMORY;
- }
-
dev->type = _to_ua_mac_type(uam_dev.type);
dev->pairing_required = FALSE;
dev->discriminant= uam_dev.discriminant;
return UA_ERROR_OUT_OF_MEMORY;
}
- dev->payload = _ua_get_payload_from_uam(&uam_dev.payload);
- if (dev->payload == NULL) {
- UA_ERR("_ua_get_payload_from_uam() failed");
- *device_handle = NULL;
- _ua_free_ua_device_info_t((gpointer)dev);
- return UA_ERROR_OUT_OF_MEMORY;
- }
-
dev->type = _to_ua_mac_type(uam_dev.type);
dev->pairing_required = FALSE;
dev->os = uam_dev.operating_system;
if (device->ipv4)
g_strlcpy(uam_device.ipv4_addr, device->ipv4, UA_IPV4_ADDRESS_STRING_LEN);
- _ua_get_uam_payload_from_ua(&uam_device.payload, device->payload);
-
ret = _ua_get_error_code(_uam_is_device_registered(&uam_device, &is_registered));
if (UA_ERROR_NONE != ret) {
/* LCOV_EXCL_START */
return UA_ERROR_OUT_OF_MEMORY;
}
- device->payload = _ua_payload_clone(org_device->payload);
- if (device->payload == NULL && org_device->payload) {
- UA_ERR("g_malloc0 failed");
- _ua_free_ua_device_info_t((gpointer)device);
- return UA_ERROR_OUT_OF_MEMORY;
- }
-
device->isadded = org_device->isadded;
device->type = org_device->type;
device->os = org_device->os;
goto done;
}
- device_info->payload = _ua_get_payload_from_uam(&ptr->payload);
- if (device_info->payload == NULL) {
- UA_ERR("_ua_get_payload_from_uam() failed");
- ret = UA_ERROR_OUT_OF_MEMORY;
- _ua_free_ua_device_info_t((gpointer)device_info);
- goto done;
- }
-
device_info->isadded = true;
device_info->handle = (ua_device_h)device_info;
device_info->type = _to_ua_mac_type(ptr->type);
goto done;
}
- device_info->payload = _ua_get_payload_from_uam(&ptr->payload);
- if (device_info->payload == NULL) {
- UA_ERR("_ua_get_payload_from_uam() failed");
- ret = UA_ERROR_OUT_OF_MEMORY;
- _ua_free_ua_device_info_t((gpointer)device_info);
- goto done;
- }
-
device_info->isadded = true;
device_info->handle = (ua_device_h)device_info;
device_info->type = _to_ua_mac_type(ptr->type);
--- /dev/null
+/*
+ * Copyright (c) 2018 Samsung Electronics Co., Ltd. All rights reserved.
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License")
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ *
+ */
+
+#include <glib.h>
+#include <ua-api.h>
+
+#include <user-awareness.h>
+#include <user-awareness-log.h>
+#include <user-awareness-private.h>
+#include <user-awareness-util.h>
+
+GSList *ua_payload_list;
+
+int ua_payload_create(ua_payload_h *payload_handle)
+{
+ FUNC_ENTRY;
+ ua_payload_info_s *payload = NULL;
+
+ UA_VALIDATE_INPUT_PARAMETER(payload_handle);
+
+ payload = g_malloc0(sizeof(ua_payload_info_s));
+ if (!payload) {
+ /* LCOV_EXCL_START */
+ UA_ERR("g_malloc0 failed");
+ return UA_ERROR_OUT_OF_MEMORY;
+ /* LCOV_EXCL_STOP */
+ }
+
+ payload->primary_key = 13;
+ payload->device_icon = 1;
+ payload->secondary_key = 1;
+ payload->device_uid = NULL;
+ payload->bt_mac = NULL;
+ payload->isadded = false;
+
+ /* Add payload to list of payloads*/
+ *payload_handle = (ua_payload_h)payload;
+ payload->handle = *payload_handle;
+
+ ua_payload_list = g_slist_append(ua_payload_list, payload);
+
+ FUNC_EXIT;
+ return UA_ERROR_NONE;
+}
+
+void _ua_free_ua_payload_info_s(gpointer data)
+{
+ FUNC_ENTRY;
+ ua_payload_info_s *payload = data;
+
+ ret_if(NULL == payload);
+
+ g_free(payload->device_uid);
+ g_free(payload->bt_mac);
+
+ g_free(payload);
+ FUNC_EXIT;
+}
+
+int ua_payload_destroy(ua_payload_h handle)
+{
+ FUNC_ENTRY;
+ ua_payload_info_s *payload = (ua_payload_info_s *)handle;
+
+ UA_VALIDATE_INPUT_PARAMETER(handle);
+ UA_VALIDATE_HANDLE(handle, ua_payload_list);
+
+ /* Do not remove from list if payload is added to database */
+ if (payload->isadded) {
+ /* LCOV_EXCL_START */
+ return UA_ERROR_NONE;
+ /* LCOV_EXCL_STOP */
+ }
+
+ ua_payload_list = g_slist_remove(ua_payload_list, payload);
+ _ua_free_ua_payload_info_s(payload);
+
+ FUNC_EXIT;
+ return UA_ERROR_NONE;
+}
+
+int ua_payload_set_primary_key(
+ ua_payload_h handle,
+ const char primary_key)
+{
+ FUNC_ENTRY;
+ ua_payload_info_s *payload = (ua_payload_info_s *)handle;
+
+ UA_VALIDATE_INPUT_PARAMETER(handle);
+ UA_PRINT_PAYLOAD_HANDLE(handle);
+
+ payload->primary_key = primary_key;
+
+ FUNC_EXIT;
+ return UA_ERROR_NONE;
+}
+
+int ua_payload_set_device_icon(
+ ua_device_h handle,
+ const char device_icon)
+{
+ FUNC_ENTRY;
+ ua_payload_info_s *payload = (ua_payload_info_s *)handle;
+
+ UA_VALIDATE_INPUT_PARAMETER(handle);
+ UA_PRINT_PAYLOAD_HANDLE(handle);
+
+ payload->device_icon = device_icon;
+
+ FUNC_EXIT;
+ return UA_ERROR_NONE;
+}
+
+int ua_payload_set_secondary_key(
+ ua_device_h handle,
+ const char secondary_key)
+{
+ FUNC_ENTRY;
+ ua_payload_info_s *payload = (ua_payload_info_s *)handle;
+
+ UA_VALIDATE_INPUT_PARAMETER(handle);
+ UA_PRINT_PAYLOAD_HANDLE(handle);
+
+ payload->secondary_key = secondary_key;
+
+ FUNC_EXIT;
+ return UA_ERROR_NONE;
+}
+
+int ua_payload_set_device_uid(
+ ua_device_h handle,
+ unsigned int device_uid_len,
+ const char *device_uid)
+{
+ FUNC_ENTRY;
+ ua_payload_info_s *payload = (ua_payload_info_s *)handle;
+
+ UA_VALIDATE_INPUT_PARAMETER(handle);
+ UA_VALIDATE_INPUT_PARAMETER(device_uid);
+ UA_PRINT_PAYLOAD_HANDLE(handle);
+
+ retv_if(device_uid_len != UA_BLE_PAYLOAD_DEVICE_UID_LEN, UA_ERROR_INVALID_PARAMETER);
+
+ g_free(payload->device_uid);
+ payload->device_uid = NULL;
+
+ payload->device_uid = g_malloc0(UA_BLE_PAYLOAD_DEVICE_UID_LEN + 1);
+ if (payload->device_uid == NULL) {
+ UA_ERR("g_malloc0 failed");
+ _ua_free_ua_payload_info_s((gpointer)payload);
+ return UA_ERROR_OUT_OF_MEMORY;
+ }
+
+ memcpy(payload->device_uid, device_uid, UA_BLE_PAYLOAD_DEVICE_UID_LEN);
+
+ FUNC_EXIT;
+ return UA_ERROR_NONE;
+}
+
+void _ua_get_uam_payload_from_ua(uam_ble_payload_s *uam_payload,
+ ua_payload_info_s *payload)
+{
+ FUNC_ENTRY;
+ memset(uam_payload, 0, sizeof(uam_ble_payload_s));
+
+ if (NULL == payload) {
+ uam_payload->primary_key = 13;
+ uam_payload->device_icon = 1;
+ uam_payload->secondary_key = 1;
+ UA_DBG("(NULL == payload) return");
+ return;
+ }
+
+ uam_payload->primary_key = payload->primary_key;
+ uam_payload->device_icon = payload->device_icon;
+ uam_payload->secondary_key = payload->secondary_key;
+
+ if (payload->device_uid)
+ memcpy(uam_payload->device_uid, payload->device_uid, UA_BLE_PAYLOAD_DEVICE_UID_LEN + 1);
+
+ if (payload->bt_mac)
+ g_strlcpy(uam_payload->bt_mac, payload->bt_mac, UA_BT_MAC_MAX_LEN);
+
+ FUNC_EXIT;
+}
+
+int ua_payload_add(ua_payload_h payload_handle, ua_device_h device_handle)
+{
+ FUNC_ENTRY;
+ int ret;
+ uam_ble_payload_s uam_payload;
+
+ ua_payload_info_s* payload_info = (ua_payload_info_s*)payload_handle;
+ ua_dev_info_s* dev_info = (ua_dev_info_s*)device_handle;
+
+ UA_VALIDATE_INPUT_PARAMETER(payload_handle);
+ UA_VALIDATE_INPUT_PARAMETER(device_handle);
+
+ UA_DBG("device_info->device_id [%s], device_info->mac [%s], device_info->type [%d]",
+ dev_info->device_id, dev_info->mac, dev_info->type);
+
+ UA_IS_EXIST(_ua_get_device_from_list(dev_info->device_id, dev_info->mac, dev_info->type));
+ retv_if(dev_info->isadded == FALSE, UA_ERROR_NOT_REGISTERED);
+ retv_if(payload_info->device_uid == NULL, UA_ERROR_INVALID_PARAMETER);
+
+ _ua_get_uam_payload_from_ua(&uam_payload, payload_info);
+
+ ret = _ua_get_error_code(_uam_request_add_payload(&uam_payload, dev_info->device_id,
+ _ua_to_uam_tech_type(dev_info->type)));
+ if (UA_ERROR_NONE != ret) {
+ UA_ERR("_uam_payload_add returned %s",
+ _ua_get_error_string(ret));
+ return ret;
+ }
+
+ FUNC_EXIT;
+ return UA_ERROR_NONE;
+}
+
+/*
+ua_payload_info_s* _ua_get_payload_from_uam(uam_ble_payload_s *uam_payload)
+{
+ FUNC_ENTRY;
+ ua_payload_info_s *payload = NULL;
+
+ retv_if(NULL == uam_payload, NULL);
+
+ payload = g_malloc0(sizeof(ua_payload_info_s));
+ if (!payload) {
+ UA_ERR("g_malloc0 failed");
+ return NULL;
+ }
+
+ payload->primary_key = uam_payload->primary_key;
+ payload->device_icon = uam_payload->device_icon;
+ payload->secondary_key = uam_payload->secondary_key;
+
+ payload->device_uid = g_memdup(uam_payload->device_uid, UA_BLE_PAYLOAD_DEVICE_UID_LEN + 1);
+ if (!payload->device_uid) {
+ UA_ERR("g_malloc0 failed");
+ _ua_free_ua_payload_info_s(payload);
+ return NULL;
+ }
+
+ payload->bt_mac = g_strdup(uam_payload->bt_mac);
+ if (!payload->bt_mac) {
+ UA_ERR("g_malloc0 failed");
+ _ua_free_ua_payload_info_s(payload);
+ return NULL;
+ }
+
+ FUNC_EXIT;
+ return payload;
+}
+
+ua_payload_info_s* _ua_payload_clone(ua_payload_info_s *org_payload)
+{
+ FUNC_ENTRY;
+ ua_payload_info_s *payload = NULL;
+
+ retv_if(NULL == org_payload, NULL);
+
+ payload = g_malloc0(sizeof(ua_payload_info_s));
+ if (!payload) {
+ UA_ERR("g_malloc0 failed");
+ return NULL;
+ }
+
+ payload->primary_key = org_payload->primary_key;
+ payload->device_icon = org_payload->device_icon;
+ payload->secondary_key = org_payload->secondary_key;
+
+ payload->device_uid = g_memdup(org_payload->device_uid, UA_BLE_PAYLOAD_DEVICE_UID_LEN + 1);
+ if (!payload->device_uid && org_payload->device_uid) {
+ UA_ERR("g_malloc0 failed");
+ _ua_free_ua_payload_info_s(payload);
+ return NULL;
+ }
+
+ payload->bt_mac = g_strdup(org_payload->bt_mac);
+ if (!payload->bt_mac && org_payload->bt_mac) {
+ UA_ERR("g_malloc0 failed");
+ _ua_free_ua_payload_info_s(payload);
+ return NULL;
+ }
+
+ FUNC_EXIT;
+ return payload;
+}
+*/
+/*
+int ua_payload_get_primary_key(
+ ua_device_h handle,
+ char *primary_key)
+{
+ FUNC_ENTRY;
+ ua_dev_info_s *device = (ua_dev_info_s *)handle;
+
+ UA_VALIDATE_INPUT_PARAMETER(handle);
+ UA_VALIDATE_INPUT_PARAMETER(primary_key);
+ UA_PRINT_DEVICE_HANDLE(handle);
+ retv_if(device->type != UA_MAC_TYPE_BLE, UA_ERROR_INVALID_PARAMETER);
+
+ if (!device->payload) {
+ *primary_key = 0x00;
+ UA_DBG("payload(primary_key) is not found");
+ goto done;
+ }
+
+ *primary_key = device->payload->primary_key;
+
+done:
+ FUNC_EXIT;
+ return UA_ERROR_NONE;
+}
+
+int ua_payload_get_device_icon(
+ ua_device_h handle,
+ char *device_icon)
+{
+ FUNC_ENTRY;
+ ua_dev_info_s *device = (ua_dev_info_s *)handle;
+
+ UA_VALIDATE_INPUT_PARAMETER(handle);
+ UA_VALIDATE_INPUT_PARAMETER(device_icon);
+ UA_PRINT_DEVICE_HANDLE(handle);
+ retv_if(device->type != UA_MAC_TYPE_BLE, UA_ERROR_INVALID_PARAMETER);
+
+ if (!device->payload) {
+ *device_icon = 0x00;
+ UA_DBG("payload(device_icon) is not found");
+ goto done;
+ }
+
+ *device_icon = device->payload->device_icon;
+
+done:
+ FUNC_EXIT;
+ return UA_ERROR_NONE;
+}
+int ua_payload_get_secondary_key(
+ ua_device_h handle,
+ char *secondary_key)
+{
+ FUNC_ENTRY;
+ ua_dev_info_s *device = (ua_dev_info_s *)handle;
+
+ UA_VALIDATE_INPUT_PARAMETER(handle);
+ UA_VALIDATE_INPUT_PARAMETER(secondary_key);
+ UA_PRINT_DEVICE_HANDLE(handle);
+ retv_if(device->type != UA_MAC_TYPE_BLE, UA_ERROR_INVALID_PARAMETER);
+
+ if (!device->payload) {
+ *secondary_key = 0x00;
+ UA_DBG("payload(secondary_key) is not found");
+ goto done;
+ }
+
+ *secondary_key = device->payload->secondary_key;
+
+done:
+ FUNC_EXIT;
+ return UA_ERROR_NONE;
+}
+
+int ua_payload_get_device_uid(
+ ua_device_h handle,
+ char **device_uid)
+{
+ FUNC_ENTRY;
+ ua_dev_info_s *device = (ua_dev_info_s *)handle;
+
+ UA_VALIDATE_INPUT_PARAMETER(handle);
+ UA_VALIDATE_INPUT_PARAMETER(device_uid);
+ UA_PRINT_DEVICE_HANDLE(handle);
+ retv_if(device->type != UA_MAC_TYPE_BLE, UA_ERROR_INVALID_PARAMETER);
+
+ if (!device->payload || !device->payload->device_uid) {
+ *device_uid = NULL;
+ UA_DBG("payload(device_uid) is not found");
+ goto done;
+ }
+
+ *device_uid = g_memdup(device->payload->device_uid, UA_BLE_PAYLOAD_DEVICE_UID_LEN);
+ if (*device_uid == NULL) {
+ // LCOV_EXCL_START
+ UA_ERR("g_memdup failed");
+ return UA_ERROR_OUT_OF_MEMORY;
+ // LCOV_EXCL_START
+ }
+
+done:
+ FUNC_EXIT;
+ return UA_ERROR_NONE;
+}
+*/
goto done;
}
- device_info->payload = _ua_get_payload_from_uam(&ptr->payload);
- if (device_info->payload == NULL) {
- UA_ERR("_ua_get_payload_from_uam() failed");
- ret = UA_ERROR_OUT_OF_MEMORY;
- _ua_free_ua_device_info_t((gpointer)device_info);
- goto done;
- }
-
device_info->isadded = true;
device_info->handle = (ua_device_h)device_info;
device_info->type = _to_ua_mac_type(ptr->type);
if (device->ipv4)
g_strlcpy(uam_device.ipv4_addr, device->ipv4, UA_IPV4_ADDRESS_STRING_LEN);
- _ua_get_uam_payload_from_ua(&uam_device.payload, device->payload);
-
ret = _ua_get_error_code(_uam_request_add_device(user->account, &uam_device));
if (UA_ERROR_NONE != ret) {
/* LCOV_EXCL_START */
if (device->ipv4)
g_strlcpy(uam_device.ipv4_addr, device->ipv4, UA_IPV4_ADDRESS_STRING_LEN);
-//TODO lk, do we need this info to be filled
- _ua_get_uam_payload_from_ua(&uam_device.payload, device->payload);
-
ret = _ua_get_error_code(_uam_request_remove_device(user->account, &uam_device));
if (UA_ERROR_NONE != ret) {
goto done;
}
- device_info->payload = _ua_get_payload_from_uam(&ptr->payload);
- if (device_info->payload == NULL) {
- UA_ERR("_ua_get_payload_from_uam() failed");
- ret = UA_ERROR_OUT_OF_MEMORY;
- _ua_free_ua_device_info_t((gpointer)device_info);
- goto done;
- }
-
device_info->isadded = true;
device_info->handle = (ua_device_h)device_info;
device_info->type = _to_ua_mac_type(ptr->type);
uat-sensors.c
uat-service.c
uat-detections.c
+ uat-payload.c
)
SET(CMAKE_EXE_LINKER_FLAGS "-Wl,--as-needed -pie")
static char g_discriminant[MENU_DATA_SIZE + 1] = {"1",}; /**< Discrimniant for a device */
static char g_ipv4_address_str[MENU_DATA_SIZE + 1] = {0,}; /**< IPv4 of the selected device */
static char g_is_paring_required_str[MENU_DATA_SIZE + 1] = {0,}; /**< Is paring required for the selected device */
-static char g_payload_primary_key[MENU_DATA_SIZE + 1] = {0,}; /**< payload primary_key for the selected device */
-static char g_payload_device_icon[MENU_DATA_SIZE + 1] = {0,}; /**< payload device_icon for the selected device */
-static char g_payload_secondary_key[MENU_DATA_SIZE + 1] = {0,}; /**< payload secondary_key for the selected device */
-static char g_payload_device_uid_str[MENU_DATA_SIZE + 1] = {0,}; /**< payload device_uid for the selected device */
char g_selected_device_idx[MENU_DATA_SIZE + 1] = {0,}; /**< Selected device id */
extern char g_service_str[MENU_DATA_SIZE + 1]; /**< Service name string */
bool required = false;
unsigned long long last_seen = 0;
bool discriminant = false;
- char primary_key = 0;
- char device_icon = 0;
- char secondary_key = 0;
- char *device_uid = NULL;
if (!device_handle) {
msgr("device_handle is NULL");
if (UA_ERROR_NONE == ret_temp)
msgb("Last present at : %llu", last_seen);
- ret_temp = ua_device_get_payload_primary_key(handle, &primary_key);
- if (UA_ERROR_NONE == ret_temp)
- msgb("payload primary_key : %d[hex: 0x%X]", primary_key, primary_key);
-
- ret_temp = ua_device_get_payload_device_icon(handle, &device_icon);
- if (UA_ERROR_NONE == ret_temp)
- msgb("payload device_icon : %d[hex: 0x%X]", device_icon, device_icon);
-
- ret_temp = ua_device_get_payload_secondary_key(handle, &secondary_key);
- if (UA_ERROR_NONE == ret_temp)
- msgb("payload secondary_key : %d[hex: 0x%X]", secondary_key, secondary_key);
-
- ret_temp = ua_device_get_payload_device_uid(handle, &device_uid);
- if (UA_ERROR_NONE == ret_temp) {
- uat_print_device_uid(device_uid);
- g_free(device_uid);
- }
-
g_device_list = g_slist_append(g_device_list, handle);
return true;
char *ipv4 = NULL;
bool required = false;
bool discriminant = false;
- char primary_key = 0;
- char device_icon = 0;
- char secondary_key = 0;
- char *device_uid = NULL;
check_if(NULL == g_device_h);
required ? "YES" : "NO ", sizeof("YES"));
}
- ret = ua_device_get_payload_primary_key(g_device_h, &primary_key);
- if (UA_ERROR_NONE == ret)
- snprintf(g_payload_primary_key, MENU_DATA_SIZE + 1, "%u",
- (unsigned int)primary_key);
-
- ret = ua_device_get_payload_device_icon(g_device_h, &device_icon);
- if (UA_ERROR_NONE == ret)
- snprintf(g_payload_device_icon, MENU_DATA_SIZE + 1, "%u",
- (unsigned int)device_icon);
-
- ret = ua_device_get_payload_secondary_key(g_device_h, &secondary_key);
- if (UA_ERROR_NONE == ret)
- snprintf(g_payload_secondary_key, MENU_DATA_SIZE + 1, "%u",
- (unsigned int)secondary_key);
-
- ret = ua_device_get_payload_device_uid(g_device_h, &device_uid);
- memset(g_payload_device_uid_str, 0, MENU_DATA_SIZE + 1);
- if (UA_ERROR_NONE == ret && device_uid) {
- memcpy(g_payload_device_uid_str, device_uid, UA_BLE_PAYLOAD_DEVICE_UID_LEN);
- g_free(device_uid);
- }
}
-
-#ifndef SUPPORT_STRING_DEVICE_UID
-static int _scan_payload_device_uid_str(
- MManager *mm, struct menu_data *menu)
-{
- int ret = UA_ERROR_NONE;
- int temp = 0;
-
- msg("Input 17 bytes device_uid, each byte is 0 to 255 value");
- memset(g_payload_device_uid_str, 0, MENU_DATA_SIZE + 1);
-
- for (int i = 0; i < UA_BLE_PAYLOAD_DEVICE_UID_LEN; i++) {
- ret = fscanf(stdin, "%d", &temp);
- if(!ret)
- msg(" - fscanf ret: %d", ret);
-
- g_payload_device_uid_str[i] = (unsigned char)temp;
- }
-
- return RET_SUCCESS;
-}
-#endif /* SUPPORT_STRING_DEVICE_UID */
-
static int run_ua_device_create(
MManager *mm, struct menu_data *menu)
{
return RET_SUCCESS;
}
-static int run_ua_device_set_payload_primary_key(
- MManager *mm, struct menu_data *menu)
-{
- int ret = UA_ERROR_NONE;
- char primary_key = 0;
-
- msg("ua_device_set_payload_primary_key");
-
- if (strlen(g_payload_primary_key))
- primary_key = (unsigned char)strtol(g_payload_primary_key, NULL, 10);
-
- ret = ua_device_set_payload_primary_key(g_device_h, primary_key);
-
- msg(" - ua_device_set_payload_primary_key() ret: [0x%X] [%s]",
- ret, uat_get_error_str(ret));
-
- return RET_SUCCESS;
-}
-
-static int run_ua_device_set_payload_device_icon(
- MManager *mm, struct menu_data *menu)
-{
- int ret = UA_ERROR_NONE;
- char device_icon = 0;
-
- msg("ua_device_set_payload_device_icon");
-
- if (strlen(g_payload_device_icon))
- device_icon = (unsigned char)strtol(g_payload_device_icon, NULL, 10);
-
- ret = ua_device_set_payload_device_icon(g_device_h, device_icon);
-
- msg(" - ua_device_set_payload_device_icon() ret: [0x%X] [%s]",
- ret, uat_get_error_str(ret));
-
- return RET_SUCCESS;
-}
-
-static int run_ua_device_set_payload_secondary_key(
- MManager *mm, struct menu_data *menu)
-{
- int ret = UA_ERROR_NONE;
- char secondary_key = 0;
-
- msg("ua_device_set_payload_secondary_key");
-
- if (strlen(g_payload_secondary_key))
- secondary_key = (unsigned char)strtol(g_payload_secondary_key, NULL, 10);
-
- ret = ua_device_set_payload_secondary_key(g_device_h, secondary_key);
-
- msg(" - ua_device_set_payload_secondary_key() ret: [0x%X] [%s]",
- ret, uat_get_error_str(ret));
-
- return RET_SUCCESS;
-}
-
-static int run_ua_device_set_payload_device_uid(
- MManager *mm, struct menu_data *menu)
-{
- int ret = UA_ERROR_NONE;
-
- msg("ua_device_set_payload_device_uid");
-
- ret = ua_device_set_payload_device_uid(g_device_h, UA_BLE_PAYLOAD_DEVICE_UID_LEN, g_payload_device_uid_str);
-
- msg(" - ua_device_set_payload_device_uid() ret: [0x%X] [%s]",
- ret, uat_get_error_str(ret));
-
- return RET_SUCCESS;
-}
-
static int run_ua_device_get_by_mac_address(
MManager *mm, struct menu_data *menu)
{
{ NULL, NULL, },
};
-static struct menu_data menu_ua_device_set_payload_primary_key[] = {
- { "1", "Service_ID (0 to 255)",
- NULL, NULL, g_payload_primary_key },
- { "2", "run", NULL,
- run_ua_device_set_payload_primary_key, NULL },
- { NULL, NULL, },
-};
-
-static struct menu_data menu_ua_device_set_payload_device_icon[] = {
- { "1", "device_icon (0 to 255)",
- NULL, NULL, g_payload_device_icon },
- { "2", "run", NULL,
- run_ua_device_set_payload_device_icon, NULL },
- { NULL, NULL, },
-};
-
-static struct menu_data menu_ua_device_set_payload_secondary_key[] = {
- { "1", "Purpose (0 to 255)",
- NULL, NULL, g_payload_secondary_key },
- { "2", "run", NULL,
- run_ua_device_set_payload_secondary_key, NULL },
- { NULL, NULL, },
-};
-
-static struct menu_data menu_ua_device_set_payload_device_uid[] = {
- { "1", "DEVICE_UID (Max. 17 bytes)",
-#ifdef SUPPORT_STRING_DEVICE_UID
- NULL, NULL, g_payload_device_uid_str },
-#else
- NULL, _scan_payload_device_uid_str, NULL },
-#endif
- { "2", "run", NULL,
- run_ua_device_set_payload_device_uid, NULL },
- { NULL, NULL, },
-};
-
static struct menu_data menu_ua_devlist_by_mac[] = {
{ "1", "MAC",
NULL, NULL, g_mac_addr_str },
menu_ua_discrminiant, NULL, g_discriminant},
{ "8", "ua_device_set_wifi_ipv4_address",
menu_ua_ipv4_address, NULL, g_ipv4_address_str },
- { "9", "ua_device_set_payload_primary_key",
- menu_ua_device_set_payload_primary_key, NULL, g_payload_primary_key },
- { "10", "ua_device_set_payload_device_icon",
- menu_ua_device_set_payload_device_icon, NULL, g_payload_device_icon },
- { "11", "ua_device_set_payload_secondary_key",
- menu_ua_device_set_payload_secondary_key, NULL, g_payload_secondary_key },
- { "12", "ua_device_set_payload_device_uid",
- menu_ua_device_set_payload_device_uid, NULL, g_payload_device_uid_str },
{ "13", "ua_device_get_wifi_bssid",
NULL, run_ua_device_get_wifi_bssid, NULL },
{ "14", "ua_device_get_by_mac_address",
extern struct menu_data menu_ua_devices[];
extern struct menu_data menu_ua_users[];
extern struct menu_data menu_ua_services[];
+extern struct menu_data menu_ua_payloads[];
extern struct menu_data menu_ua_sensors[];
extern struct menu_data menu_ua_detections[];
{ "4", "Services", menu_ua_services, NULL, NULL },
{ "5", "Sensors", menu_ua_sensors, NULL, NULL },
{ "6", "Detection", menu_ua_detections, NULL, NULL },
+ { "7", "Payload", menu_ua_payloads, NULL, NULL },
{ NULL, NULL, },
};
--- /dev/null
+/*
+ * Copyright (c) 2018 Samsung Electronics Co., Ltd. All rights reserved.
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ *
+ */
+#include <stdio.h>
+#include <stdlib.h>
+#include <string.h>
+
+#include <glib.h>
+#include <gio/gio.h>
+
+#include "uat-common.h"
+
+extern ua_device_h g_device_h; /**< Device handle */
+ua_payload_h g_payload_h = NULL; /**< Payload handle */
+
+static char g_payload_primary_key[MENU_DATA_SIZE + 1] = {0,}; /**< payload primary_key for the selected device */
+static char g_payload_device_icon[MENU_DATA_SIZE + 1] = {0,}; /**< payload device_icon for the selected device */
+static char g_payload_secondary_key[MENU_DATA_SIZE + 1] = {0,}; /**< payload secondary_key for the selected device */
+static char g_payload_device_uid_str[MENU_DATA_SIZE + 1] = {0,}; /**< payload device_uid for the selected device */
+
+static int run_ua_payload_create(
+ MManager *mm, struct menu_data *menu)
+{
+ int ret = UA_ERROR_NONE;
+
+ msg("ua_payload_create");
+
+ if (g_payload_h) {
+ ua_payload_destroy(g_payload_h);
+ g_payload_h = NULL;
+ }
+
+ ret = ua_payload_create(&g_payload_h);
+
+ msg(" - ua_payload_create() ret: [0x%X] [%s]",
+ ret, uat_get_error_str(ret));
+
+ return RET_SUCCESS;
+}
+
+static int run_ua_payload_destroy(MManager *mm, struct menu_data *menu)
+{
+ int ret = UA_ERROR_NONE;
+
+ msg("ua_payload_destroy");
+
+ ret = ua_payload_destroy(g_payload_h);
+ g_payload_h = NULL;
+
+ msg(" - ua_payload_destroy() ret: [0x%X] [%s]",
+ ret, uat_get_error_str(ret));
+
+ return RET_SUCCESS;
+}
+
+#ifndef SUPPORT_STRING_DEVICE_UID
+static int _scan_payload_device_uid_str(
+ MManager *mm, struct menu_data *menu)
+{
+ int ret = UA_ERROR_NONE;
+ int temp = 0;
+
+ msg("Input 17 bytes device_uid, each byte is 0 to 255 value");
+ memset(g_payload_device_uid_str, 0, MENU_DATA_SIZE + 1);
+
+ for (int i = 0; i < UA_BLE_PAYLOAD_DEVICE_UID_LEN; i++) {
+ ret = fscanf(stdin, "%d", &temp);
+ if(!ret)
+ msg(" - fscanf ret: %d", ret);
+
+ g_payload_device_uid_str[i] = (unsigned char)temp;
+ }
+
+ return RET_SUCCESS;
+}
+#endif /* SUPPORT_STRING_DEVICE_UID */
+
+static int run_ua_payload_set_primary_key(
+ MManager *mm, struct menu_data *menu)
+{
+ int ret = UA_ERROR_NONE;
+ char primary_key = 0;
+
+ msg("ua_payload_set_primary_key");
+
+ if (strlen(g_payload_primary_key))
+ primary_key = (unsigned char)strtol(g_payload_primary_key, NULL, 10);
+
+ ret = ua_payload_set_primary_key(g_payload_h, primary_key);
+
+ msg(" - ua_payload_set_primary_key() ret: [0x%X] [%s]",
+ ret, uat_get_error_str(ret));
+
+ return RET_SUCCESS;
+}
+
+static int run_ua_payload_set_device_icon(
+ MManager *mm, struct menu_data *menu)
+{
+ int ret = UA_ERROR_NONE;
+ char device_icon = 0;
+
+ msg("ua_payload_set_device_icon");
+
+ if (strlen(g_payload_device_icon))
+ device_icon = (unsigned char)strtol(g_payload_device_icon, NULL, 10);
+
+ ret = ua_payload_set_device_icon(g_payload_h, device_icon);
+
+ msg(" - ua_payload_set_device_icon() ret: [0x%X] [%s]",
+ ret, uat_get_error_str(ret));
+
+ return RET_SUCCESS;
+}
+
+static int run_ua_payload_set_secondary_key(
+ MManager *mm, struct menu_data *menu)
+{
+ int ret = UA_ERROR_NONE;
+ char secondary_key = 0;
+
+ msg("ua_payload_set_secondary_key");
+
+ if (strlen(g_payload_secondary_key))
+ secondary_key = (unsigned char)strtol(g_payload_secondary_key, NULL, 10);
+
+ ret = ua_payload_set_secondary_key(g_payload_h, secondary_key);
+
+ msg(" - ua_payload_set_secondary_key() ret: [0x%X] [%s]",
+ ret, uat_get_error_str(ret));
+
+ return RET_SUCCESS;
+}
+
+static int run_ua_payload_set_device_uid(
+ MManager *mm, struct menu_data *menu)
+{
+ int ret = UA_ERROR_NONE;
+
+ msg("ua_payload_set_device_uid");
+
+ ret = ua_payload_set_device_uid(g_payload_h,
+ UA_BLE_PAYLOAD_DEVICE_UID_LEN, g_payload_device_uid_str);
+
+ msg(" - ua_payload_set_device_uid() ret: [0x%X] [%s]",
+ ret, uat_get_error_str(ret));
+
+ return RET_SUCCESS;
+}
+
+static int run_ua_payload_add(
+ MManager *mm, struct menu_data *menu)
+{
+ int ret = UA_ERROR_NONE;
+
+ msg("ua_payload_add");
+
+ check_if(NULL == g_payload_h);
+
+ ret = ua_payload_add(g_payload_h, g_device_h);
+
+ msg(" - ua_payload_add() ret: [0x%X] [%s]",
+ ret, uat_get_error_str(ret));
+
+ return RET_SUCCESS;
+}
+
+static struct menu_data menu_ua_payload_set_primary_key[] = {
+ { "1", "Primary Key (0 to 255)",
+ NULL, NULL, g_payload_primary_key },
+ { "2", "run", NULL,
+ run_ua_payload_set_primary_key, NULL },
+ { NULL, NULL, },
+};
+
+static struct menu_data menu_ua_payload_set_device_icon[] = {
+ { "1", "device_icon (0 to 255)",
+ NULL, NULL, g_payload_device_icon },
+ { "2", "run", NULL,
+ run_ua_payload_set_device_icon, NULL },
+ { NULL, NULL, },
+};
+
+static struct menu_data menu_ua_payload_set_secondary_key[] = {
+ { "1", "Purpose (0 to 255)",
+ NULL, NULL, g_payload_secondary_key },
+ { "2", "run", NULL,
+ run_ua_payload_set_secondary_key, NULL },
+ { NULL, NULL, },
+};
+
+static struct menu_data menu_ua_payload_set_device_uid[] = {
+ { "1", "DEVICE_UID (Max. 17 bytes)",
+#ifdef SUPPORT_STRING_DEVICE_UID
+ NULL, NULL, g_payload_device_uid_str },
+#else
+ NULL, _scan_payload_device_uid_str, NULL },
+#endif
+ { "2", "run", NULL,
+ run_ua_payload_set_device_uid, NULL },
+ { NULL, NULL, },
+};
+
+struct menu_data menu_ua_payloads[] = {
+ { "1", "ua_payload_create",
+ NULL, run_ua_payload_create, NULL },
+ { "2", "ua_payload_destroy",
+ NULL, run_ua_payload_destroy, NULL },
+ { "3", "ua_payload_set_primary_key",
+ menu_ua_payload_set_primary_key, NULL, g_payload_primary_key },
+ { "4", "ua_payload_set_device_icon",
+ menu_ua_payload_set_device_icon, NULL, g_payload_device_icon },
+ { "5", "ua_payload_set_secondary_key",
+ menu_ua_payload_set_secondary_key, NULL, g_payload_secondary_key },
+ { "6", "ua_payload_set_device_uid",
+ menu_ua_payload_set_device_uid, NULL, g_payload_device_uid_str },
+ { "7", ANSI_COLOR_LIGHTGREEN "ua_payload_add" ANSI_COLOR_NORMAL,
+ NULL, run_ua_payload_add, NULL },
+ { NULL, NULL, },
+};
bool required = false;
bool discriminant = false;
unsigned long long last_seen = 0;
- char primary_key = 0;
- char device_icon = 0;
- char secondary_key = 0;
- char *device_uid = NULL;
if (!service_handle) {
msgr("service_handle is NULL");
if (UA_ERROR_NONE == ret_temp)
msgb("Last present at : %llu", last_seen);
- ret_temp = ua_device_get_payload_primary_key(handle, &primary_key);
- if (UA_ERROR_NONE == ret_temp)
- msgb("payload primary_key : %d[hex: 0x%X]", primary_key, primary_key);
-
- ret_temp = ua_device_get_payload_device_icon(handle, &device_icon);
- if (UA_ERROR_NONE == ret_temp)
- msgb("payload device_icon : %d[hex: 0x%X]", device_icon, device_icon);
-
- ret_temp = ua_device_get_payload_secondary_key(handle, &secondary_key);
- if (UA_ERROR_NONE == ret_temp)
- msgb("payload secondary_key : %d[hex: 0x%X]", secondary_key, secondary_key);
-
- ret_temp = ua_device_get_payload_device_uid(handle, &device_uid);
- if (UA_ERROR_NONE == ret_temp) {
- uat_print_device_uid(device_uid);
- g_free(device_uid);
- }
-
g_device_list = g_slist_append(g_device_list, handle);
return true;
bool required = false;
unsigned long long last_seen = 0;
bool discriminant = false;
- char primary_key = 0;
- char device_icon = 0;
- char secondary_key = 0;
- char *device_uid = NULL;
if (!device_handle) {
msgr("device_handle is NULL");
if (UA_ERROR_NONE == ret_temp)
msgc("Last present at : %llu", last_seen);
- ret_temp = ua_device_get_payload_primary_key(handle, &primary_key);
- if (UA_ERROR_NONE == ret_temp)
- msgc("payload primary_key : %d[hex: 0x%X]", primary_key, primary_key);
-
- ret_temp = ua_device_get_payload_device_icon(handle, &device_icon);
- if (UA_ERROR_NONE == ret_temp)
- msgc("payload device_icon : %d[hex: 0x%X]", device_icon, device_icon);
-
- ret_temp = ua_device_get_payload_secondary_key(handle, &secondary_key);
- if (UA_ERROR_NONE == ret_temp)
- msgc("payload secondary_key : %d[hex: 0x%X]", secondary_key, secondary_key);
-
- ret_temp = ua_device_get_payload_device_uid(handle, &device_uid);
- if (UA_ERROR_NONE == ret_temp) {
- uat_print_device_uid(device_uid);
- g_free(device_uid);
- }
-
g_device_list = g_slist_append(g_device_list, handle);
return true;