This is an automated email from the ASF dual-hosted git repository.

rymek pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/mynewt-nimble.git


The following commit(s) were added to refs/heads/master by this push:
     new 4cfe326  btshell: Add information to ongoing test-tx and test-tx stop
4cfe326 is described below

commit 4cfe3260ba3c4fbfbea9d0ec61ff76a0edc75bf4
Author: Ɓukasz Rymanowski <lukasz.rymanow...@codecoup.pl>
AuthorDate: Thu Jan 31 12:47:06 2019 +0100

    btshell: Add information to ongoing test-tx and test-tx stop
---
 apps/btshell/src/btshell.h |  1 +
 apps/btshell/src/cmd.c     | 13 +++++++++++++
 apps/btshell/src/main.c    | 13 +++++++++++++
 3 files changed, 27 insertions(+)

diff --git a/apps/btshell/src/btshell.h b/apps/btshell/src/btshell.h
index 088a899..9def8f5 100644
--- a/apps/btshell/src/btshell.h
+++ b/apps/btshell/src/btshell.h
@@ -164,6 +164,7 @@ int btshell_sec_restart(uint16_t conn_handle, uint8_t *ltk, 
uint16_t ediv,
                         uint64_t rand_val, int auth);
 int btshell_tx_start(uint16_t conn_handle, uint16_t len, uint16_t rate,
                      uint16_t num);
+void btshell_tx_stop(void);
 int btshell_rssi(uint16_t conn_handle, int8_t *out_rssi);
 int btshell_l2cap_create_srv(uint16_t psm, int accept_response);
 int btshell_l2cap_connect(uint16_t conn, uint16_t psm);
diff --git a/apps/btshell/src/cmd.c b/apps/btshell/src/cmd.c
index b9baac1..66f94fc 100644
--- a/apps/btshell/src/cmd.c
+++ b/apps/btshell/src/cmd.c
@@ -2957,12 +2957,24 @@ cmd_test_tx(int argc, char **argv)
     uint16_t len;
     uint16_t rate;
     uint16_t num;
+    uint8_t stop;
 
     rc = parse_arg_all(argc - 1, argv + 1);
     if (rc != 0) {
         return rc;
     }
 
+    stop = parse_arg_uint8_dflt("stop", 0, &rc);
+    if (rc != 0) {
+        console_printf("invalid 'stop' parameter\n");
+        return rc;
+    }
+
+    if (stop) {
+        btshell_tx_stop();
+        return 0;
+    }
+
     conn = parse_arg_uint16("conn", &rc);
     if (rc != 0) {
         console_printf("invalid 'conn' parameter\n");
@@ -3000,6 +3012,7 @@ static const struct shell_param test_tx_params[] = {
     {"length", "size of packet, usage: =<UINT16>"},
     {"rate", "rate of tx, usage: =<UINT16>, default=1"},
     {"num", "number of packets, usage: =<UINT16>, default=1"},
+    {"stop", "stop sending, usage: 1 to stop, default 0"},
     {NULL, NULL}
 };
 
diff --git a/apps/btshell/src/main.c b/apps/btshell/src/main.c
index 9417cef..ee48680 100644
--- a/apps/btshell/src/main.c
+++ b/apps/btshell/src/main.c
@@ -110,6 +110,7 @@ static struct os_callout btshell_tx_timer;
 struct btshell_tx_data_s
 {
     uint16_t tx_num;
+    uint16_t tx_num_requested;
     uint16_t tx_rate;
     uint16_t tx_conn_handle;
     uint16_t tx_len;
@@ -1240,6 +1241,10 @@ btshell_tx_timer_cb(struct os_event *ev)
         return;
     }
 
+    console_printf("Sending %d/%d len: %d\n",
+                       btshell_tx_data.tx_num_requested - 
btshell_tx_data.tx_num + 1,
+                       btshell_tx_data.tx_num_requested, 
btshell_tx_data.tx_len);
+
     len = btshell_tx_data.tx_len;
 
     om = NULL;
@@ -1827,6 +1832,7 @@ btshell_tx_start(uint16_t conn_handle, uint16_t len, 
uint16_t rate, uint16_t num
     }
 
     btshell_tx_data.tx_num = num;
+    btshell_tx_data.tx_num_requested = num;
     btshell_tx_data.tx_rate = rate;
     btshell_tx_data.tx_len = len;
     btshell_tx_data.tx_conn_handle = conn_handle;
@@ -1846,6 +1852,13 @@ btshell_tx_start(uint16_t conn_handle, uint16_t len, 
uint16_t rate, uint16_t num
     return 0;
 }
 
+void
+btshell_tx_stop(void)
+{
+    os_callout_stop(&btshell_tx_timer);
+    btshell_tx_data.tx_num = 0;
+}
+
 int
 btshell_rssi(uint16_t conn_handle, int8_t *out_rssi)
 {

Reply via email to