From a2801fa0f0f1d4f7ec8e1fb20b6e0c778c28c1e5 Mon Sep 17 00:00:00 2001 From: Neeraj Bijalwan Date: Fri, 28 Jan 2022 05:54:45 +0000 Subject: [PATCH] Added CommandKey in TransferComplete event --- dmdiagnostics.c | 17 ++++++++++------- dmdiagnostics.h | 2 +- dmtree/tr181/deviceinfo.c | 6 +++++- 3 files changed, 16 insertions(+), 9 deletions(-) diff --git a/dmdiagnostics.c b/dmdiagnostics.c index 20716ce9..d42fa293 100644 --- a/dmdiagnostics.c +++ b/dmdiagnostics.c @@ -87,7 +87,7 @@ static bool get_response_code_status(const char *url, int response_code) } static void send_transfer_complete_event(const char *command, const char *obj_path, const char *transfer_url, - long res_code, time_t start_t, time_t complete_t, const char *transfer_type) + long res_code, time_t start_t, time_t complete_t,const char *commandKey, const char *transfer_type) { char start_time[32] = {0}; char complete_time[32] = {0}; @@ -105,7 +105,10 @@ static void send_transfer_complete_event(const char *command, const char *obj_pa struct json_object *obj = json_object_new_object(); json_object_object_add(obj, "Command", json_object_new_string(command)); - json_object_object_add(obj, "CommandKey", json_object_new_string("")); + if(commandKey) + json_object_object_add(obj, "CommandKey", json_object_new_string(commandKey)); + else + json_object_object_add(obj, "CommandKey", json_object_new_string("")); json_object_object_add(obj, "Requestor", json_object_new_string("")); json_object_object_add(obj, "TransferType", json_object_new_string(transfer_type)); json_object_object_add(obj, "Affected", json_object_new_string(obj_path)); @@ -413,7 +416,7 @@ int bbf_config_backup(const char *url, const char *username, const char *passwor time_t complete_time = time(NULL); // Send Transfer Complete Event - send_transfer_complete_event(command, obj_path, url, res_code, start_time, complete_time, "Upload"); + send_transfer_complete_event(command, obj_path, url, res_code, start_time, complete_time,NULL,"Upload"); // Check if the upload operation was successful if (!get_response_code_status(url, res_code)) { @@ -440,7 +443,7 @@ int bbf_upload_log(const char *url, const char *username, const char *password, time_t complete_time = time(NULL); // Send Transfer Complete Event - send_transfer_complete_event(command, obj_path, url, res_code, start_time, complete_time, "Upload"); + send_transfer_complete_event(command, obj_path, url, res_code, start_time, complete_time,NULL, "Upload"); // Check if the upload operation was successful if (!get_response_code_status(url, res_code)) { @@ -468,7 +471,7 @@ int bbf_config_restore(const char *url, const char *username, const char *passwo time_t complete_time = time(NULL); // Send Transfer Complete Event - send_transfer_complete_event(command, obj_path, url, res_code, start_time, complete_time, "Download"); + send_transfer_complete_event(command, obj_path, url, res_code, start_time, complete_time, NULL, "Download"); // Check if the download operation was successful if (!get_response_code_status(url, res_code)) { @@ -496,7 +499,7 @@ end: int bbf_fw_image_download(const char *url, const char *auto_activate, const char *username, const char *password, const char *file_size, const char *checksum_algorithm, const char *checksum, - const char *bank_id, const char *command, const char *obj_path) + const char *bank_id, const char *command, const char *obj_path, const char *commandKey) { char fw_image_path[256] = "/tmp/firmware.bin"; json_object *json_obj = NULL; @@ -515,7 +518,7 @@ int bbf_fw_image_download(const char *url, const char *auto_activate, const char time_t complete_time = time(NULL); // Send Transfer Complete Event - send_transfer_complete_event(command, obj_path, url, res_code, start_time, complete_time, "Download"); + send_transfer_complete_event(command, obj_path, url, res_code, start_time, complete_time,commandKey, "Download"); // Check if the download operation was successful if (!get_response_code_status(url, res_code)) { diff --git a/dmdiagnostics.h b/dmdiagnostics.h index 1bc40b5d..5141f46d 100644 --- a/dmdiagnostics.h +++ b/dmdiagnostics.h @@ -80,7 +80,7 @@ int bbf_config_restore(const char *url, const char *username, const char *passwo const char *command, const char *obj_path); int bbf_fw_image_download(const char *url, const char *auto_activate, const char *username, const char *password, const char *file_size, const char *checksum_algorithm, const char *checksum, - const char *bank_id, const char *command, const char *obj_path); + const char *bank_id, const char *command, const char *obj_path, const char *commandKey); int bbf_fw_image_activate(const char *bank_id, struct activate_image *active_img); #endif diff --git a/dmtree/tr181/deviceinfo.c b/dmtree/tr181/deviceinfo.c index 2a3a27d9..433d7b08 100644 --- a/dmtree/tr181/deviceinfo.c +++ b/dmtree/tr181/deviceinfo.c @@ -940,6 +940,7 @@ static operation_args firmware_image_download_args = { "FileSize", "CheckSumAlgorithm", "CheckSum", + "CommandKey", NULL } }; @@ -969,16 +970,19 @@ static int operate_DeviceInfoFirmwareImage_Download(char *refparam, struct dmctx char *file_size = dmjson_get_value((json_object *)value, 1, "FileSize"); char *checksum_algorithm = dmjson_get_value((json_object *)value, 1, "CheckSumAlgorithm"); char *checksum = dmjson_get_value((json_object *)value, 1, "CheckSum"); + char *commandKey = dmjson_get_value((json_object *)value, 1, "CommandKey"); + char *bank_id = dmjson_get_value((json_object *)data, 1, "id"); - int res = bbf_fw_image_download(url, auto_activate, username, password, file_size, checksum_algorithm, checksum, bank_id, command, obj_path); + int res = bbf_fw_image_download(url, auto_activate, username, password, file_size, checksum_algorithm, checksum, bank_id, command, obj_path, commandKey); return res ? CMD_FAIL : CMD_SUCCESS; } static operation_args firmware_image_activate_args = { .in = (const char *[]) { + "TimeWindow.{i}.Start", "TimeWindow.{i}.End", "TimeWindow.{i}.Mode",