diff --git a/docs/guide/libbbfdm_DeviceInfo_Reboots.md b/docs/guide/libbbfdm_DeviceInfo_Reboots.md index 004ece50d51bd37d8087667a50843cb402004dec..716aebd8406e0ca04f5b92e2907ee82e3367f28f 100644 --- a/docs/guide/libbbfdm_DeviceInfo_Reboots.md +++ b/docs/guide/libbbfdm_DeviceInfo_Reboots.md @@ -4,18 +4,18 @@ In TR-181 version 2.18, a new object, Device.DeviceInfo.Reboots, was introduced Currently, there is no standard configuration mapping to this object. However, we propose introducing a custom config called `sysmngr` to manage this information effectively. -The idea is to maintain a 1-to-1 mapping between the parameters and UCI config. To achieve this, we need to create an `init.d` service script that generates a UCI section each time the start_service() function is called. Essentially, when the start_service() function is executed, it will check the `/tmp/reset_reason` file for specific markers, such as (reset reason) and (reset triggered), to identify the cause of the last boot. And based on these markers, it will calculate the required counter for data model parameters and commit the changes in `sysmngr.deviceinfo` section. Furthermore, if necessary, it will create a UCI reboot section by checking `sysmngr.deviceinfo.max_reboot_entries` and adjusting the config accordingly. +The idea is to maintain a 1-to-1 mapping between the parameters and UCI config. To achieve this, we need to create an `init.d` service script that generates a UCI section each time the start_service() function is called. Essentially, when the start_service() function is executed, it will check the `/tmp/reset_reason` file for specific markers, such as (reset reason) and (reset triggered), to identify the cause of the last boot. And based on these markers, it will calculate the required counter for data model parameters and commit the changes in `sysmngr.reboots` section. Furthermore, if necessary, it will create a UCI reboot section by checking `sysmngr.reboots.max_reboot_entries` and adjusting the config accordingly. This approach ensures that the data model maps directly to UCI config as closely as possible, eliminating the need for any adjustments at the data model layer. ## Parameter Mapping Details -- Device.DeviceInfo.Reboots.BootCount: Maps to sysmngr.deviceinfo.boot_count. This value is determined based on the marker (reset triggered: defaultreset) defined in `/tmp/reset_reason` file. -- Device.DeviceInfo.Reboots.CurrentVersionBootCount: Maps to sysmngr.deviceinfo.curr_version_boot_count. This value is determined based on the marker (reset triggered: upgrade) defined in `/tmp/reset_reason` file. -- Device.DeviceInfo.Reboots.WatchdogBootCount: Maps to sysmngr.deviceinfo.watchdog_boot_count. This value is determined based on the marker (reset reason: WATCHDOG) defined in `/tmp/reset_reason` file. -- Device.DeviceInfo.Reboots.ColdBootCount: Maps to sysmngr.deviceinfo.cold_boot_count. This value is determined based on the marker (reset reason: POR_RESET) defined in `/tmp/reset_reason` file. -- Device.DeviceInfo.Reboots.WarmBootCount: Maps to sysmngr.deviceinfo.warm_boot_count. This value is determined based on the marker (reset reason: POR_RESET) defined in `/tmp/reset_reason` file. -- Device.DeviceInfo.Reboots.MaxRebootEntries: Maps to sysmngr.deviceinfo.max_reboot_entries. Possible values include {-1, 0, etc..}. Each case will be handled internally by bbfdm and default value is 3 and maximum reboot entry supported is 255. +- Device.DeviceInfo.Reboots.BootCount: Maps to sysmngr.reboots.boot_count. This value is determined based on the marker (reset triggered: defaultreset) defined in `/tmp/reset_reason` file. +- Device.DeviceInfo.Reboots.CurrentVersionBootCount: Maps to sysmngr.reboots.curr_version_boot_count. This value is determined based on the marker (reset triggered: upgrade) defined in `/tmp/reset_reason` file. +- Device.DeviceInfo.Reboots.WatchdogBootCount: Maps to sysmngr.reboots.watchdog_boot_count. This value is determined based on the marker (reset reason: WATCHDOG) defined in `/tmp/reset_reason` file. +- Device.DeviceInfo.Reboots.ColdBootCount: Maps to sysmngr.reboots.cold_boot_count. This value is determined based on the marker (reset reason: POR_RESET) defined in `/tmp/reset_reason` file. +- Device.DeviceInfo.Reboots.WarmBootCount: Maps to sysmngr.reboots.warm_boot_count. This value is determined based on the marker (reset reason: POR_RESET) defined in `/tmp/reset_reason` file. +- Device.DeviceInfo.Reboots.MaxRebootEntries: Maps to sysmngr.reboots.max_reboot_entries. Possible values include {-1, 0, etc..}. Each case will be handled internally by bbfdm and default value is 3 and maximum reboot entry supported is 255. - Device.DeviceInfo.Reboots.RebootNumberOfEntries: This is an internal bbfdm mechanism used to count the number of reboot entries. - Device.DeviceInfo.Reboots.RemoveAllReboots(): An internal bbfdm API to remove all reboot sections. - Device.DeviceInfo.Reboots.Reboot.{i}.: Each reboot entry is stored in a 'reboot' section. @@ -34,7 +34,7 @@ Below is an example of the configuration file: ```bash cat /etc/config/sysmngr -config device-info 'deviceinfo' +config reboots 'reboots' option boot_count '2' option curr_version_boot_count '4' option watchdog_boot_count '3' diff --git a/src/fw_images.c b/src/fw_images.c index 4ea4f3edfe91d93df3f1bd1af6b99cdf88213ae8..9b166a6b27b73ab5c0b3c6d4b3057ac2672028a0 100644 --- a/src/fw_images.c +++ b/src/fw_images.c @@ -28,7 +28,7 @@ static void _exec_reboot(const void *arg1, void *arg2) snprintf(config_name, sizeof(config_name), "%s", "sysmngr"); // Set last_reboot_cause to 'RemoteReboot' because the upcoming reboot will be initiated by USP Operate - dmuci_set_value(config_name, "deviceinfo", "last_reboot_cause", "RemoteReboot"); + dmuci_set_value(config_name, "reboots", "last_reboot_cause", "RemoteReboot"); dmuci_commit_package(config_name); sleep(3); @@ -40,7 +40,7 @@ static void _exec_reboot(const void *arg1, void *arg2) BBF_ERR("Reboot call failed!!!"); // Set last_reboot_cause to empty because there is a problem in the system reboot - dmuci_set_value(config_name, "deviceinfo", "last_reboot_cause", ""); + dmuci_set_value(config_name, "reboots", "last_reboot_cause", ""); dmuci_commit_package(config_name); } diff --git a/src/reboots.c b/src/reboots.c index 8aab709523e83b593ad9a2597f03b3452c354ad0..120fd28d977317775458145eb0830bb5c15af84a 100644 --- a/src/reboots.c +++ b/src/reboots.c @@ -29,19 +29,19 @@ static int g_retry_count = 0; static void reset_option_counter(const char *option_name, const char *option_value) { - sysmngr_uci_set("sysmngr", "deviceinfo", option_name, option_value); + sysmngr_uci_set("sysmngr", "reboots", option_name, option_value); } static void increment_option_counter(const char *option_name) { char buf[16] = {0}; - sysmngr_uci_get("sysmngr", "deviceinfo", option_name, "0", buf, sizeof(buf)); + sysmngr_uci_get("sysmngr", "reboots", option_name, "0", buf, sizeof(buf)); int counter = (int)strtol(buf, NULL, 10) + 1; snprintf(buf, sizeof(buf), "%d", counter); - sysmngr_uci_set("sysmngr", "deviceinfo", option_name, buf); + sysmngr_uci_set("sysmngr", "reboots", option_name, buf); } static void get_boot_option_value(const char *option_name, char *buffer, size_t buffer_size) @@ -185,9 +185,9 @@ static void create_reboot_section(const char *trigger, const char *reason) sysmngr_uci_set("sysmngr", sec_name, "cause", "FactoryReset"); } else { char last_reboot_cause[32] = {0}; - sysmngr_uci_get("sysmngr", "deviceinfo", "last_reboot_cause", "LocalReboot", last_reboot_cause, sizeof(last_reboot_cause)); + sysmngr_uci_get("sysmngr", "reboots", "last_reboot_cause", "LocalReboot", last_reboot_cause, sizeof(last_reboot_cause)); sysmngr_uci_set("sysmngr", sec_name, "cause", last_reboot_cause); - sysmngr_uci_set("sysmngr", "deviceinfo", "last_reboot_cause", ""); + sysmngr_uci_set("sysmngr", "reboots", "last_reboot_cause", ""); } sysmngr_uci_set("sysmngr", sec_name, "reason", boot_reason_message(trigger, reason)); @@ -224,7 +224,7 @@ static void sysmngr_register_boot_action(void) increment_option_counter("warm_boot_count"); } - sysmngr_uci_get("sysmngr", "deviceinfo", "max_reboot_entries", "3", max_entries, sizeof(max_entries)); + sysmngr_uci_get("sysmngr", "reboots", "max_reboot_entries", "3", max_entries, sizeof(max_entries)); int max_reboot_entries = (int)strtol(max_entries, NULL, 10); if (max_reboot_entries != 0) { @@ -293,37 +293,37 @@ static int browseDeviceInfoRebootsRebootInst(struct dmctx *dmctx, DMNODE *parent **************************************************************/ static int get_DeviceInfoReboots_BootCount(char *refparam, struct dmctx *ctx, void *data, char *instance, char **value) { - dmuci_get_option_value_string("sysmngr", "deviceinfo", "boot_count", value); + dmuci_get_option_value_string("sysmngr", "reboots", "boot_count", value); return 0; } static int get_DeviceInfoReboots_CurrentVersionBootCount(char *refparam, struct dmctx *ctx, void *data, char *instance, char **value) { - dmuci_get_option_value_string("sysmngr", "deviceinfo", "curr_version_boot_count", value); + dmuci_get_option_value_string("sysmngr", "reboots", "curr_version_boot_count", value); return 0; } static int get_DeviceInfoReboots_WatchdogBootCount(char *refparam, struct dmctx *ctx, void *data, char *instance, char **value) { - dmuci_get_option_value_string("sysmngr", "deviceinfo", "watchdog_boot_count", value); + dmuci_get_option_value_string("sysmngr", "reboots", "watchdog_boot_count", value); return 0; } static int get_DeviceInfoReboots_ColdBootCount(char *refparam, struct dmctx *ctx, void *data, char *instance, char **value) { - dmuci_get_option_value_string("sysmngr", "deviceinfo", "cold_boot_count", value); + dmuci_get_option_value_string("sysmngr", "reboots", "cold_boot_count", value); return 0; } static int get_DeviceInfoReboots_WarmBootCount(char *refparam, struct dmctx *ctx, void *data, char *instance, char **value) { - dmuci_get_option_value_string("sysmngr", "deviceinfo", "warm_boot_count", value); + dmuci_get_option_value_string("sysmngr", "reboots", "warm_boot_count", value); return 0; } static int get_DeviceInfoReboots_MaxRebootEntries(char *refparam, struct dmctx *ctx, void *data, char *instance, char **value) { - *value = dmuci_get_option_value_fallback_def("sysmngr", "deviceinfo", "max_reboot_entries", "3"); + *value = dmuci_get_option_value_fallback_def("sysmngr", "reboots", "max_reboot_entries", "3"); return 0; } @@ -365,7 +365,7 @@ static int set_DeviceInfoReboots_MaxRebootEntries(char *refparam, struct dmctx * } } - dmuci_set_value("sysmngr", "deviceinfo", "max_reboot_entries", value); + dmuci_set_value("sysmngr", "reboots", "max_reboot_entries", value); break; } return 0;