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/07/13 20:56:01 UTC

[48/50] [abbrv] incubator-mynewt-core git commit: BLE Host - combine adv enable/disable tx commands.

BLE Host - combine adv enable/disable tx commands.

There is no need for separate functions for the same HCI command.  Also,
the function that was removed allocated an overly large buffer.


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

Branch: refs/heads/develop
Commit: bcdaa4731133d0881f522f7bf79bc4f7f136a9a1
Parents: ed21cfa
Author: Christopher Collins <cc...@apache.org>
Authored: Wed Jul 13 12:16:45 2016 -0700
Committer: Christopher Collins <cc...@apache.org>
Committed: Wed Jul 13 12:16:45 2016 -0700

----------------------------------------------------------------------
 net/nimble/host/src/ble_gap.c | 28 ++++++----------------------
 1 file changed, 6 insertions(+), 22 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/incubator-mynewt-core/blob/bcdaa473/net/nimble/host/src/ble_gap.c
----------------------------------------------------------------------
diff --git a/net/nimble/host/src/ble_gap.c b/net/nimble/host/src/ble_gap.c
index bd85cf3..941c350 100644
--- a/net/nimble/host/src/ble_gap.c
+++ b/net/nimble/host/src/ble_gap.c
@@ -141,7 +141,7 @@ static bssnz_t struct {
 } ble_gap_slave;
 
 static int ble_gap_disc_disable_tx(void);
-static int ble_gap_adv_disable_tx(void);
+static int ble_gap_adv_enable_tx(int enable);
 static int ble_gap_conn_cancel_tx(void);
 
 struct ble_gap_snapshot {
@@ -1114,7 +1114,7 @@ ble_gap_slave_heartbeat(void)
     /*** Timer expired; process event. */
 
     /* Stop advertising. */
-    rc = ble_gap_adv_disable_tx();
+    rc = ble_gap_adv_enable_tx(0);
     if (rc != 0) {
         /* Failed to stop advertising; try again in 100 ms. */
         return 100;
@@ -1276,12 +1276,12 @@ done:
  *****************************************************************************/
 
 static int
-ble_gap_adv_disable_tx(void)
+ble_gap_adv_enable_tx(int enable)
 {
     uint8_t buf[BLE_HCI_CMD_HDR_LEN + BLE_HCI_SET_ADV_ENABLE_LEN];
     int rc;
 
-    host_hci_cmd_build_le_set_adv_enable(0, buf, sizeof buf);
+    host_hci_cmd_build_le_set_adv_enable(!!enable, buf, sizeof buf);
     rc = ble_hci_cmd_tx_empty_ack(buf);
     if (rc != 0) {
         return rc;
@@ -1321,7 +1321,7 @@ ble_gap_adv_stop(void)
 
     BLE_HS_LOG(INFO, "GAP procedure initiated: stop advertising.\n");
 
-    rc = ble_gap_adv_disable_tx();
+    rc = ble_gap_adv_enable_tx(0);
     if (rc != 0) {
         goto done;
     }
@@ -1344,22 +1344,6 @@ done:
  *****************************************************************************/
 
 static int
-ble_gap_adv_enable_tx(void)
-{
-    uint8_t buf[BLE_HCI_CMD_HDR_LEN + BLE_HCI_SET_ADV_PARAM_LEN];
-    int rc;
-
-    host_hci_cmd_build_le_set_adv_enable(1, buf, sizeof buf);
-
-    rc = ble_hci_cmd_tx_empty_ack(buf);
-    if (rc != 0) {
-        return rc;
-    }
-
-    return 0;
-}
-
-static int
 ble_gap_adv_rsp_data_tx(void)
 {
     uint8_t buf[BLE_HCI_CMD_HDR_LEN + BLE_HCI_SET_SCAN_RSP_DATA_LEN];
@@ -1722,7 +1706,7 @@ ble_gap_adv_start(uint8_t own_addr_type, uint8_t peer_addr_type,
         }
     }
 
-    rc = ble_gap_adv_enable_tx();
+    rc = ble_gap_adv_enable_tx(1);
     if (rc != 0) {
         goto done;
     }