You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@mynewt.apache.org by GitBox <gi...@apache.org> on 2017/12/20 08:26:25 UTC

[GitHub] sjanc closed pull request #707: Fixes for btshell

sjanc closed pull request #707: Fixes for btshell
URL: https://github.com/apache/mynewt-core/pull/707
 
 
   

This is a PR merged from a forked repository.
As GitHub hides the original diff on merge, it is displayed below for
the sake of provenance:

As this is a foreign pull request (from a fork), the diff is supplied
below (as it won't show otherwise due to GitHub magic):

diff --git a/apps/btshell/src/cmd.c b/apps/btshell/src/cmd.c
index f50a26393..c638c516b 100644
--- a/apps/btshell/src/cmd.c
+++ b/apps/btshell/src/cmd.c
@@ -456,7 +456,7 @@ static const struct shell_param advertise_configure_params[] = {
     {"interval_min", "usage: =[0-UINT32_MAX], default: 0"},
     {"interval_max", "usage: =[0-UINT32_MAX], default: 0"},
     {"tx_power", "usage: =[-127-127], default: 127"},
-    {"primary_phy", "usage: =[1M|2M|coded], default: 1M"},
+    {"primary_phy", "usage: =[1M|coded], default: 1M"},
     {"secondary_phy", "usage: =[1M|2M|coded], default: primary_phy"},
     {"sid", "usage: =[0-UINT8_MAX], default: 0"},
     {"high_duty", "usage: =[0-1], default: 0"},
@@ -1022,6 +1022,52 @@ cmd_disconnect(int argc, char **argv)
     return 0;
 }
 
+static int
+cmd_show_conn(int argc, char **argv)
+{
+    struct ble_gap_conn_desc conn_desc;
+    struct btshell_conn *conn;
+    int rc;
+    int i;
+
+    for (i = 0; i < btshell_num_conns; i++) {
+        conn = btshell_conns + i;
+
+        rc = ble_gap_conn_find(conn->handle, &conn_desc);
+        if (rc == 0) {
+            print_conn_desc(&conn_desc);
+        }
+    }
+
+    return 0;
+}
+
+static int
+cmd_show_addr(int argc, char **argv)
+{
+    uint8_t id_addr[6];
+    int rc;
+
+    console_printf("public_id_addr=");
+    rc = ble_hs_id_copy_addr(BLE_ADDR_PUBLIC, id_addr, NULL);
+    if (rc == 0) {
+        print_addr(id_addr);
+    } else {
+        console_printf("none");
+    }
+
+    console_printf(" random_id_addr=");
+    rc = ble_hs_id_copy_addr(BLE_ADDR_RANDOM, id_addr, NULL);
+    if (rc == 0) {
+        print_addr(id_addr);
+    } else {
+        console_printf("none");
+    }
+    console_printf("\n");
+
+    return 0;
+}
+
 #if MYNEWT_VAL(SHELL_CMD_HELP)
 static const struct shell_param disconnect_params[] = {
     {"conn", "connection handle parameter, usage: =<UINT16>"},
@@ -1218,7 +1264,7 @@ static const struct shell_param scan_params[] = {
     {"interval", "usage: =[0-UINT16_MAX], default: 0"},
     {"window", "usage: =[0-UINT16_MAX], default: 0"},
     {"filter", "usage: =[no_wl|use_wl|no_wl_inita|use_wl_inita], default: no_wl"},
-    {"nodups", "usage: =[0-UINT16_MAX], default: 0"},
+    {"nodups", "usage: =[0-1], default: 0"},
     {"own_addr_type", "usage: =[public|random|rpa_pub|rpa_rnd], default: public"},
     {"extended_duration", "usage: =[0-UINT16_MAX], default: 0"},
     {"extended_period", "usage: =[0-UINT16_MAX], default: 0"},
@@ -3045,7 +3091,7 @@ static const struct shell_param gatt_read_params[] = {
     {"conn", "connection handle, usage: =<UINT16>"},
     {"long", "is read long, usage: =[0-1], default=0"},
     {"attr", "attribute handle, usage: =<UINT16>"},
-    {"offset", "attribute handle, usage: =<UINT16>"},
+    {"offset", "offset value, usage: =<UINT16>"},
     {"uuid", "read by uuid, usage: =[UUID]"},
     {"start", "start handle, usage: =<UINT16>"},
     {"end", "end handle, usage: =<UINT16>"},
@@ -3309,6 +3355,20 @@ static const struct shell_cmd btshell_commands[] = {
         .sc_cmd_func = cmd_disconnect,
 #if MYNEWT_VAL(SHELL_CMD_HELP)
         .help = &disconnect_help,
+#endif
+    },
+    {
+        .sc_cmd = "show-addr",
+        .sc_cmd_func = cmd_show_addr,
+#if MYNEWT_VAL(SHELL_CMD_HELP)
+        .help = &gatt_show_addr_help,
+#endif
+    },
+    {
+        .sc_cmd = "show-conn",
+        .sc_cmd_func = cmd_show_conn,
+#if MYNEWT_VAL(SHELL_CMD_HELP)
+        .help = &gatt_show_conn_help,
 #endif
     },
     {
@@ -3458,27 +3518,6 @@ static const struct shell_cmd btshell_commands[] = {
         .sc_cmd_func = cmd_gatt_show_local,
 #if MYNEWT_VAL(SHELL_CMD_HELP)
         .help = &gatt_show_local_help,
-#endif
-    },
-    {
-        .sc_cmd = "gatt-show-addr",
-        .sc_cmd_func = cmd_gatt_show_addr,
-#if MYNEWT_VAL(SHELL_CMD_HELP)
-        .help = &gatt_show_addr_help,
-#endif
-    },
-    {
-        .sc_cmd = "gatt-show-conn",
-        .sc_cmd_func = cmd_gatt_show_conn,
-#if MYNEWT_VAL(SHELL_CMD_HELP)
-        .help = &gatt_show_conn_help,
-#endif
-    },
-    {
-        .sc_cmd = "gatt-show-coc",
-        .sc_cmd_func = cmd_gatt_show_coc,
-#if MYNEWT_VAL(SHELL_CMD_HELP)
-        .help = &gatt_show_coc_help,
 #endif
     },
     {
@@ -3522,6 +3561,13 @@ static const struct shell_cmd btshell_commands[] = {
         .sc_cmd_func = cmd_l2cap_send,
 #if MYNEWT_VAL(SHELL_CMD_HELP)
         .help = &l2cap_send_help,
+#endif
+    },
+    {
+        .sc_cmd = "l2cap-show-coc",
+        .sc_cmd_func = cmd_l2cap_show_coc,
+#if MYNEWT_VAL(SHELL_CMD_HELP)
+        .help = &gatt_show_coc_help,
 #endif
     },
 #endif
diff --git a/apps/btshell/src/cmd_gatt.c b/apps/btshell/src/cmd_gatt.c
index 707b77584..ba3799e56 100644
--- a/apps/btshell/src/cmd_gatt.c
+++ b/apps/btshell/src/cmd_gatt.c
@@ -462,76 +462,6 @@ cmd_gatt_show_local(int argc, char **argv)
     return 0;
 }
 
-int
-cmd_gatt_show_addr(int argc, char **argv)
-{
-    uint8_t id_addr[6];
-    int rc;
-
-    console_printf("public_id_addr=");
-    rc = ble_hs_id_copy_addr(BLE_ADDR_PUBLIC, id_addr, NULL);
-    if (rc == 0) {
-        print_addr(id_addr);
-    } else {
-        console_printf("none");
-    }
-
-    console_printf(" random_id_addr=");
-    rc = ble_hs_id_copy_addr(BLE_ADDR_RANDOM, id_addr, NULL);
-    if (rc == 0) {
-        print_addr(id_addr);
-    } else {
-        console_printf("none");
-    }
-    console_printf("\n");
-
-    return 0;
-}
-
-int
-cmd_gatt_show_conn(int argc, char **argv)
-{
-    struct ble_gap_conn_desc conn_desc;
-    struct btshell_conn *conn;
-    int rc;
-    int i;
-
-    for (i = 0; i < btshell_num_conns; i++) {
-        conn = btshell_conns + i;
-
-        rc = ble_gap_conn_find(conn->handle, &conn_desc);
-        if (rc == 0) {
-            print_conn_desc(&conn_desc);
-        }
-    }
-
-    return 0;
-}
-
-int
-cmd_gatt_show_coc(int argc, char **argv)
-{
-    struct btshell_conn *conn = NULL;
-    struct btshell_l2cap_coc *coc;
-    int i, j;
-
-    for (i = 0; i < btshell_num_conns; i++) {
-        conn = btshell_conns + i;
-
-        if (SLIST_EMPTY(&conn->coc_list)) {
-            continue;
-        }
-
-        console_printf("conn_handle: 0x%04x\n", conn->handle);
-        j = 0;
-        SLIST_FOREACH(coc, &conn->coc_list, next) {
-            console_printf("    idx: %i, chan pointer = %p\n", j++, coc->chan);
-        }
-    }
-
-    return 0;
-}
-
 /*****************************************************************************
  * $gatt-write                                                               *
  *****************************************************************************/
diff --git a/apps/btshell/src/cmd_gatt.h b/apps/btshell/src/cmd_gatt.h
index 1fa8c6f63..70536d03c 100644
--- a/apps/btshell/src/cmd_gatt.h
+++ b/apps/btshell/src/cmd_gatt.h
@@ -34,9 +34,6 @@ int cmd_gatt_service_changed(int argc, char **argv);
 int cmd_gatt_service_visibility(int argc, char **argv);
 int cmd_gatt_show(int argc, char **argv);
 int cmd_gatt_show_local(int argc, char **argv);
-int cmd_gatt_show_addr(int argc, char **argv);
-int cmd_gatt_show_conn(int argc, char **argv);
-int cmd_gatt_show_coc(int argc, char **argv);
 int cmd_gatt_write(int argc, char **argv);
 
 #endif
diff --git a/apps/btshell/src/cmd_l2cap.c b/apps/btshell/src/cmd_l2cap.c
index b04c89650..68237f22f 100644
--- a/apps/btshell/src/cmd_l2cap.c
+++ b/apps/btshell/src/cmd_l2cap.c
@@ -215,3 +215,27 @@ cmd_l2cap_send(int argc, char **argv)
 
     return btshell_l2cap_send(conn, idx, bytes);
 }
+
+int
+cmd_l2cap_show_coc(int argc, char **argv)
+{
+    struct btshell_conn *conn = NULL;
+    struct btshell_l2cap_coc *coc;
+    int i, j;
+
+    for (i = 0; i < btshell_num_conns; i++) {
+        conn = btshell_conns + i;
+
+        if (SLIST_EMPTY(&conn->coc_list)) {
+            continue;
+        }
+
+        console_printf("conn_handle: 0x%04x\n", conn->handle);
+        j = 0;
+        SLIST_FOREACH(coc, &conn->coc_list, next) {
+            console_printf("    idx: %i, chan pointer = %p\n", j++, coc->chan);
+        }
+    }
+
+    return 0;
+}
diff --git a/apps/btshell/src/cmd_l2cap.h b/apps/btshell/src/cmd_l2cap.h
index fccefd197..164b02dc8 100644
--- a/apps/btshell/src/cmd_l2cap.h
+++ b/apps/btshell/src/cmd_l2cap.h
@@ -27,5 +27,6 @@ int cmd_l2cap_create_server(int argc, char **argv);
 int cmd_l2cap_connect(int argc, char **argv);
 int cmd_l2cap_disconnect(int argc, char **argv);
 int cmd_l2cap_send(int argc, char **argv);
+int cmd_l2cap_show_coc(int argc, char **argv);
 
 #endif


 

----------------------------------------------------------------
This is an automated message from the Apache Git Service.
To respond to the message, please log on GitHub and use the
URL above to go to the specific comment.
 
For queries about this service, please contact Infrastructure at:
users@infra.apache.org


With regards,
Apache Git Services