X-Git-Url: http://pilppa.org/gitweb/?a=blobdiff_plain;f=src%2FDeviceConfig.cc;h=66fe863be28c17766269f3203c88807d46ade757;hb=65f22bbea2531f7cd492d6108b8902f92b7750a8;hp=c3e8bad047e2a915f18b493fadd46d6b40f0254e;hpb=d6c14157bb43b7c356dd4042987a31f28c6e99ad;p=libplp.git diff --git a/src/DeviceConfig.cc b/src/DeviceConfig.cc index c3e8bad..66fe863 100644 --- a/src/DeviceConfig.cc +++ b/src/DeviceConfig.cc @@ -18,7 +18,8 @@ using namespace std; using namespace plp; -string DeviceConfig::store_base_dir = DEFAULT_STORAGE_BASE_DIR; +string DeviceConfig::store_base_dir = DEFAULT_STORAGE_BASE_DIR; +long DeviceConfig::read_interval_seconds = 600; ConfigHandle::ConfigHandle(uci_context *ctx_param, uci_package *pkg_param, @@ -202,6 +203,14 @@ void DeviceConfig::set_base_dir_name(string store_param) { } } +long DeviceConfig::get_read_interval_seconds() { + return read_interval_seconds; +} + +void DeviceConfig::set_read_interval_seconds(long seconds_param) { + read_interval_seconds = seconds_param; +} + string DeviceConfig::get_base_dir_name() { return store_base_dir; } @@ -287,6 +296,8 @@ ConfigHandle *DeviceConfig::load_device_config(string device_id_param) { struct uci_package *pkg; string cfg_fl; string cfg_dir; + int b_count; + char *fname; ConfigHandle *ret_val; ret_val = NULL; @@ -299,14 +310,11 @@ ConfigHandle *DeviceConfig::load_device_config(string device_id_param) { 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("confdir: %s, file: %s\n", cfg_dir.c_str(), cfg_fl.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()); - int b_count; - char *fname; - b_count = strlen(cfg_dir.c_str()) + strlen(cfg_fl.c_str()) + 10; fname = (char *)calloc(1, b_count); if (fname != NULL) { @@ -325,20 +333,20 @@ ConfigHandle *DeviceConfig::load_device_config(string device_id_param) { } } else { - log_error("Failed to load device device configuration, memory allocation error.\n"); + log_error("Failed to load device configuration, memory allocation error.\n"); set_config_value(DEVICE_CONFIG_VALUE_KEY__TYPE, ""); } } else { - log_error("Failed to load device device configuration, file does not exist: %s.\n", cfg_fl.c_str()); + log_error("Failed to load device configuration, file does not exist: %s.\n", cfg_fl.c_str()); } } return ret_val; } -DeviceConfig *DeviceConfig::get_device_config(string device_id) { +DeviceConfig *DeviceConfig::get_device_config(string device_id_param) { DeviceConfig *ret_val; - ret_val = new DeviceConfig(device_id); + ret_val = new DeviceConfig(device_id_param); return ret_val; }