From: Abhay agarwal Date: Mon, 19 Aug 2019 13:13:37 +0000 (+0530) Subject: Modify update device API to support BLE payload update X-Git-Tag: accepted/tizen/unified/20190822.105942~4 X-Git-Url: http://review.tizen.org/git/?a=commitdiff_plain;h=13768f98791feb54f967333fd20f59203f8c9fe2;p=platform%2Fcore%2Fconnectivity%2Fua-manager.git Modify update device API to support BLE payload update Signed-off-by: Abhay agarwal --- diff --git a/packaging/ua-manager.spec b/packaging/ua-manager.spec index c397ef2..f28114d 100644 --- a/packaging/ua-manager.spec +++ b/packaging/ua-manager.spec @@ -1,6 +1,6 @@ Name: ua-manager Summary: User awareness manager -Version: 0.6.5 +Version: 0.6.6 Release: 1 License: Apache-2.0 Source0: %{name}-%{version}.tar.gz diff --git a/ua-daemon/include/ua-manager-database.h b/ua-daemon/include/ua-manager-database.h index 1464854..c9dd226 100644 --- a/ua-daemon/include/ua-manager-database.h +++ b/ua-daemon/include/ua-manager-database.h @@ -128,7 +128,7 @@ int _ua_device_db_update_device_presence( int _ua_device_db_update_device_ip_address( char *device_id, int tech_type, char *address, char *ip_address); int _ua_device_db_update_device_device(char *device_id, int tech_type, - char *address, char *ip, char os_type, char discriminant); + char *address, char *ip, char os_type, char discriminant, uam_ble_payload_s payload); /* SERVICE QUERIES */ typedef struct { diff --git a/ua-daemon/src/ua-manager-core.c b/ua-daemon/src/ua-manager-core.c index 99dc040..f3c6497 100644 --- a/ua-daemon/src/ua-manager-core.c +++ b/ua-daemon/src/ua-manager-core.c @@ -1183,11 +1183,19 @@ int _uam_core_update_device(const uam_device_info_s *a_device) /* Update discriminant for device-tech */ tech->discriminant = a_device->discriminant; - /* Update device's discriminant to database */ + /* Update Payload for device-tech */ + tech->payload->service_id = a_device->payload.service_id; + tech->payload->purpose = a_device->payload.purpose; + tech->payload->device_icon = a_device->payload.device_icon; + tech->payload->duid = g_memdup(&(a_device->payload.duid), UAM_BLE_PAYLOAD_DUID_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 */ __copy_tech_info_to_device_info(tech, &temp); ret = _ua_device_db_update_device_device(temp.device_id, temp.type, - temp.mac, temp.ipv4_addr, temp.operating_system, temp.discriminant); + temp.mac, temp.ipv4_addr, temp.operating_system, temp.discriminant, + temp.payload); if (UAM_ERROR_NONE != ret) UAM_WARN("_ua_device_db_update_device_device failed [%d]", ret); } diff --git a/ua-daemon/src/ua-manager-device-db.c b/ua-daemon/src/ua-manager-device-db.c index 2f9f182..1e09491 100644 --- a/ua-daemon/src/ua-manager-device-db.c +++ b/ua-daemon/src/ua-manager-device-db.c @@ -54,7 +54,8 @@ "SET ip_address = ? WHERE device_id = ? AND tech_type = ? AND address = ?" #define UPDATE_DEVICE "UPDATE devices " \ - "SET (os_type, discriminant, ip_address) = (?, ?, ?) " \ + "SET (os_type, discriminant, ip_address, service_id, " \ + "purpose, duid) = (?, ?, ?, ?, ?, ?) " \ "WHERE device_id = ? AND tech_type = ? AND address = ?" #define DELETE_ALL_DEVICES "delete from devices " @@ -419,7 +420,7 @@ handle_error: } int _ua_device_db_update_device_device(char *device_id, int tech_type, - char *address, char *ip, char os_type, char discriminant) + char *address, char *ip, char os_type, char discriminant, uam_ble_payload_s payload) { int error_code = UAM_ERROR_NONE; sqlite3_stmt *stmt = update_device; @@ -433,11 +434,17 @@ int _ua_device_db_update_device_device(char *device_id, int tech_type, 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, device_id, -1, SQLITE_TRANSIENT), + DB_ACTION(sqlite3_bind_text(stmt, 4, &(payload.service_id), 1, SQLITE_TRANSIENT), error_code, handle_error); - DB_ACTION(sqlite3_bind_int(stmt, 5, tech_type), + DB_ACTION(sqlite3_bind_text(stmt, 5, &(payload.purpose), 1, SQLITE_TRANSIENT), error_code, handle_error); - DB_ACTION(sqlite3_bind_text(stmt, 6, address, -1, SQLITE_TRANSIENT), + DB_ACTION(sqlite3_bind_text(stmt, 6, payload.duid, UAM_BLE_PAYLOAD_DUID_LEN + 1, SQLITE_TRANSIENT), + error_code, handle_error); + DB_ACTION(sqlite3_bind_text(stmt, 7, device_id, -1, SQLITE_TRANSIENT), + error_code, handle_error); + DB_ACTION(sqlite3_bind_int(stmt, 8, tech_type), + error_code, handle_error); + DB_ACTION(sqlite3_bind_text(stmt, 9, address, -1, SQLITE_TRANSIENT), error_code, handle_error); if (sqlite3_step(stmt) != SQLITE_DONE) { @@ -488,7 +495,7 @@ int _ua_device_db_insert_device_info(int user_id, DB_ACTION(sqlite3_bind_int(stmt, 9, dev_info->discriminant), error_code, handle_error); DB_ACTION(sqlite3_bind_text(stmt, 10, &(dev_info->payload.service_id), 1, SQLITE_TRANSIENT), - error_code, handle_error); // fourth parameter is number of bytes, set to 1 to store one byte + error_code, handle_error); DB_ACTION(sqlite3_bind_text(stmt, 11, &(dev_info->payload.purpose), 1, SQLITE_TRANSIENT), error_code, handle_error); DB_ACTION(sqlite3_bind_text(stmt, 12, dev_info->payload.duid, UAM_BLE_PAYLOAD_DUID_LEN + 1, SQLITE_TRANSIENT),