You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@mynewt.apache.org by an...@apache.org on 2017/04/07 08:49:34 UTC

[5/6] incubator-mynewt-core git commit: bletiny: Add support to modify privacy mode

bletiny: Add support to modify privacy mode


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/10fdd0b6
Tree: http://git-wip-us.apache.org/repos/asf/incubator-mynewt-core/tree/10fdd0b6
Diff: http://git-wip-us.apache.org/repos/asf/incubator-mynewt-core/diff/10fdd0b6

Branch: refs/heads/bluetooth5
Commit: 10fdd0b6fdb09d3f08c634c53efaf2982be10e04
Parents: 674af93
Author: \u0141ukasz Rymanowski <lu...@codecoup.pl>
Authored: Wed Apr 5 15:45:06 2017 +0200
Committer: \u0141ukasz Rymanowski <lu...@codecoup.pl>
Committed: Thu Apr 6 09:46:45 2017 +0200

----------------------------------------------------------------------
 apps/bletiny/src/cmd.c | 46 +++++++++++++++++++++++++++++++++++++++++++++
 1 file changed, 46 insertions(+)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/incubator-mynewt-core/blob/10fdd0b6/apps/bletiny/src/cmd.c
----------------------------------------------------------------------
diff --git a/apps/bletiny/src/cmd.c b/apps/bletiny/src/cmd.c
index 15563a0..19580c7 100644
--- a/apps/bletiny/src/cmd.c
+++ b/apps/bletiny/src/cmd.c
@@ -2464,6 +2464,46 @@ static struct kv_pair cmd_set_addr_types[] = {
 };
 
 static void
+bletiny_set_priv_mode_help(void)
+{
+    console_printf("Available set priv_mode params: \n");
+    help_cmd_kv_dflt("addr_type", cmd_set_addr_types, BLE_ADDR_PUBLIC);
+    help_cmd_byte_stream_exact_length("addr", 6);
+    help_cmd_uint8("mode");
+}
+
+static int
+cmd_set_priv_mode(void)
+{
+    ble_addr_t addr;
+    uint8_t priv_mode;
+    int rc;
+
+    addr.type = parse_arg_kv_default("addr_type", cmd_set_addr_types,
+                                     BLE_ADDR_PUBLIC, &rc);
+    if (rc != 0) {
+        console_printf("invalid 'addr_type' parameter\n");
+        help_cmd_kv_dflt("addr_type", cmd_set_addr_types, BLE_ADDR_PUBLIC);
+        return rc;
+    }
+
+    rc = parse_arg_mac("addr", addr.val);
+    if (rc != 0) {
+        console_printf("invalid 'addr' parameter\n");
+        help_cmd_byte_stream_exact_length("addr", 6);
+        return rc;
+    }
+
+    priv_mode = parse_arg_uint8("mode", &rc);
+    if (rc != 0) {
+        console_printf("missing mode\n");
+        return rc;
+    }
+
+    return ble_gap_set_priv_mode(&addr, priv_mode);
+}
+
+static void
 bletiny_set_addr_help(void)
 {
     console_printf("Available set addr params: \n");
@@ -2544,6 +2584,7 @@ cmd_set(int argc, char **argv)
         bletiny_set_adv_data_help();
         bletiny_set_sm_data_help();
         bletiny_set_addr_help();
+        bletiny_set_priv_mode_help();
         return 0;
     }
 
@@ -2557,6 +2598,11 @@ cmd_set(int argc, char **argv)
         return rc;
     }
 
+    if (argc > 1 && strcmp(argv[1], "priv_mode") == 0) {
+        rc = cmd_set_priv_mode();
+        return rc;
+    }
+
     good = 0;
 
     rc = parse_arg_find_idx("addr");