device_type = get_cfg_value(DEVICE_CONFIG_VALUE_KEY__TYPE);
}
else {
- log_error("Could not read device config\n");
+ log_error("Could not read device configuration.\n");
}
}
section = uci_lookup_section(uci_handle->_ctx, uci_handle->_pkg, DEVICE_CONFIG__SECTION_NAME);
if (section != NULL) {
option = uci_lookup_option(uci_handle->_ctx, section, key.c_str());
- switch (option->type) {
- case UCI_TYPE_STRING:
- log_info("key: %s option name: %s, value: %s\n", key.c_str(), option->e.name, option->v.string);
- ret_val = option->v.string;
- break;
- default:
- log_error("key: %s Failed to read parameter value\n", key.c_str());
- break;
+ if (option != NULL) {
+ switch (option->type) {
+ case UCI_TYPE_STRING:
+ log_info("key: %s option name: %s, value: %s\n", key.c_str(), option->e.name, option->v.string);
+ ret_val = option->v.string;
+ break;
+ default:
+ log_error("key: %s Failed to read parameter value\n", key.c_str());
+ break;
+ }
+ }
+ else {
+ log_error("key: %s Failed to read parameter value\n", key.c_str());
}
}
}
if (access(cfg_fl.c_str(), R_OK) == 0) {
ctx = uci_alloc_context();
if (ctx != NULL) {
- log_debug("uci_set_confdir: %s\n", cfg_dir.c_str());
+ //log_debug("uci_set_confdir: %s\n", cfg_dir.c_str());
uci_set_confdir(ctx, cfg_dir.c_str());
err_flg = uci_load(ctx, cfg_fl.c_str(), &pkg);
if (err_flg == UCI_OK) {
- log_debug("Loaded device configuration: %s\n.", cfg_fl.c_str());
+ //log_debug("Loaded device configuration: %s.\n", cfg_fl.c_str());
ret_val = new ConfigHandle(ctx, pkg);
}
else {
- log_debug("Failed to load device configuration: %s, err code: %d\n.", cfg_fl.c_str(), UCI_OK);
+ log_debug("Failed to load device configuration: %s, err code: %d.\n", cfg_fl.c_str(), UCI_OK);
set_cfg_value(DEVICE_CONFIG_VALUE_KEY__TYPE, "");
uci_free_context(ctx);
}