Add ua-manager core APIs to insert payload information
authorAbhay agarwal <ay.agarwal@samsung.com>
Fri, 29 Nov 2019 05:52:07 +0000 (11:22 +0530)
committerDoHyun Pyun <dh79.pyun@samsung.com>
Mon, 30 Dec 2019 07:29:55 +0000 (16:29 +0900)
Signed-off-by: Abhay agarwal <ay.agarwal@samsung.com>
include/ua-internal.h
ua-api/src/ua-api.c
ua-daemon/include/ua-manager-core.h
ua-daemon/src/ua-manager-core.c
ua-daemon/src/ua-manager-request-handler.c

index b240de9..672401c 100644 (file)
@@ -83,6 +83,7 @@ extern "C" {
        REQUEST(UAM_REQUEST_GET_SERVICE_USERS) \
        REQUEST(UAM_REQUEST_GET_SERVICES) \
        REQUEST(UAM_REQUEST_ADD_IBEACON_ADV) \
+       REQUEST(UAM_REQUEST_ADD_PAYLOAD) \
        REQUEST(UAM_REQUEST_MAX)
 
 #define GENERATE_REQUEST_ENUM(ENUM) ENUM,
index 9607710..2cf3f1d 100644 (file)
@@ -1456,8 +1456,8 @@ UAM_EXPORT_API int _uam_request_add_payload(uam_ble_payload_s *payload,
        g_array_append_vals(in_param2, str, sizeof(str));
        g_array_append_vals(in_param3, &tech_type, sizeof(int));
 
-//     ret = _uam_async_request(UAM_REQUEST_ADD_PAYLOAD, in_param1, in_param2,
-//                     in_param3, in_param4, cb_info.callback, cb_info.user_data);
+       ret = _uam_async_request(UAM_REQUEST_ADD_PAYLOAD, in_param1, in_param2,
+                       in_param3, in_param4, cb_info.callback, cb_info.user_data);
 
        UAM_FREE_PARAMS(in_param1, in_param2, in_param3, in_param4, out_param);
 
index 57d7a6a..434fa57 100644 (file)
@@ -253,6 +253,9 @@ int _uam_core_add_ibeacon_adv(unsigned int adv_len, const char *iadv);
 
 void _uam_core_handle_status_changed(unsigned int sensor, void *info);
 
+int _uam_core_add_payload(uam_ble_payload_s *payload, const char *device_id,
+       int tech_type);
+
 #ifdef __cplusplus
 }
 #endif
index d01c111..5d01e39 100644 (file)
@@ -3876,3 +3876,30 @@ void _uam_core_handle_status_changed(unsigned int sensor, void *info)
        FUNC_EXIT;
 }
 
+int _uam_core_add_payload(uam_ble_payload_s *payload,
+               const char *device_id, int tech_type)
+{
+       FUNC_ENTRY;
+       int ret = UAM_ERROR_NONE;
+       uam_db_tech_info_t *tech_info;
+//     char *mac;
+
+       retv_if(NULL == payload, UAM_ERROR_INVALID_PARAMETER);
+       retv_if(NULL == device_id, UAM_ERROR_INVALID_PARAMETER);
+       retv_if(UAM_TECH_TYPE_NONE >= tech_type, UAM_ERROR_INVALID_PARAMETER);
+       retv_if(UAM_TECH_TYPE_MAX <= tech_type, UAM_ERROR_INVALID_PARAMETER);
+
+       tech_info = __uam_core_get_dev_tech_info(device_id, tech_type);
+       retv_if(NULL == tech_info, UAM_ERROR_INVALID_PARAMETER);
+//     mac = __get_mac_addr(tech_info);
+
+       /*** Add payload to database ***/
+//     ret = _uam_db_insert_payload(payload, device_id, tech_type, mac);
+       if (UAM_ERROR_NONE != ret) {
+               UAM_ERR("_uam_db_insert_adv_info failed");
+               return ret;
+       }
+
+       FUNC_EXIT;
+       return UAM_ERROR_NONE;
+}
index 55ffb2a..635c5ee 100644 (file)
@@ -690,6 +690,21 @@ static int __uam_manager_sync_request_handler(
                result = _uam_core_add_ibeacon_adv(adv_len, iadv);
                break;
        }
+       case UAM_REQUEST_ADD_PAYLOAD: {
+               uam_ble_payload_s *payload;
+               const char *device_id;
+               int tech_type;
+
+               __uam_manager_copy_params(in_param1, &payload, sizeof(uam_ble_payload_s));
+               device_id = (char *)g_variant_get_data(in_param2);
+               __uam_manager_copy_params(in_param3, &tech_type, sizeof(int));
+               UAM_DBG("Payload primary key: [%d] device_id: [%s], tech_type: %d",
+                               payload->primary_key, device_id, tech_type);
+
+               result = _uam_core_add_payload(payload, device_id, tech_type);
+
+               break;
+       }
        default:
                UAM_WARN("UnSupported function [%s(0x%4.4X)]",
                                _uam_manager_request_to_str(function), function);
@@ -887,6 +902,7 @@ static gboolean __uam_manager_is_sync_function(int function)
        case UAM_REQUEST_GET_SERVICE_USERS:
        case UAM_REQUEST_GET_SERVICES:
        case UAM_REQUEST_ADD_IBEACON_ADV:
+       case UAM_REQUEST_ADD_PAYLOAD:
                return TRUE;
        default:
                return FALSE;