diff --git a/bbf_plugin/datamodel.c b/bbf_plugin/datamodel.c index d983330..4a7560d 100644 --- a/bbf_plugin/datamodel.c +++ b/bbf_plugin/datamodel.c @@ -445,7 +445,12 @@ static int set_management_server_delay_reboot(char *refparam, struct dmctx *ctx, /*#Device.ManagementServer.ParameterKey!UCI:cwmp/acs,acs/ParameterKey*/ static int get_management_server_key(char *refparam, struct dmctx *ctx, void *data, char *instance, char **value) { + char buf[1024] = {0}; + dmuci_get_option_value_string("cwmp", "cpe", "ParameterKey", value); + convert_hex_to_string(*value, buf, sizeof(buf)); + *value = dmstrdup(buf); + return 0; } diff --git a/src/common.c b/src/common.c index 9e00532..753ba0d 100755 --- a/src/common.c +++ b/src/common.c @@ -363,9 +363,24 @@ size_t write_data(void *ptr, size_t size, size_t nmemb, FILE *stream) return written; } +void convert_string_to_hex(const char *str, char *hex, size_t size) +{ + int i, len = CWMP_STRLEN(str); + unsigned pos = 0; + + for (i = 0; i < len && pos < size - 2; i++) { + pos += snprintf((char *)hex + pos, size - pos, "%02X", str[i]); + } + + hex[pos] = '\0'; +} + void set_rpc_parameter_key(char *param_key) { - set_uci_path_value(NULL, "cwmp.cpe.ParameterKey", param_key ? param_key : ""); + char buf[1024] = {0}; + + convert_string_to_hex(param_key, buf, sizeof(buf)); + set_uci_path_value(NULL, "cwmp.cpe.ParameterKey", buf); } /*