You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@mynewt.apache.org by ma...@apache.org on 2016/04/08 23:27:05 UTC

incubator-mynewt-core git commit: config; add cli commands to dump running and saved config.

Repository: incubator-mynewt-core
Updated Branches:
  refs/heads/develop 0030fa241 -> 03679c9ea


config; add cli commands to dump running and saved config.


Project: http://git-wip-us.apache.org/repos/asf/incubator-mynewt-core/repo
Commit: http://git-wip-us.apache.org/repos/asf/incubator-mynewt-core/commit/03679c9e
Tree: http://git-wip-us.apache.org/repos/asf/incubator-mynewt-core/tree/03679c9e
Diff: http://git-wip-us.apache.org/repos/asf/incubator-mynewt-core/diff/03679c9e

Branch: refs/heads/develop
Commit: 03679c9ea169223611a39834db7a8da9502fbde4
Parents: 0030fa2
Author: Marko Kiiskila <ma...@runtime.io>
Authored: Fri Apr 8 14:26:35 2016 -0700
Committer: Marko Kiiskila <ma...@runtime.io>
Committed: Fri Apr 8 14:26:35 2016 -0700

----------------------------------------------------------------------
 sys/config/src/config_cli.c | 33 +++++++++++++++++++++++++++------
 1 file changed, 27 insertions(+), 6 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/incubator-mynewt-core/blob/03679c9e/sys/config/src/config_cli.c
----------------------------------------------------------------------
diff --git a/sys/config/src/config_cli.c b/sys/config/src/config_cli.c
index 72fd801..ff81611 100644
--- a/sys/config/src/config_cli.c
+++ b/sys/config/src/config_cli.c
@@ -36,23 +36,39 @@ static struct shell_cmd shell_conf_cmd = {
 };
 
 static void
-conf_dump_one(struct conf_handler *ch, char *name, char *val)
+conf_running_one(struct conf_handler *ch, char *name, char *val)
 {
     console_printf("%s/%s = %s\n", ch->ch_name, name, val ? val : "<del>");
 }
 
 static void
-conf_dump(void)
+conf_dump_running(void)
 {
     struct conf_handler *ch;
 
     SLIST_FOREACH(ch, &conf_handlers, ch_list) {
         if (ch->ch_export) {
-            ch->ch_export(conf_dump_one);
+            ch->ch_export(conf_running_one);
         }
     }
 }
 
+static void
+conf_saved_one(char *name, char *val, void *cb_arg)
+{
+    console_printf("%s = %s\n", name, val ? val : "<del>");
+}
+
+static void
+conf_dump_saved(void)
+{
+    struct conf_store *cs;
+
+    SLIST_FOREACH(cs, &conf_load_srcs, cs_next) {
+        cs->cs_itf->csi_load(cs, conf_saved_one, NULL);
+    }
+}
+
 static int
 shell_conf_command(int argc, char **argv)
 {
@@ -82,12 +98,17 @@ shell_conf_command(int argc, char **argv)
         }
         console_printf("%s", val);
         return 0;
-    }
-    if (!strcmp(name, "dump")) {
+    } else if (!strcmp(name, "dump")) {
         if (!val || !strcmp(val, "running")) {
-            conf_dump();
+            conf_dump_running();
+        }
+        if (val && !strcmp(val, "saved")) {
+            conf_dump_saved();
         }
         return 0;
+    } else if (!strcmp(name, "save")) {
+        conf_save();
+        return 0;
     }
     if (!val) {
         val = conf_get_value(name, tmp_buf, sizeof(tmp_buf));