g_free(device->addr_list[i].address);
g_free(device->addr_list);
-
- if (device->payload) {
- g_free(device->payload->device_uid);
- g_free(device->payload->bt_mac);
- g_free(device->payload);
- }
-
g_free(device);
FUNC_EXIT;
(*device)->addr_list[i].type = _pm_util_uam_addr_type_to_uas_addr_type(addr->addr_type);
(*device)->addr_list[i++].address = g_strdup(addr->address);
}
- (*device)->payload = g_new0(uas_ble_payload_t, 1);
- (*device)->payload->primary_key = tech->payload->primary_key;
- (*device)->payload->secondary_key = tech->payload->secondary_key;
- (*device)->payload->device_icon = tech->payload->device_icon;
- (*device)->payload->device_uid = g_memdup(tech->payload->device_uid, UAM_BLE_PAYLOAD_DEVICE_UID_LEN);
- (*device)->payload->bt_mac = g_memdup(tech->payload->bt_mac, UAM_BT_MAC_ADDRESS_STRING_LEN);
}
FUNC_EXIT;
device->device_id = g_strdup(dev->device_id);
- device->payload = g_new0(uas_ble_payload_t, 1);
- device->payload->primary_key = dev->payload.primary_key;
- device->payload->secondary_key = dev->payload.secondary_key;
- device->payload->device_icon = dev->payload.device_icon;
- device->payload->device_uid = g_memdup(&(dev->payload.device_uid), UAM_BLE_PAYLOAD_DEVICE_UID_LEN);
- device->payload->bt_mac = g_memdup(&(dev->payload.bt_mac), UAM_BT_MAC_ADDRESS_STRING_LEN);
-
device->addr_list = g_new0(uas_address_info_t, device->num_addr);
if (mac) {
device->addr_list[i].type = type;
device->last_seen = dev->last_seen;
g_strlcpy(device->device_id, dev->device_id, UAM_DEVICE_ID_MAX_STRING_LEN);
- memset(device->payload.device_uid, 0, UAM_BLE_PAYLOAD_DEVICE_UID_LEN + 1);
- memset(device->payload.bt_mac, 0, UAM_BT_MAC_ADDRESS_STRING_LEN);
- if (dev->payload) {
- device->payload.primary_key = dev->payload->primary_key;
- device->payload.device_icon = dev->payload->device_icon;
- device->payload.secondary_key = dev->payload->secondary_key;
- if (dev->payload->device_uid)
- memcpy(device->payload.device_uid, dev->payload->device_uid, UAM_BLE_PAYLOAD_DEVICE_UID_LEN);
- if (dev->payload->bt_mac)
- g_strlcpy(device->payload.bt_mac,
- dev->payload->bt_mac, UAM_BT_MAC_ADDRESS_STRING_LEN);
- }
-
for (i = 0; i < dev->num_addr; i++) {
UAM_DBG("Address[%d]: %s", i, dev->addr_list[i].address);
switch (dev->addr_list[i].type) {
g_slist_free_full(tech_info->addresses, __free_address_info);
tech_info->addresses = NULL;
- if (tech_info->payload) {
- g_free(tech_info->payload->device_uid);
- g_free(tech_info->payload->bt_mac);
- g_free(tech_info->payload);
- }
-
g_free(tech_info);
FUNC_EXIT;
}
}
+/*
static void __uam_copy_payload_info(uam_ble_payload_s *dev_payload, uam_db_ble_payload_t *payload)
{
if (payload) {
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)
{
UAM_DEVICE_ID_MAX_STRING_LEN);
device->type = tech->tech_type;
device->discriminant = tech->discriminant;
- memset(device->payload.device_uid, 0, UAM_BLE_PAYLOAD_DEVICE_UID_LEN + 1);
- memset(device->payload.bt_mac, 0, UAM_BT_MAC_ADDRESS_STRING_LEN);
device->last_seen = tech->last_seen;
- __uam_copy_payload_info(&(device->payload), tech->payload);
FUNC_EXIT;
return UAM_ERROR_NONE;
tech->device = device;
tech->discriminant = dev_info->discriminant;
- tech->payload = g_new0(uam_db_ble_payload_t, 1);
- tech->payload->primary_key = dev_info->payload.primary_key;
- tech->payload->secondary_key = dev_info->payload.secondary_key;
- tech->payload->device_icon = dev_info->payload.device_icon;
- tech->payload->device_uid = g_memdup(&(dev_info->payload.device_uid), UAM_BLE_PAYLOAD_DEVICE_UID_LEN);
- tech->payload->bt_mac = g_memdup(&(dev_info->payload.bt_mac), UAM_BT_MAC_ADDRESS_STRING_LEN);
-
tech->svc_list = svc_list;
g_slist_foreach(tech->svc_list, __print_service, tech);
for (l = svc_list; NULL != l; l = g_slist_next(l)) {
/* Update discriminant for device-tech */
tech->discriminant = a_device->discriminant;
- /* Update Payload for device-tech */
- tech->payload->primary_key = a_device->payload.primary_key;
- tech->payload->secondary_key = a_device->payload.secondary_key;
- tech->payload->device_icon = a_device->payload.device_icon;
- tech->payload->device_uid = g_memdup(&(a_device->payload.device_uid), UAM_BLE_PAYLOAD_DEVICE_UID_LEN);
- tech->payload->bt_mac = g_memdup(&(a_device->payload.bt_mac), UAM_BT_MAC_ADDRESS_STRING_LEN);
-
/* Update device's updated information to database */
ret = __copy_tech_info_to_device_info(tech, &temp);
if (UAM_ERROR_NONE != ret) {
return ret;
}
- ret = _uam_device_db_update_device_device(temp.device_id, temp.type,
- temp.mac, temp.ipv4_addr, temp.operating_system, temp.discriminant,
- temp.payload);
+ ret = _uam_device_db_update_device(temp.device_id, temp.type,
+ temp.mac, temp.ipv4_addr, temp.operating_system, temp.discriminant);
if (UAM_ERROR_NONE != ret) {
- UAM_ERR("_uam_device_db_update_device_device failed [%d]", ret);
+ UAM_ERR("_uam_device_db_update_device failed [%d]", ret);
return ret;
}
}
#define SELECT_ALL_DEVICES "SELECT device_id, tech_type, address, " \
"ip_address, last_seen, presence_state, os_type, " \
- "user_id, discriminant, primary_key, secondary_key, device_uid, device_icon FROM devices"
+ "user_id, discriminant FROM devices"
#define SELECT_DEVICE "SELECT device_id, tech_type, address, " \
"ip_address, last_seen, presence_state, os_type, " \
- "user_id, discriminant, primary_key, secondary_key, device_uid, device_icon FROM devices " \
+ "user_id, discriminant FROM devices " \
"WHERE device_id = ? AND tech_type = ? AND address = ?"
#define SELECT_DEVICE_NUMBER "SELECT device_number FROM devices " \
#define INSERT_DEVICE "insert into devices " \
"(device_id, tech_type, address, ip_address, last_seen, " \
- "presence_state, os_type, user_id, discriminant, primary_key, " \
- "secondary_key, device_uid, device_icon)" \
- "values (?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?)"
+ "presence_state, os_type, user_id, discriminant)" \
+ "values (?, ?, ?, ?, ?, ?, ?, ?, ?)"
#define UPDATE_LAST_SEEN "UPDATE devices " \
"SET last_seen = ? WHERE device_id = ? AND tech_type = ? AND address = ?"
"SET address = ? WHERE device_id = ? AND tech_type = ?"
#define UPDATE_DEVICE "UPDATE devices " \
- "SET (os_type, discriminant, ip_address, primary_key, " \
- "secondary_key, device_uid, device_icon) = (?, ?, ?, ?, ?, ?, ?) " \
+ "SET (os_type, discriminant, ip_address) = (?, ?, ?) " \
"WHERE device_id = ? AND tech_type = ? AND address = ?"
#define DELETE_ALL_DEVICES "delete from devices "
return error_code;
}
-int _uam_device_db_update_device_device(char *device_id, int tech_type,
- char *address, char *ip, char os_type, char discriminant, uam_ble_payload_s payload)
+int _uam_device_db_update_device(char *device_id, int tech_type,
+ char *address, char *ip, char os_type, char discriminant)
{
int error_code = UAM_ERROR_NONE;
sqlite3_stmt *stmt = update_device;
error_code, handle_error);
DB_ACTION(sqlite3_bind_text(stmt, 3, ip, -1, SQLITE_TRANSIENT),
error_code, handle_error);
- DB_ACTION(sqlite3_bind_text(stmt, 4, &(payload.primary_key), 1, SQLITE_TRANSIENT),
+ DB_ACTION(sqlite3_bind_text(stmt, 4, device_id, -1, SQLITE_TRANSIENT),
error_code, handle_error);
- DB_ACTION(sqlite3_bind_text(stmt, 5, &(payload.secondary_key), 1, SQLITE_TRANSIENT),
+ DB_ACTION(sqlite3_bind_int(stmt, 5, tech_type),
error_code, handle_error);
- DB_ACTION(sqlite3_bind_text(stmt, 6, payload.device_uid, UAM_BLE_PAYLOAD_DEVICE_UID_LEN + 1, SQLITE_TRANSIENT),
- error_code, handle_error);
- DB_ACTION(sqlite3_bind_text(stmt, 7, &(payload.device_icon), 1, SQLITE_TRANSIENT),
- error_code, handle_error);
- DB_ACTION(sqlite3_bind_text(stmt, 8, device_id, -1, SQLITE_TRANSIENT),
- error_code, handle_error);
- DB_ACTION(sqlite3_bind_int(stmt, 9, tech_type),
- error_code, handle_error);
- DB_ACTION(sqlite3_bind_text(stmt, 10, address, -1, SQLITE_TRANSIENT),
+ DB_ACTION(sqlite3_bind_text(stmt, 6, address, -1, SQLITE_TRANSIENT),
error_code, handle_error);
sql_ret = sqlite3_step(stmt);
retv_if(NULL == dev_info, UAM_ERROR_INVALID_PARAMETER);
- UAM_INFO("%s-%d-%s-%s-%llu-%d-%d-%d-%d-0x%2.2X", dev_info->device_id,
+ UAM_INFO("%s-%d-%s-%s-%llu-%d-%d-%d-%d", dev_info->device_id,
dev_info->type, dev_info->mac, dev_info->ipv4_addr,
last_seen, presence_state, dev_info->operating_system, dev_info->discriminant,
- user_id, dev_info->payload.primary_key);
+ user_id);
DB_ACTION(sqlite3_bind_text(stmt, 1, dev_info->device_id, -1, SQLITE_TRANSIENT),
error_code, handle_error);
error_code, handle_error);
DB_ACTION(sqlite3_bind_int(stmt, 9, dev_info->discriminant),
error_code, handle_error);
- DB_ACTION(sqlite3_bind_text(stmt, 10, &(dev_info->payload.primary_key), 1, SQLITE_TRANSIENT),
- error_code, handle_error);
- DB_ACTION(sqlite3_bind_text(stmt, 11, &(dev_info->payload.secondary_key), 1, SQLITE_TRANSIENT),
- error_code, handle_error);
- DB_ACTION(sqlite3_bind_text(stmt, 12, dev_info->payload.device_uid, UAM_BLE_PAYLOAD_DEVICE_UID_LEN + 1, SQLITE_TRANSIENT),
- error_code, handle_error);
- DB_ACTION(sqlite3_bind_text(stmt, 13, &(dev_info->payload.device_icon), 1, SQLITE_TRANSIENT),
- error_code, handle_error);
sql_ret = sqlite3_step(stmt);
if (sql_ret != SQLITE_DONE) {
int error_code = UAM_ERROR_NONE;
sqlite3_stmt *stmt = select_device;
int sql_ret = SQLITE_OK;
- char *buf = NULL;
retv_if(NULL == info, UAM_ERROR_INVALID_PARAMETER);
info->dev_info.operating_system = sqlite3_column_int(stmt, 6);
info->user_id = sqlite3_column_int(stmt, 7);
info->dev_info.discriminant = sqlite3_column_int(stmt, 8);
- memset(info->dev_info.payload.device_uid, 0, UAM_BLE_PAYLOAD_DEVICE_UID_LEN + 1);
- buf = (char *)sqlite3_column_text(stmt, 9);
- info->dev_info.payload.primary_key = buf ? *buf : 13;
- buf = (char *)sqlite3_column_text(stmt, 10);
- info->dev_info.payload.secondary_key = buf ? *buf : 1;
- if ((char*)sqlite3_column_text(stmt, 11))
- memcpy(info->dev_info.payload.device_uid, (char *)sqlite3_column_text(stmt, 11),
- UAM_BLE_PAYLOAD_DEVICE_UID_LEN);
- buf = (char *)sqlite3_column_text(stmt, 12);
- info->dev_info.payload.device_icon = buf ? *buf : 1;
-
- UAM_INFO("%s-%d-%s-%s-%llu-%d-%d-%d-%d-0x%2.2X",
+
+ UAM_INFO("%s-%d-%s-%s-%llu-%d-%d-%d-%d",
info->dev_info.device_id,
info->dev_info.type,
info->dev_info.mac,
info->presence_state,
info->dev_info.operating_system,
info->user_id,
- info->dev_info.discriminant,
- info->dev_info.payload.primary_key);
+ info->dev_info.discriminant);
}
handle_error:
GSList *device_list = NULL;
db_device_info_t *info = NULL;
int sql_ret = SQLITE_OK;
- char *buf = NULL;
do {
sql_ret = sqlite3_step(stmt);
info->dev_info.operating_system = sqlite3_column_int(stmt, 6);
info->user_id = sqlite3_column_int(stmt, 7);
info->dev_info.discriminant = sqlite3_column_int(stmt, 8);
- memset(info->dev_info.payload.device_uid, 0, UAM_BLE_PAYLOAD_DEVICE_UID_LEN + 1);
- buf = (char *)sqlite3_column_text(stmt, 9);
- info->dev_info.payload.primary_key = buf ? *buf : 13;
- buf = (char *)sqlite3_column_text(stmt, 10);
- info->dev_info.payload.secondary_key = buf ? *buf : 1;
- if ((char*)sqlite3_column_text(stmt, 11))
- memcpy(info->dev_info.payload.device_uid, (char *)sqlite3_column_text(stmt, 11),
- UAM_BLE_PAYLOAD_DEVICE_UID_LEN);
- buf = (char *)sqlite3_column_text(stmt, 12);
- info->dev_info.payload.device_icon = buf ? *buf : 1;
-
- UAM_INFO("%s-%d-%s-%s-%llu-%d-%d-%d-%d-0x%2.2X",
+
+ UAM_INFO("%s-%d-%s-%s-%llu-%d-%d-%d-%d",
info->dev_info.device_id,
info->dev_info.type,
info->dev_info.mac,
info->presence_state,
info->dev_info.operating_system,
info->user_id,
- info->dev_info.discriminant,
- info->dev_info.payload.primary_key);
+ info->dev_info.discriminant);
device_list = g_slist_append(device_list, info);
break;