FUNC_EXIT;
return ret;
}
+
+UAM_EXPORT_API int _uam_get_added_payloads(GPtrArray **payload_list)
+{
+ FUNC_ENTRY;
+ int ret;
+
+ UAM_VALIDATE_INPUT_PARAMETER(payload_list);
+
+ UAM_INIT_PARAMS();
+ UAM_ALLOC_PARAMS(in_param1, in_param2, in_param3, in_param4, out_param);
+
+ ret = _uam_sync_request(UAM_REQUEST_GET_PAYLOADS,
+ in_param1, in_param2, in_param3, in_param4, &out_param);
+ if (UAM_ERROR_NONE == ret && NULL != out_param) {
+ int i;
+ int count;
+
+ count = (out_param->len)/sizeof(uam_ble_payload_s);
+ if (0 == count)
+ UAM_INFO("No registered payloads");
+
+ for (i = 0; i < count; i++) {
+ uam_ble_payload_s *payload_info = NULL;
+ uam_ble_payload_s *info;
+
+ info = &g_array_index(out_param, uam_ble_payload_s, i);
+ payload_info = g_memdup(info, sizeof(uam_ble_payload_s));
+ if (payload_info)
+ g_ptr_array_add(*payload_list, (gpointer)payload_info);
+ }
+ }
+
+ UAM_FREE_PARAMS(in_param1, in_param2, in_param3, in_param4, out_param);
+
+ FUNC_EXIT;
+ return ret;
+}
static GSList *devices; /* List of devices - uam_db_device_info_t */
static GSList *services; /* List of services - uam_db_service_info_t */
static GSList *svc_devs; /* List of service device mapping - uam_svc_dev_info_t */
+static GSList *payloads; /* List of payloads - uam_db_payload_info_t */
static GSList *monitors; /* List of monitoring apps - uam_monitor_info_t */
static GSList *scanners; /* List of scanning apps - uam_scanner_info_t */
}
}
-/*
-static void __uam_copy_payload_info(uam_ble_payload_s *dev_payload, uam_db_ble_payload_t *payload)
-{
- if (payload) {
- dev_payload->primary_key = payload->primary_key;
- dev_payload->device_icon = payload->device_icon;
- dev_payload->secondary_key = payload->secondary_key;
- if (payload->device_uid)
- memcpy(dev_payload->device_uid,
- payload->device_uid, UAM_BLE_PAYLOAD_DEVICE_UID_LEN);
- if (payload->bt_mac)
- memcpy(dev_payload->bt_mac,
- payload->bt_mac, UAM_BT_MAC_ADDRESS_STRING_LEN);
- }
-}
-*/
-
static int __copy_tech_info_to_device_info(uam_db_tech_info_t *tech, uam_device_info_s *device)
{
FUNC_ENTRY;
FUNC_EXIT;
}
+static void __uam_copy_db_payload_info(uam_ble_payload_s *dst_payload,
+ uam_db_payload_info_t *src_payload)
+{
+ if (src_payload) {
+ dst_payload->primary_key = src_payload->primary_key;
+ dst_payload->device_icon = src_payload->device_icon;
+ dst_payload->secondary_key = src_payload->secondary_key;
+ if (src_payload->device_uid)
+ memcpy(dst_payload->device_uid,
+ src_payload->device_uid, UAM_BLE_PAYLOAD_DEVICE_UID_LEN);
+ if (src_payload->bt_mac)
+ memcpy(dst_payload->bt_mac,
+ src_payload->bt_mac, UAM_BT_MAC_ADDRESS_STRING_LEN);
+ }
+}
+
+static void __uam_copy_uam_payload_info(
+ uam_db_payload_info_t *dst_payload, uam_ble_payload_s *src_payload)
+{
+ if (src_payload) {
+ dst_payload = g_new0(uam_db_payload_info_t, 1);
+ dst_payload->primary_key = src_payload->primary_key;
+ dst_payload->device_icon = src_payload->device_icon;
+ dst_payload->secondary_key = src_payload->secondary_key;
+ dst_payload->device_uid = g_memdup(&(src_payload->device_uid),
+ UAM_BLE_PAYLOAD_DEVICE_UID_LEN);
+ dst_payload->bt_mac = g_memdup(&(src_payload->bt_mac),
+ UAM_BT_MAC_ADDRESS_STRING_LEN);
+ }
+}
+
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;
+ uam_db_payload_info_t *db_payload;
char *mac;
retv_if(NULL == payload, 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);
+ // <TO-DO> check if payload already exist
+
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);
return ret;
}
+ __uam_copy_uam_payload_info(db_payload, payload);
+ payloads = g_slist_append(payloads, db_payload);
+
FUNC_EXIT;
return UAM_ERROR_NONE;
}
retv_if(NULL == payload, UAM_ERROR_INVALID_PARAMETER);
retv_if(NULL == svc_name, UAM_ERROR_INVALID_PARAMETER);
+ // <TO-DO> check if payload exist
+ // <TO-DO> check if service exist
+ // <TO-DO> check if device-service exist
+
/* Retrieve service from list */
l = g_slist_find_custom(services, svc_name, __compare_svc_name);
retv_if(NULL == l, UAM_ERROR_INVALID_PARAMETER);
service = l->data;
- /*** Add payload to database ***/
+ /*** Add payload service mapping to database ***/
ret = _uam_db_update_device_service_payload_info(payload, service->name);
if (UAM_ERROR_NONE != ret) {
UAM_ERR("_uam_db_update_device_service_payload_info failed");
FUNC_EXIT;
return UAM_ERROR_NONE;
}
+
+int _uam_core_get_payloads(int *count, uam_ble_payload_s **payload_list)
+{
+ FUNC_ENTRY;
+ guint size;
+ GSList *l;
+
+ size = g_slist_length(payloads);
+ *payload_list = g_new0(uam_ble_payload_s, size);
+ *count = 0;
+
+ /* fetch payloads list from DB */
+ for (l = payloads; l; l = g_slist_next(l)) {
+ uam_db_payload_info_t *db_info = l->data;
+
+ if (!db_info || !db_info->device_uid)
+ continue;
+
+ __uam_copy_db_payload_info(&(*payload_list)[*count], db_info);
+ *count += 1;
+ }
+
+ UAM_INFO("Count: %d", *count);
+ FUNC_EXIT;
+ return UAM_ERROR_NONE;
+}