You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@mynewt.apache.org by cc...@apache.org on 2016/06/15 02:27:24 UTC

[02/50] [abbrv] incubator-mynewt-core git commit: bletiny - add "datalen" command.

bletiny - add "datalen" command.


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

Branch: refs/heads/develop
Commit: 4f891353c6a674ab552db419c586392ba7e8e80c
Parents: c312da6
Author: Christopher Collins <cc...@apache.org>
Authored: Tue Jun 7 18:27:47 2016 +0800
Committer: Christopher Collins <cc...@apache.org>
Committed: Tue Jun 14 19:23:33 2016 -0700

----------------------------------------------------------------------
 apps/bletiny/src/bletiny.h |  2 ++
 apps/bletiny/src/cmd.c     | 39 ++++++++++++++++++++++++++++++++++++++-
 apps/bletiny/src/main.c    |  9 +++++++++
 3 files changed, 49 insertions(+), 1 deletion(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/incubator-mynewt-core/blob/4f891353/apps/bletiny/src/bletiny.h
----------------------------------------------------------------------
diff --git a/apps/bletiny/src/bletiny.h b/apps/bletiny/src/bletiny.h
index c5c5921..6ca6d77 100644
--- a/apps/bletiny/src/bletiny.h
+++ b/apps/bletiny/src/bletiny.h
@@ -169,6 +169,8 @@ int bletiny_set_adv_data(struct ble_hs_adv_fields *adv_fields);
 int bletiny_update_conn(uint16_t conn_handle,
                          struct ble_gap_upd_params *params);
 void bletiny_chrup(uint16_t attr_handle);
+int bletiny_datalen(uint16_t conn_handle, uint16_t tx_octets,
+                    uint16_t tx_time);
 int bletiny_l2cap_update(uint16_t conn_handle,
                           struct ble_l2cap_sig_update_params *params);
 int bletiny_sec_start(uint16_t conn_handle);

http://git-wip-us.apache.org/repos/asf/incubator-mynewt-core/blob/4f891353/apps/bletiny/src/cmd.c
----------------------------------------------------------------------
diff --git a/apps/bletiny/src/cmd.c b/apps/bletiny/src/cmd.c
index 178aeca..9a3fe14 100644
--- a/apps/bletiny/src/cmd.c
+++ b/apps/bletiny/src/cmd.c
@@ -454,7 +454,7 @@ cmd_conn(int argc, char **argv)
 }
 
 /*****************************************************************************
- * $connect                                                                  *
+ * $chrup                                                                    *
  *****************************************************************************/
 
 static int
@@ -474,6 +474,42 @@ cmd_chrup(int argc, char **argv)
 }
 
 /*****************************************************************************
+ * $datalen                                                                  *
+ *****************************************************************************/
+
+static int
+cmd_datalen(int argc, char **argv)
+{
+    uint16_t conn_handle;
+    uint16_t tx_octets;
+    uint16_t tx_time;
+    int rc;
+
+    conn_handle = parse_arg_uint16("conn", &rc);
+    if (rc != 0) {
+        return rc;
+    }
+
+    tx_octets = parse_arg_long("octets", &rc);
+    if (rc != 0) {
+        return rc;
+    }
+
+    tx_time = parse_arg_long("time", &rc);
+    if (rc != 0) {
+        return rc;
+    }
+
+    rc = bletiny_datalen(conn_handle, tx_octets, tx_time);
+    if (rc != 0) {
+        console_printf("error setting data length; rc=%d\n", rc);
+        return rc;
+    }
+
+    return 0;
+}
+
+/*****************************************************************************
  * $discover                                                                 *
  *****************************************************************************/
 
@@ -2064,6 +2100,7 @@ static struct cmd_entry cmd_b_entries[] = {
     { "adv",        cmd_adv },
     { "conn",       cmd_conn },
     { "chrup",      cmd_chrup },
+    { "datalen",    cmd_datalen },
     { "disc",       cmd_disc },
     { "find",       cmd_find },
     { "l2cap",      cmd_l2cap },

http://git-wip-us.apache.org/repos/asf/incubator-mynewt-core/blob/4f891353/apps/bletiny/src/main.c
----------------------------------------------------------------------
diff --git a/apps/bletiny/src/main.c b/apps/bletiny/src/main.c
index 6e97f84..4ed9858 100755
--- a/apps/bletiny/src/main.c
+++ b/apps/bletiny/src/main.c
@@ -1371,6 +1371,15 @@ bletiny_chrup(uint16_t attr_handle)
 }
 
 int
+bletiny_datalen(uint16_t conn_handle, uint16_t tx_octets, uint16_t tx_time)
+{
+    int rc;
+
+    rc = ble_hci_util_set_data_len(conn_handle, tx_octets, tx_time);
+    return rc;
+}
+
+int
 bletiny_l2cap_update(uint16_t conn_handle,
                      struct ble_l2cap_sig_update_params *params)
 {