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 19:36:57 UTC

[1/2] incubator-mynewt-core git commit: slinky; add export routine for the sample config.

Repository: incubator-mynewt-core
Updated Branches:
  refs/heads/develop 35b4f2339 -> 46849c552


slinky; add export routine for the sample 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/15400dbd
Tree: http://git-wip-us.apache.org/repos/asf/incubator-mynewt-core/tree/15400dbd
Diff: http://git-wip-us.apache.org/repos/asf/incubator-mynewt-core/diff/15400dbd

Branch: refs/heads/develop
Commit: 15400dbdb87415f68758732cd2e11696f7f3f18b
Parents: 35b4f23
Author: Marko Kiiskila <ma...@runtime.io>
Authored: Fri Apr 8 10:34:17 2016 -0700
Committer: Marko Kiiskila <ma...@runtime.io>
Committed: Fri Apr 8 10:34:17 2016 -0700

----------------------------------------------------------------------
 apps/slinky/src/main.c | 17 ++++++++++++++++-
 1 file changed, 16 insertions(+), 1 deletion(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/incubator-mynewt-core/blob/15400dbd/apps/slinky/src/main.c
----------------------------------------------------------------------
diff --git a/apps/slinky/src/main.c b/apps/slinky/src/main.c
index edaad80..4f7053f 100755
--- a/apps/slinky/src/main.c
+++ b/apps/slinky/src/main.c
@@ -88,12 +88,15 @@ struct os_mempool default_mbuf_mpool;
 static char *test_conf_get(int argc, char **argv, char *val, int max_len);
 static int test_conf_set(int argc, char **argv, char *val);
 static int test_conf_commit(void);
+static int test_conf_export(void (*export_func)(struct conf_handler *ch,
+        char *name, char *val));
 
 static struct conf_handler test_conf_handler = {
     .ch_name = "test",
     .ch_get = test_conf_get,
     .ch_set = test_conf_set,
-    .ch_commit = test_conf_commit
+    .ch_commit = test_conf_commit,
+    .ch_export = test_conf_export
 };
 
 static uint8_t test8;
@@ -134,6 +137,18 @@ test_conf_commit(void)
     return 0;
 }
 
+static int
+test_conf_export(void (*func)(struct conf_handler *ch,
+        char *name, char *val))
+{
+    char buf[4];
+
+    conf_str_from_value(CONF_INT8, &test8, buf, sizeof(buf));
+    func(&test_conf_handler, "8", buf);
+    func(&test_conf_handler, "str", test_str);
+    return 0;
+}
+
 void
 task1_handler(void *arg)
 {


[2/2] incubator-mynewt-core git commit: config; add CLI command to dump current running config.

Posted by ma...@apache.org.
config; add CLI command to dump current running 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/46849c55
Tree: http://git-wip-us.apache.org/repos/asf/incubator-mynewt-core/tree/46849c55
Diff: http://git-wip-us.apache.org/repos/asf/incubator-mynewt-core/diff/46849c55

Branch: refs/heads/develop
Commit: 46849c552bb1b2687c3c47f8efa0c39af23c3ed9
Parents: 15400db
Author: Marko Kiiskila <ma...@runtime.io>
Authored: Fri Apr 8 10:36:26 2016 -0700
Committer: Marko Kiiskila <ma...@runtime.io>
Committed: Fri Apr 8 10:36:26 2016 -0700

----------------------------------------------------------------------
 sys/config/src/config_cli.c | 24 ++++++++++++++++++++++++
 1 file changed, 24 insertions(+)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/incubator-mynewt-core/blob/46849c55/sys/config/src/config_cli.c
----------------------------------------------------------------------
diff --git a/sys/config/src/config_cli.c b/sys/config/src/config_cli.c
index 2090652..72fd801 100644
--- a/sys/config/src/config_cli.c
+++ b/sys/config/src/config_cli.c
@@ -35,6 +35,24 @@ static struct shell_cmd shell_conf_cmd = {
     .sc_cmd_func = shell_conf_command
 };
 
+static void
+conf_dump_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)
+{
+    struct conf_handler *ch;
+
+    SLIST_FOREACH(ch, &conf_handlers, ch_list) {
+        if (ch->ch_export) {
+            ch->ch_export(conf_dump_one);
+        }
+    }
+}
+
 static int
 shell_conf_command(int argc, char **argv)
 {
@@ -65,6 +83,12 @@ shell_conf_command(int argc, char **argv)
         console_printf("%s", val);
         return 0;
     }
+    if (!strcmp(name, "dump")) {
+        if (!val || !strcmp(val, "running")) {
+            conf_dump();
+        }
+        return 0;
+    }
     if (!val) {
         val = conf_get_value(name, tmp_buf, sizeof(tmp_buf));
         if (!val) {