diff --git a/datamodel_interface.c b/datamodel_interface.c index 1823f5f..2357e8e 100644 --- a/datamodel_interface.c +++ b/datamodel_interface.c @@ -14,6 +14,8 @@ bool transaction_started = false; int transaction_id = 0; +json_object *old_global_json_obj = NULL; +json_object *actual_global_json_obj = NULL; json_object *old_list_notify = NULL; json_object *actual_list_notify = NULL; @@ -381,18 +383,28 @@ char* cwmp_set_parameter_attributes(char* parameter_name, char* notification) int cwmp_update_enabled_list_notify(int instance_mode, int notify_type) { int e; - json_object *list_notif_obj = NULL; - e = cwmp_ubus_call("usp.raw", "list_notify", CWMP_UBUS_ARGS{{"instance_mode", {.int_val=instance_mode}, UBUS_Integer}}, 1, &list_notif_obj); - if (e) - return e; + CWMP_LOG (INFO,"Get List Notify for %s paramters values", notify_type == OLD_LIST_NOTIFY ? "old": "actual"); if (notify_type == OLD_LIST_NOTIFY) { + CWMP_LOG (INFO,"%s line %d", __FILE__, __LINE__); FREE_JSON(old_list_notify) - json_object_object_get_ex(list_notif_obj, "parameters", &old_list_notify); + FREE_JSON(old_global_json_obj) + CWMP_LOG (INFO,"%s:%s line %d", __FILE__, __FUNCTION__, __LINE__); + e = cwmp_ubus_call("usp.raw", "list_notify", CWMP_UBUS_ARGS{{"instance_mode", {.int_val=instance_mode}, UBUS_Integer}}, 1, &old_global_json_obj); + if (e) + return e; + json_object_object_get_ex(old_global_json_obj, "parameters", &old_list_notify); + CWMP_LOG (INFO,"%s line %d", __FILE__, __LINE__); } else { + CWMP_LOG (INFO,"%s line %d", __FILE__, __LINE__); FREE_JSON(actual_list_notify) - json_object_object_get_ex(list_notif_obj, "parameters", &actual_list_notify); + FREE_JSON(actual_global_json_obj) + CWMP_LOG (INFO,"%s line %d", __FILE__, __FUNCTION__, __LINE__); + e = cwmp_ubus_call("usp.raw", "list_notify", CWMP_UBUS_ARGS{{"instance_mode", {.int_val=instance_mode}, UBUS_Integer}}, 1, &actual_global_json_obj); + if (e) + return e; + json_object_object_get_ex(actual_global_json_obj, "parameters", &actual_list_notify); + CWMP_LOG (INFO,"%s line %d", __FILE__, __FUNCTION__, __LINE__); } - //FREE_JSON(list_notif_obj) return 0; } diff --git a/inc/datamodel_interface.h b/inc/datamodel_interface.h index 67f2359..dd29b85 100644 --- a/inc/datamodel_interface.h +++ b/inc/datamodel_interface.h @@ -9,6 +9,8 @@ #define DM_ROOT_OBJ "Device." extern bool transaction_started; extern int transaction_id; +extern json_object *old_global_json_obj; +extern json_object *actual_global_json_obj; extern json_object *old_list_notify; extern json_object *actual_list_notify; diff --git a/scripts/icwmp.sh b/scripts/icwmp.sh index 63c6a03..1d9250c 100644 --- a/scripts/icwmp.sh +++ b/scripts/icwmp.sh @@ -195,13 +195,10 @@ handle_action() { if [ -z `echo $set_res | jsonfilter -e @.fault` ]; then if [ `echo $set_res | jsonfilter -e @.status` = true ]; then ubus call usp.raw transaction_commit "{'transaction_id':$transaction_id}" &> /dev/null - echo "Parameter is successfully set" else - echo "Not able to set parameter" ubus call usp.raw transaction_abort "{'transaction_id':$transaction_id}" &> /dev/null fi else - echo "Not able to set parameter" ubus call usp.raw transaction_abort "{'transaction_id':$transaction_id}" &> /dev/null fi echo $set_res @@ -219,13 +216,10 @@ handle_action() { if [ -z `echo $set_notif | jsonfilter -e @.fault` ]; then if [ -z `echo $set_notif | jsonfilter -e @.parameters[0].fault` ]; then ubus call usp.raw transaction_commit "{'transaction_id':$transaction_id}" &> /dev/null - echo "Parameter notification is successfully set" else - echo "Not able to set parameter notification" ubus call usp.raw transaction_abort "{'transaction_id':$transaction_id}" &> /dev/null fi else - echo "Not able to set parameter" ubus call usp.raw transaction_abort "{'transaction_id':$transaction_id}" &> /dev/null fi echo $set_notif @@ -243,13 +237,10 @@ handle_action() { if [ -z `echo $adddel_obj_res | jsonfilter -e @.fault` ]; then if [ -z `echo $adddel_obj_res | jsonfilter -e @.parameters[0].fault` ]; then ubus call usp.raw transaction_commit "{'transaction_id':$transaction_id}" &> /dev/null - echo "Add/Delete operation successfully done" else - echo "Add/Delete operation failed" ubus call usp.raw transaction_abort "{'transaction_id':$transaction_id}" &> /dev/null fi else - echo "Not able to set parameter" ubus call usp.raw transaction_abort "{'transaction_id':$transaction_id}" &> /dev/null fi echo $adddel_obj_res