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/04/20 03:17:48 UTC

[6/7] incubator-mynewt-core git commit: ble host - major changes.

ble host - major changes.

These changes are detailed in this thread on the mynewt dev list:
http://mail-archives.apache.org/mod_mbox/incubator-mynewt-dev/201604.mbox/%3C20160417225734.GB8991%40iori.nightmare-heaven.no-ip.biz%3E

Here is a summary of the changes:

1. All HCI command/acknowledgement exchanges are blocking.

    * FSM machinery goes away; controller response is indicated in the
      return code of the HCI send function.
    * Nearly all HCI failures are indicated to the application
      immediately, so there is no need for lots of mutexes and temporary
      copies of data structures.
    * API is simplified; operation results are indicated via a simple
      function return code.

2. The Nimble host is "taskless"

the Nimble host is now a "flat" library that runs in an application
task.  When the application initializes the host, it indicates which OS
event queue should be used for host-related events.  Host operations are
captured in OS_EVENT_TIMER events that the application task would need
to handle generically, as it most likely already does.


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

Branch: refs/heads/develop
Commit: e32f9f9f20666ecbb42598db0737b9c8f1ca6c74
Parents: f6bc99f
Author: Christopher Collins <cc...@apache.org>
Authored: Tue Apr 12 11:31:14 2016 -0700
Committer: Christopher Collins <cc...@apache.org>
Committed: Tue Apr 19 17:52:53 2016 -0700

----------------------------------------------------------------------
 apps/bletiny/src/main.c                        |    8 +-
 net/nimble/host/include/host/ble_gatt.h        |   14 +-
 net/nimble/host/include/host/ble_hs.h          |    7 +-
 net/nimble/host/include/host/ble_l2cap.h       |    1 +
 net/nimble/host/include/host/host_hci.h        |   20 +-
 net/nimble/host/src/ble_att.c                  |    7 +-
 net/nimble/host/src/ble_att_clt.c              |   24 +-
 net/nimble/host/src/ble_att_svr.c              |   28 +-
 net/nimble/host/src/ble_fsm.c                  |  530 ----
 net/nimble/host/src/ble_fsm_priv.h             |   88 -
 net/nimble/host/src/ble_gap.c                  | 1146 +++-----
 net/nimble/host/src/ble_gatt_priv.h            |    1 -
 net/nimble/host/src/ble_gattc.c                | 2690 +++++++------------
 net/nimble/host/src/ble_gatts.c                |    8 +-
 net/nimble/host/src/ble_hci_block.c            |  229 --
 net/nimble/host/src/ble_hci_sched.c            |  474 ----
 net/nimble/host/src/ble_hci_sched.h            |   47 -
 net/nimble/host/src/ble_hci_util.c             |   78 +
 net/nimble/host/src/ble_hci_util.h             |   26 +
 net/nimble/host/src/ble_hs.c                   |  179 +-
 net/nimble/host/src/ble_hs_atomic.c            |   45 +
 net/nimble/host/src/ble_hs_atomic.h            |   25 +
 net/nimble/host/src/ble_hs_cfg.c               |    1 -
 net/nimble/host/src/ble_hs_conn.c              |  120 +-
 net/nimble/host/src/ble_hs_conn.h              |    6 +-
 net/nimble/host/src/ble_hs_misc.c              |   10 +-
 net/nimble/host/src/ble_hs_priv.h              |   44 +-
 net/nimble/host/src/ble_hs_startup.c           |  213 +-
 net/nimble/host/src/ble_ibeacon.c              |    9 +-
 net/nimble/host/src/ble_l2cap_priv.h           |    3 +-
 net/nimble/host/src/ble_l2cap_sig.c            |  439 +--
 net/nimble/host/src/ble_l2cap_sig_cmd.c        |    4 +-
 net/nimble/host/src/ble_l2cap_sm.c             | 1142 +++-----
 net/nimble/host/src/ble_l2cap_sm.h             |    9 +-
 net/nimble/host/src/ble_l2cap_sm_cmd.c         |   13 +-
 net/nimble/host/src/host_hci.c                 |  356 ++-
 net/nimble/host/src/host_hci_cmd.c             |  240 +-
 net/nimble/host/src/test/ble_gap_test.c        |  155 +-
 net/nimble/host/src/test/ble_gatt_conn_test.c  |   50 +-
 net/nimble/host/src/test/ble_gatt_read_test.c  |   55 +-
 net/nimble/host/src/test/ble_gatt_write_test.c |    9 +-
 net/nimble/host/src/test/ble_host_hci_test.c   |  133 -
 net/nimble/host/src/test/ble_hs_conn_test.c    |   69 -
 net/nimble/host/src/test/ble_hs_test.c         |   27 +-
 net/nimble/host/src/test/ble_hs_test_util.c    |  149 +-
 net/nimble/host/src/test/ble_hs_test_util.h    |   13 +-
 net/nimble/host/src/test/ble_l2cap_sm_test.c   |   30 +-
 net/nimble/host/src/test/ble_l2cap_test.c      |   12 +-
 net/nimble/host/src/test/ble_os_test.c         |   99 +-
 net/nimble/include/nimble/hci_common.h         |    2 +-
 50 files changed, 2956 insertions(+), 6131 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/incubator-mynewt-core/blob/e32f9f9f/apps/bletiny/src/main.c
----------------------------------------------------------------------
diff --git a/apps/bletiny/src/main.c b/apps/bletiny/src/main.c
index 20efe2f..2cec311 100755
--- a/apps/bletiny/src/main.c
+++ b/apps/bletiny/src/main.c
@@ -47,7 +47,6 @@
  * app uses some of nimble's internal details for logging.
  */
 #include "../src/ble_hs_conn.h"
-#include "../src/ble_hci_sched.h"
 
 #define BSWAP16(x)  ((uint16_t)(((x) << 8) | (((x) & 0xff00) >> 8)))
 
@@ -978,6 +977,7 @@ bletiny_on_scan(int event, int status, struct ble_gap_disc_desc *desc,
     }
 }
 
+#if 0
 static void
 bletiny_on_rx_rssi(struct ble_hci_ack *ack, void *unused)
 {
@@ -996,6 +996,7 @@ bletiny_on_rx_rssi(struct ble_hci_ack *ack, void *unused)
     console_printf("rssi response received; status=%d conn=%d rssi=%d\n",
                    params.status, params.connection_handle, params.rssi);
 }
+#endif
 
 int
 bletiny_exchange_mtu(uint16_t conn_handle)
@@ -1267,6 +1268,7 @@ bletiny_l2cap_update(uint16_t conn_handle,
     return rc;
 }
 
+#if 0
 static int
 bletiny_tx_rssi_req(void *arg)
 {
@@ -1285,10 +1287,12 @@ bletiny_tx_rssi_req(void *arg)
 
     return 0;
 }
+#endif
 
 int
 bletiny_show_rssi(uint16_t conn_handle)
 {
+#if 0
     int rc;
 
     rc = ble_hci_sched_enqueue(bletiny_tx_rssi_req,
@@ -1298,8 +1302,8 @@ bletiny_show_rssi(uint16_t conn_handle)
         return rc;
     }
 
+#endif
     return 0;
-
 }
 
 int

http://git-wip-us.apache.org/repos/asf/incubator-mynewt-core/blob/e32f9f9f/net/nimble/host/include/host/ble_gatt.h
----------------------------------------------------------------------
diff --git a/net/nimble/host/include/host/ble_gatt.h b/net/nimble/host/include/host/ble_gatt.h
index d147cdf..73d73e5 100644
--- a/net/nimble/host/include/host/ble_gatt.h
+++ b/net/nimble/host/include/host/ble_gatt.h
@@ -68,12 +68,6 @@ typedef int ble_gatt_disc_svc_fn(uint16_t conn_handle,
 typedef int ble_gatt_attr_fn(uint16_t conn_handle,
                              struct ble_gatt_error *error,
                              struct ble_gatt_attr *attr, void *arg);
-typedef int ble_gatt_mult_attr_fn(uint16_t conn_handle,
-                                  struct ble_gatt_error *error,
-                                  uint16_t *attr_handles,
-                                  uint8_t num_attr_handles,
-                                  uint8_t *attr_data, uint16_t attr_data_len,
-                                  void *arg);
 typedef int ble_gatt_reliable_attr_fn(uint16_t conn_handle,
                                       struct ble_gatt_error *error,
                                       struct ble_gatt_attr *attrs,
@@ -112,11 +106,10 @@ int ble_gattc_read_by_uuid(uint16_t conn_handle, uint16_t start_handle,
 int ble_gattc_read_long(uint16_t conn_handle, uint16_t handle,
                         ble_gatt_attr_fn *cb, void *cb_arg);
 int ble_gattc_read_mult(uint16_t conn_handle, uint16_t *handles,
-                        uint8_t num_handles, ble_gatt_mult_attr_fn *cb,
+                        uint8_t num_handles, ble_gatt_attr_fn *cb,
                         void *cb_arg);
 int ble_gattc_write_no_rsp(uint16_t conn_handle, uint16_t attr_handle,
-                           void *value, uint16_t value_len,
-                           ble_gatt_attr_fn *cb, void *cb_arg);
+                           void *value, uint16_t value_len);
 int ble_gattc_write(uint16_t conn_handle, uint16_t attr_handle, void *value,
                     uint16_t value_len, ble_gatt_attr_fn *cb, void *cb_arg);
 int ble_gattc_write_long(uint16_t conn_handle, uint16_t attr_handle,
@@ -136,7 +129,8 @@ int ble_gattc_write_long_dsc(uint16_t conn_handle, uint16_t attr_handle,
                              void *value, uint16_t value_len,
                              ble_gatt_attr_fn *cb, void *cb_arg);
 int ble_gattc_notify(uint16_t conn_handle, uint16_t chr_val_handle);
-int ble_gattc_notify_custom(uint16_t conn_handle, struct ble_gatt_attr *attr);
+int ble_gattc_notify_custom(uint16_t conn_handle, uint16_t att_handle,
+                            void *attr_data, uint16_t attr_data_len);
 
 int ble_gattc_init(void);
 

http://git-wip-us.apache.org/repos/asf/incubator-mynewt-core/blob/e32f9f9f/net/nimble/host/include/host/ble_hs.h
----------------------------------------------------------------------
diff --git a/net/nimble/host/include/host/ble_hs.h b/net/nimble/host/include/host/ble_hs.h
index dfffc97..72cde41 100644
--- a/net/nimble/host/include/host/ble_hs.h
+++ b/net/nimble/host/include/host/ble_hs.h
@@ -28,6 +28,8 @@
 #include "host/ble_hs_test.h"
 #include "host/ble_uuid.h"
 #include "host/host_hci.h"
+struct os_eventq;
+struct os_event;
 
 #define BLE_HS_CONN_HANDLE_NONE     0xffff
 
@@ -69,7 +71,6 @@
 struct ble_hs_cfg {
     /** HCI settings. */
     uint8_t max_hci_bufs;
-    uint8_t max_hci_tx_slots;
 
     /** Connection settings. */
     uint16_t max_outstanding_pkts_per_conn;
@@ -105,7 +106,9 @@ struct ble_hs_cfg {
 
 extern const struct ble_hs_cfg ble_hs_cfg_dflt;
 
+int ble_hs_start(void);
+void ble_hs_event_enqueue(struct os_event *ev);
 int ble_ibeacon_set_adv_data(void *uuid128, uint16_t major, uint16_t minor);
-int ble_hs_init(uint8_t prio, struct ble_hs_cfg *cfg);
+int ble_hs_init(struct os_eventq *app_evq, struct ble_hs_cfg *cfg);
 
 #endif

http://git-wip-us.apache.org/repos/asf/incubator-mynewt-core/blob/e32f9f9f/net/nimble/host/include/host/ble_l2cap.h
----------------------------------------------------------------------
diff --git a/net/nimble/host/include/host/ble_l2cap.h b/net/nimble/host/include/host/ble_l2cap.h
index 01e25a6..b25e163 100644
--- a/net/nimble/host/include/host/ble_l2cap.h
+++ b/net/nimble/host/include/host/ble_l2cap.h
@@ -80,6 +80,7 @@ struct ble_hs_conn;
 #define BLE_L2CAP_SM_ERR_NUM_CMP            0x0c
 #define BLE_L2CAP_SM_ERR_ALREADY            0x0d
 #define BLE_L2CAP_SM_ERR_CROSS_TRANS        0x0e
+#define BLE_L2CAP_SM_ERR_MAX_PLUS_1         0x0f
 
 #define BLE_L2CAP_SM_PAIR_ALG_JW            0
 #define BLE_L2CAP_SM_PAIR_ALG_PASSKEY       1

http://git-wip-us.apache.org/repos/asf/incubator-mynewt-core/blob/e32f9f9f/net/nimble/host/include/host/host_hci.h
----------------------------------------------------------------------
diff --git a/net/nimble/host/include/host/host_hci.h b/net/nimble/host/include/host/host_hci.h
index 97db9ff..1a15f01 100644
--- a/net/nimble/host/include/host/host_hci.h
+++ b/net/nimble/host/include/host/host_hci.h
@@ -30,6 +30,8 @@ uint16_t host_hci_opcode_join(uint8_t ogf, uint16_t ocf);
 void host_hci_write_hdr(uint8_t ogf, uint8_t ocf, uint8_t len, void *buf);
 int host_hci_cmd_send(uint8_t ogf, uint8_t ocf, uint8_t len, void *cmddata);
 int host_hci_cmd_send_buf(void *cmddata);
+void host_hci_cmd_build_set_event_mask(uint64_t event_mask,
+                                       uint8_t *dst, int dst_len);
 int host_hci_cmd_set_event_mask(uint64_t event_mask);
 void host_hci_cmd_build_disconnect(uint16_t handle, uint8_t reason,
                                    uint8_t *dst, int dst_len);
@@ -52,8 +54,12 @@ int host_hci_cmd_build_le_set_adv_params(struct hci_adv_params *adv,
                                          uint8_t *dst, int dst_len);
 int host_hci_cmd_le_set_adv_params(struct hci_adv_params *adv);
 int host_hci_cmd_le_set_rand_addr(uint8_t *addr);
+void host_hci_cmd_build_le_set_event_mask(uint64_t event_mask,
+                                          uint8_t *dst, int dst_len);
 int host_hci_cmd_le_set_event_mask(uint64_t event_mask);
+void host_hci_cmd_build_le_read_buffer_size(uint8_t *dst, int dst_len);
 int host_hci_cmd_le_read_buffer_size(void);
+void host_hci_cmd_build_le_read_loc_supp_feat(uint8_t *dst, uint8_t dst_len);
 int host_hci_cmd_le_read_loc_supp_feat(void);
 int host_hci_cmd_le_read_rem_used_feat(uint16_t handle);
 void host_hci_cmd_build_le_set_adv_enable(uint8_t enable, uint8_t *dst,
@@ -76,13 +82,14 @@ int host_hci_cmd_le_set_scan_enable(uint8_t enable, uint8_t filter_dups);
 int host_hci_cmd_build_le_create_connection(struct hci_create_conn *hcc,
                                             uint8_t *cmd, int cmd_len);
 int host_hci_cmd_le_create_connection(struct hci_create_conn *hcc);
-void host_hci_cmd_le_build_clear_whitelist(uint8_t *dst, int dst_len);
+void host_hci_cmd_build_le_clear_whitelist(uint8_t *dst, int dst_len);
 int host_hci_cmd_le_clear_whitelist(void);
 int host_hci_cmd_le_read_whitelist(void);
 int host_hci_cmd_build_le_add_to_whitelist(uint8_t *addr, uint8_t addr_type,
                                            uint8_t *dst, int dst_len);
 int host_hci_cmd_le_add_to_whitelist(uint8_t *addr, uint8_t addr_type);
 int host_hci_cmd_le_rmv_from_whitelist(uint8_t *addr, uint8_t addr_type);
+void host_hci_cmd_build_reset(uint8_t *dst, int dst_len);
 int host_hci_cmd_reset(void);
 void host_hci_cmd_build_read_adv_pwr(uint8_t *dst, int dst_len);
 int host_hci_cmd_read_adv_pwr(void);
@@ -91,9 +98,15 @@ int host_hci_cmd_le_create_conn_cancel(void);
 int host_hci_cmd_build_le_conn_update(struct hci_conn_update *hcu,
                                       uint8_t *dst, int dst_len);
 int host_hci_cmd_le_conn_update(struct hci_conn_update *hcu);
+void host_hci_cmd_build_le_lt_key_req_reply(struct hci_lt_key_req_reply *hkr,
+                                            uint8_t *dst, int dst_len);
 int host_hci_cmd_le_lt_key_req_reply(struct hci_lt_key_req_reply *hkr);
 int host_hci_cmd_le_lt_key_req_neg_reply(uint16_t handle);
+void host_hci_cmd_build_le_conn_param_reply(struct hci_conn_param_reply *hcr,
+                                            uint8_t *dst, int dst_len);
 int host_hci_cmd_le_conn_param_reply(struct hci_conn_param_reply *hcr);
+void host_hci_cmd_build_le_conn_param_neg_reply(
+    struct hci_conn_param_neg_reply *hcn, uint8_t *dst, int dst_len);
 int host_hci_cmd_le_conn_param_neg_reply(struct hci_conn_param_neg_reply *hcn);
 int host_hci_cmd_le_read_supp_states(void);
 int host_hci_cmd_le_read_max_datalen(void);
@@ -102,7 +115,10 @@ int host_hci_cmd_le_write_sugg_datalen(uint16_t txoctets, uint16_t txtime);
 int host_hci_cmd_le_set_datalen(uint16_t handle, uint16_t txoctets,
                                 uint16_t txtime);
 int host_hci_cmd_le_encrypt(uint8_t *key, uint8_t *pt);
+void host_hci_cmd_build_le_rand(uint8_t *dst, int dst_len);
 int host_hci_cmd_le_rand(void);
+void host_hci_cmd_build_le_start_encrypt(struct hci_start_encrypt *cmd,
+                                         uint8_t *dst, int dst_len);
 int host_hci_cmd_le_start_encrypt(struct hci_start_encrypt *cmd);
 int host_hci_set_buf_size(uint16_t pktlen, uint8_t max_pkts);
 
@@ -114,6 +130,4 @@ int host_hci_data_tx(struct ble_hs_conn *connection, struct os_mbuf *om);
 void host_hci_timer_set(void);
 void host_hci_init(void);
 
-extern uint16_t host_hci_outstanding_opcode;
-
 #endif /* H_HOST_HCI_ */

http://git-wip-us.apache.org/repos/asf/incubator-mynewt-core/blob/e32f9f9f/net/nimble/host/src/ble_att.c
----------------------------------------------------------------------
diff --git a/net/nimble/host/src/ble_att.c b/net/nimble/host/src/ble_att.c
index c9fa0bb..74679f7 100644
--- a/net/nimble/host/src/ble_att.c
+++ b/net/nimble/host/src/ble_att.c
@@ -396,9 +396,6 @@ ble_att_inc_rx_stat(uint8_t att_op)
     }
 }
 
-/**
- * Lock restrictions: Caller must NOT lock ble_hs_conn mutex.
- */
 uint16_t
 ble_att_mtu(uint16_t conn_handle)
 {
@@ -406,7 +403,7 @@ ble_att_mtu(uint16_t conn_handle)
     struct ble_hs_conn *conn;
     uint16_t mtu;
 
-    ble_hs_conn_lock();
+    ble_hs_lock();
 
     ble_att_conn_chan_find(conn_handle, &conn, &chan);
     if (chan != NULL) {
@@ -415,7 +412,7 @@ ble_att_mtu(uint16_t conn_handle)
         mtu = 0;
     }
 
-    ble_hs_conn_unlock();
+    ble_hs_unlock();
 
     return mtu;
 }

http://git-wip-us.apache.org/repos/asf/incubator-mynewt-core/blob/e32f9f9f/net/nimble/host/src/ble_att_clt.c
----------------------------------------------------------------------
diff --git a/net/nimble/host/src/ble_att_clt.c b/net/nimble/host/src/ble_att_clt.c
index 575399d..19af956 100644
--- a/net/nimble/host/src/ble_att_clt.c
+++ b/net/nimble/host/src/ble_att_clt.c
@@ -117,10 +117,6 @@ ble_att_clt_copy_attr_to_flatbuf(struct os_mbuf *om, void **out_attr_val,
     return 0;
 }
 
-/**
- * Lock restrictions:
- *     o Caller unlocks ble_hs_conn.
- */
 static int
 ble_att_clt_tx_req(uint16_t conn_handle, struct os_mbuf *txom)
 {
@@ -131,19 +127,15 @@ ble_att_clt_tx_req(uint16_t conn_handle, struct os_mbuf *txom)
     BLE_HS_DBG_ASSERT_EVAL(txom->om_len >= 1);
     ble_att_inc_tx_stat(txom->om_data[0]);
 
-    ble_hs_conn_lock();
+    ble_hs_lock();
 
     rc = ble_att_conn_chan_find(conn_handle, &conn, &chan);
     if (rc == 0) {
-        if (!ble_hs_conn_can_tx(conn)) {
-            rc = BLE_HS_ECONGESTED;
-        } else {
-            rc = ble_l2cap_tx(conn, chan, txom);
-            txom = NULL;
-        }
+        rc = ble_l2cap_tx(conn, chan, txom);
+        txom = NULL;
     }
 
-    ble_hs_conn_unlock();
+    ble_hs_unlock();
 
     os_mbuf_free_chain(txom);
     return rc;
@@ -233,14 +225,14 @@ ble_att_clt_tx_mtu(uint16_t conn_handle, struct ble_att_mtu_cmd *req)
         return rc;
     }
 
-    ble_hs_conn_lock();
+    ble_hs_lock();
 
     rc = ble_att_conn_chan_find(conn_handle, &conn, &chan);
     if (rc == 0) {
         chan->blc_flags |= BLE_L2CAP_CHAN_F_TXED_MTU;
     }
 
-    ble_hs_conn_unlock();
+    ble_hs_unlock();
 
     return rc;
 }
@@ -263,7 +255,7 @@ ble_att_clt_rx_mtu(uint16_t conn_handle, struct os_mbuf **om)
     if (rc == 0) {
         ble_att_mtu_cmd_parse((*om)->om_data, (*om)->om_len, &rsp);
 
-        ble_hs_conn_lock();
+        ble_hs_lock();
 
         rc = ble_att_conn_chan_find(conn_handle, NULL, &chan);
         if (rc == 0) {
@@ -271,7 +263,7 @@ ble_att_clt_rx_mtu(uint16_t conn_handle, struct os_mbuf **om)
             mtu = ble_l2cap_chan_mtu(chan);
         }
 
-        ble_hs_conn_unlock();
+        ble_hs_unlock();
     }
 
     ble_gattc_rx_mtu(conn_handle, rc, mtu);

http://git-wip-us.apache.org/repos/asf/incubator-mynewt-core/blob/e32f9f9f/net/nimble/host/src/ble_att_svr.c
----------------------------------------------------------------------
diff --git a/net/nimble/host/src/ble_att_svr.c b/net/nimble/host/src/ble_att_svr.c
index aadab63..8f647e2 100644
--- a/net/nimble/host/src/ble_att_svr.c
+++ b/net/nimble/host/src/ble_att_svr.c
@@ -240,8 +240,6 @@ ble_att_svr_read(uint16_t conn_handle, struct ble_att_svr_entry *entry,
     uint8_t att_err;
     int rc;
 
-    ble_hs_misc_assert_no_locks();
-
     if (conn_handle != BLE_HS_CONN_HANDLE_NONE &&
         !(entry->ha_flags & HA_FLAG_PERM_READ)) {
 
@@ -312,7 +310,7 @@ ble_att_svr_write(uint16_t conn_handle, struct ble_att_svr_entry *entry,
     uint8_t att_err;
     int rc;
 
-    BLE_HS_DBG_ASSERT(!ble_hs_conn_locked_by_cur_task());
+    ble_hs_misc_assert_not_locked();
 
     if (conn_handle != BLE_HS_CONN_HANDLE_NONE &&
         !(entry->ha_flags & HA_FLAG_PERM_WRITE)) {
@@ -453,7 +451,7 @@ ble_att_svr_tx_rsp(uint16_t conn_handle, int rc, struct os_mbuf *txom,
     }
 
     if (do_tx) {
-        ble_hs_conn_lock();
+        ble_hs_lock();
 
         ble_att_conn_chan_find(conn_handle, &conn, &chan);
         if (chan == NULL) {
@@ -476,7 +474,7 @@ ble_att_svr_tx_rsp(uint16_t conn_handle, int rc, struct os_mbuf *txom,
             }
         }
 
-        ble_hs_conn_unlock();
+        ble_hs_unlock();
     }
 
     os_mbuf_free_chain(txom);
@@ -501,12 +499,12 @@ ble_att_svr_build_mtu_rsp(uint16_t conn_handle, struct os_mbuf **out_txom,
     *att_err = 0; /* Silence unnecessary warning. */
     txom = NULL;
 
-    ble_hs_conn_lock();
+    ble_hs_lock();
     rc = ble_att_conn_chan_find(conn_handle, NULL, &chan);
     if (rc == 0) {
         mtu = chan->blc_my_mtu;
     }
-    ble_hs_conn_unlock();
+    ble_hs_unlock();
 
     if (rc != 0) {
         goto done;
@@ -570,13 +568,13 @@ done:
     rc = ble_att_svr_tx_rsp(conn_handle, rc, txom, BLE_ATT_OP_FIND_INFO_REQ,
                             att_err, 0);
     if (rc == 0) {
-        ble_hs_conn_lock();
+        ble_hs_lock();
         ble_att_conn_chan_find(conn_handle, &conn, &chan);
         if (chan != NULL) {
             ble_att_set_peer_mtu(chan, cmd.bamc_mtu);
             chan->blc_flags |= BLE_L2CAP_CHAN_F_TXED_MTU;
         }
-        ble_hs_conn_unlock();
+        ble_hs_unlock();
     }
     return rc;
 }
@@ -2435,7 +2433,7 @@ ble_att_svr_rx_prep_write(uint16_t conn_handle, struct os_mbuf **rxom)
     prep_entry->bape_handle = req.bapc_handle;
     prep_entry->bape_offset = req.bapc_offset;
 
-    ble_hs_conn_lock();
+    ble_hs_lock();
 
     conn = ble_hs_conn_find(conn_handle);
     if (conn == NULL) {
@@ -2466,7 +2464,7 @@ ble_att_svr_rx_prep_write(uint16_t conn_handle, struct os_mbuf **rxom)
         }
     }
 
-    ble_hs_conn_unlock();
+    ble_hs_unlock();
 
     if (rc != 0) {
         goto done;
@@ -2491,7 +2489,7 @@ ble_att_svr_rx_prep_write(uint16_t conn_handle, struct os_mbuf **rxom)
 
 done:
     if (rc != 0 && rc != BLE_HS_ENOTCONN) {
-        ble_hs_conn_lock();
+        ble_hs_lock();
 
         conn = ble_hs_conn_find(conn_handle);
         if (conn == NULL) {
@@ -2510,7 +2508,7 @@ done:
             }
         }
 
-        ble_hs_conn_unlock();
+        ble_hs_unlock();
     }
 
     rc = ble_att_svr_tx_rsp(conn_handle, rc, txom, BLE_ATT_OP_PREP_WRITE_REQ,
@@ -2597,7 +2595,7 @@ ble_att_svr_rx_exec_write(uint16_t conn_handle, struct os_mbuf **rxom)
 
 done:
     if (rc == 0) {
-        ble_hs_conn_lock();
+        ble_hs_lock();
         conn = ble_hs_conn_find(conn_handle);
         if (conn == NULL) {
             rc = BLE_HS_ENOTCONN;
@@ -2613,7 +2611,7 @@ done:
             /* Erase all prep entries. */
             ble_att_svr_prep_clear(&conn->bhc_att_svr);
         }
-        ble_hs_conn_unlock();
+        ble_hs_unlock();
     }
 
     rc = ble_att_svr_tx_rsp(conn_handle, rc, txom, BLE_ATT_OP_EXEC_WRITE_REQ,

http://git-wip-us.apache.org/repos/asf/incubator-mynewt-core/blob/e32f9f9f/net/nimble/host/src/ble_fsm.c
----------------------------------------------------------------------
diff --git a/net/nimble/host/src/ble_fsm.c b/net/nimble/host/src/ble_fsm.c
deleted file mode 100644
index e6edd28..0000000
--- a/net/nimble/host/src/ble_fsm.c
+++ /dev/null
@@ -1,530 +0,0 @@
-/**
- * Licensed to the Apache Software Foundation (ASF) under one
- * or more contributor license agreements.  See the NOTICE file
- * distributed with this work for additional information
- * regarding copyright ownership.  The ASF licenses this file
- * to you under the Apache License, Version 2.0 (the
- * "License"); you may not use this file except in compliance
- * with the License.  You may obtain a copy of the License at
- *
- *  http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing,
- * software distributed under the License is distributed on an
- * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
- * KIND, either express or implied.  See the License for the
- * specific language governing permissions and limitations
- * under the License.
- */
-
-#include <stddef.h>
-#include <assert.h>
-#include <stdlib.h>
-#include <errno.h>
-#include <string.h>
-#include "os/os_mempool.h"
-#include "nimble/ble.h"
-#include "host/ble_uuid.h"
-#include "host/ble_gap.h"
-#include "ble_hs_priv.h"
-
-/*****************************************************************************
- * $mutex                                                                    *
- *****************************************************************************/
-
-void
-ble_fsm_lock(struct ble_fsm *fsm)
-{
-    struct os_task *owner;
-    int rc;
-
-    owner = fsm->mutex.mu_owner;
-    if (owner != NULL) {
-        BLE_HS_DBG_ASSERT_EVAL(owner != os_sched_get_current_task());
-    }
-
-    rc = os_mutex_pend(&fsm->mutex, 0xffffffff);
-    BLE_HS_DBG_ASSERT_EVAL(rc == 0 || rc == OS_NOT_STARTED);
-}
-
-void
-ble_fsm_unlock(struct ble_fsm *fsm)
-{
-    int rc;
-
-    rc = os_mutex_release(&fsm->mutex);
-    BLE_HS_DBG_ASSERT_EVAL(rc == 0 || rc == OS_NOT_STARTED);
-}
-
-int
-ble_fsm_locked_by_cur_task(struct ble_fsm *fsm)
-{
-    struct os_task *owner;
-
-    owner = fsm->mutex.mu_owner;
-    return owner != NULL && owner == os_sched_get_current_task();
-}
-
-/*****************************************************************************
- * $debug                                                                    *
- *****************************************************************************/
-
-/**
- * Ensures all procedure entries are in a valid state.
- *
- * Lock restrictions:
- *     o Caller locks fsm.
- */
-static void
-ble_fsm_assert_sanity(struct ble_fsm *fsm)
-{
-#if !BLE_HS_DEBUG
-    return;
-#endif
-
-    struct ble_fsm_proc *proc;
-    unsigned mask;
-    int num_set;
-
-    STAILQ_FOREACH(proc, &fsm->procs, next) {
-        /* Ensure exactly one flag is set. */
-        num_set = 0;
-        mask = 0x01;
-        while (mask <= UINT8_MAX) {
-            if (proc->flags & mask) {
-                num_set++;
-            }
-            mask <<= 1;
-        }
-
-        BLE_HS_DBG_ASSERT(num_set == 1);
-    }
-}
-
-/*****************************************************************************
- * $proc                                                                     *
- *****************************************************************************/
-
-/**
- * Removes the specified proc entry from a list without freeing it.
- *
- * Lock restrictions:
- *     o Caller locks fsm if the source list is fsm->procs.
- *
- * @param src_list              The list to remove the proc from.
- * @param proc                  The proc to remove.
- * @param prev                  The proc that is previous to "proc" in the
- *                                  list; null if "proc" is the list head.
- */
-void
-ble_fsm_proc_remove(struct ble_fsm_proc_list *src_list,
-                    struct ble_fsm_proc *proc,
-                    struct ble_fsm_proc *prev)
-{
-    if (prev == NULL) {
-        BLE_HS_DBG_ASSERT(STAILQ_FIRST(src_list) == proc);
-        STAILQ_REMOVE_HEAD(src_list, next);
-    } else {
-        BLE_HS_DBG_ASSERT(STAILQ_NEXT(prev, next) == proc);
-        STAILQ_NEXT(prev, next) = STAILQ_NEXT(proc, next);
-    }
-}
-
-/**
- * Concatenates the specified list onto the end of the main proc list.
- *
- * Lock restrictions:
- *     o Caller unlocks fsm.
- */
-void
-ble_fsm_proc_concat(struct ble_fsm *fsm, struct ble_fsm_proc_list *tail_list)
-{
-    struct ble_fsm_proc *proc;
-
-    if (!STAILQ_EMPTY(tail_list)) {
-        ble_fsm_lock(fsm);
-
-        if (STAILQ_EMPTY(&fsm->procs)) {
-            fsm->procs = *tail_list;
-        } else {
-            proc = STAILQ_LAST(&fsm->procs, ble_fsm_proc, next);
-            STAILQ_NEXT(proc, next) = STAILQ_FIRST(tail_list);
-            fsm->procs.stqh_last = tail_list->stqh_last;
-        }
-
-        ble_fsm_unlock(fsm);
-    }
-}
-
-/**
- * Determines if the specified proc entry's "pending" flag can be set.
- *
- * Lock restrictions: None.
- */
-int
-ble_fsm_proc_can_pend(struct ble_fsm_proc *proc)
-{
-    return !(proc->flags & (BLE_FSM_PROC_F_CONGESTED    |
-                            BLE_FSM_PROC_F_NO_MEM       |
-                            BLE_FSM_PROC_F_EXPECTING));
-}
-
-/**
- * Sets the specified proc entry's "pending" flag (i.e., indicates that the
- * FSM procedure is stalled until it transmits its next packet).
- *
- * Lock restrictions:
- *     o Caller locks fsm.
- */
-void
-ble_fsm_proc_set_pending(struct ble_fsm_proc *proc)
-{
-    BLE_HS_DBG_ASSERT(!(proc->flags & BLE_FSM_PROC_F_PENDING));
-
-    proc->flags &= ~BLE_FSM_PROC_F_EXPECTING;
-    proc->flags |= BLE_FSM_PROC_F_PENDING;
-}
-
-/**
- * Sets the specified proc entry's "expecting" flag (i.e., indicates that the
- * FSM procedure is stalled until it receives a packet).
- *
- * Lock restrictions: None.
- */
-static void
-ble_fsm_proc_set_expecting(struct ble_fsm_proc *proc)
-{
-    BLE_HS_DBG_ASSERT(!(proc->flags & BLE_FSM_PROC_F_EXPECTING));
-
-    proc->flags &= ~BLE_FSM_PROC_F_PENDING;
-    proc->flags |= BLE_FSM_PROC_F_EXPECTING;
-    proc->tx_time = os_time_get();
-}
-
-/**
- * Postpones tx for the specified proc entry if appropriate.  The determination
- * of whether tx should be postponed is based on the return code of the
- * previous transmit attempt.  This function should be called immediately after
- * transmission fails.  A tx can be postponed if the failure was caused by
- * congestion or memory exhaustion.  All other failures cannot be postponed,
- * and the procedure should be aborted entirely.
- *
- * Lock restrictions: None.
- *
- * @param proc                  The proc entry to check for postponement.
- * @param rc                    The return code of the previous tx attempt.
- *
- * @return                      1 if the transmit should be postponed; else 0.
- */
-int
-ble_fsm_tx_postpone_chk(struct ble_fsm_proc *proc, int rc)
-{
-    switch (rc) {
-    case BLE_HS_ECONGESTED:
-        proc->flags |= BLE_FSM_PROC_F_CONGESTED;
-        return 1;
-
-    case BLE_HS_ENOMEM:
-        proc->flags |= BLE_FSM_PROC_F_NO_MEM;
-        return 1;
-
-    default:
-        return 0;
-    }
-}
-
-/**
- * Called after an incoming packet is done being processed.  If the status of
- * the response processing is 0, the proc entry is re-inserted into the main
- * proc list.  Otherwise, the proc entry is freed.
- *
- * Lock restrictions:
- *     o Caller unlocks fsm.
- */
-void
-ble_fsm_process_rx_status(struct ble_fsm *fsm, struct ble_fsm_proc *proc,
-                          int status)
-{
-    if (status != 0) {
-        fsm->free_cb(proc);
-    } else {
-        ble_fsm_lock(fsm);
-        STAILQ_INSERT_HEAD(&fsm->procs, proc, next);
-        ble_fsm_unlock(fsm);
-    }
-}
-
-/**
- * Searches an fsm's proc list for the first entry that that fits a custom set
- * of criteria.  The supplied callback is applied to each entry in the list
- * until it indicates a match.  If a matching entry is found, it is removed
- * from the list and returned.
- *
- * Lock restrictions:
- *     o Caller unlocks fsm.
- *
- * @param fsm                   The fsm whose list should be searched.
- * @param out_proc              On success, the address of the matching proc is
- *                                  written here.
- * @extract_cb                  The callback to apply to each proc entry.
- * @arg                         An argument that gets passed to each invocation
- *                                  of the callback.
- *
- * @return                      The matching proc entry on success;
- *                                  null on failure.
- */
-int
-ble_fsm_proc_extract(struct ble_fsm *fsm,
-                     struct ble_fsm_proc **out_proc,
-                     ble_fsm_extract_fn *extract_cb, void *arg)
-{
-    struct ble_fsm_proc *prev;
-    struct ble_fsm_proc *proc;
-    int rc;
-
-    ble_fsm_lock(fsm);
-
-    ble_fsm_assert_sanity(fsm);
-
-    prev = NULL;
-
-    STAILQ_FOREACH(proc, &fsm->procs, next) {
-        rc = extract_cb(proc, arg);
-        switch (rc) {
-        case BLE_FSM_EXTRACT_EMOVE_CONTINUE:
-        case BLE_FSM_EXTRACT_EMOVE_STOP:
-            ble_fsm_proc_remove(&fsm->procs, proc, prev);
-            *out_proc = proc;
-            rc = 0;
-            goto done;
-
-        case BLE_FSM_EXTRACT_EKEEP_CONTINUE:
-            break;
-
-        case BLE_FSM_EXTRACT_EKEEP_STOP:
-            rc = 1;
-            goto done;
-
-        default:
-            BLE_HS_DBG_ASSERT(0);
-            rc = 1;
-            goto done;
-        }
-
-        prev = proc;
-    }
-
-    rc = 1;
-
-done:
-    ble_fsm_unlock(fsm);
-    return rc;
-}
-
-/**
- * Searches an fsm's proc list for all entries that that fits a custom set of
- * criteria.  The supplied callback is applied to each entry in the list to
- * determine if it matches. Each matching entry is removed from the list and
- * inserted into a secondary list.
- *
- * Lock restrictions:
- *     o Caller unlocks fsm.
- *
- * @param fsm                   The fsm whose list should be searched.
- * @param dst_list              Matching procs get appended to this list.
- * @extract_cb                  The callback to apply to each proc entry.
- * @arg                         An argument that gets passed to each invocation
- *                                  of the callback.
- *
- * @return                      The number of matching procs (i.e., the size of
- *                                  the destination list).
- */
-int
-ble_fsm_proc_extract_list(struct ble_fsm *fsm,
-                          struct ble_fsm_proc_list *dst_list,
-                          ble_fsm_extract_fn *extract_cb, void *arg)
-{
-    struct ble_fsm_proc *prev;
-    struct ble_fsm_proc *proc;
-    struct ble_fsm_proc *next;
-    int move;
-    int done;
-    int cnt;
-    int rc;
-
-    STAILQ_INIT(dst_list);
-    cnt = 0;
-
-    ble_fsm_lock(fsm);
-
-    ble_fsm_assert_sanity(fsm);
-
-    prev = NULL;
-    proc = STAILQ_FIRST(&fsm->procs);
-    while (proc != NULL) {
-        next = STAILQ_NEXT(proc, next);
-
-        rc = extract_cb(proc, arg);
-        switch (rc) {
-        case BLE_FSM_EXTRACT_EMOVE_CONTINUE:
-            move = 1;
-            done = 0;
-            break;
-
-        case BLE_FSM_EXTRACT_EMOVE_STOP:
-            move = 1;
-            done = 1;
-            break;
-
-        case BLE_FSM_EXTRACT_EKEEP_CONTINUE:
-            move = 0;
-            done = 0;
-            break;
-
-        case BLE_FSM_EXTRACT_EKEEP_STOP:
-            move = 0;
-            done = 1;
-            break;
-
-        default:
-            BLE_HS_DBG_ASSERT(0);
-            move = 0;
-            done = 1;
-            break;
-        }
-
-        if (move) {
-            ble_fsm_proc_remove(&fsm->procs, proc, prev);
-            STAILQ_INSERT_TAIL(dst_list, proc, next);
-            cnt++;
-        } else {
-            prev = proc;
-        }
-
-        if (done) {
-            break;
-        }
-
-        proc = next;
-    }
-
-    ble_fsm_unlock(fsm);
-
-    return cnt;
-}
-
-/**
- * Triggers a transmission for each active FSM procedure with a pending send.
- *
- * Lock restrictions:
- *     o Caller unlocks all ble_hs mutexes.
- */
-void
-ble_fsm_wakeup(struct ble_fsm *fsm)
-{
-    struct ble_fsm_proc_list proc_list;
-    struct ble_fsm_proc *proc;
-    struct ble_fsm_proc *prev;
-    struct ble_fsm_proc *next;
-    int rc;
-
-    ble_hs_misc_assert_no_locks();
-
-    STAILQ_INIT(&proc_list);
-
-    /* Remove all procs with pending transmits and insert them into the
-     * temporary list. Once the elements are moved, they can be processed
-     * without keeping the mutex locked.
-     */
-    ble_fsm_lock(fsm);
-
-    prev = NULL;
-    proc = STAILQ_FIRST(&fsm->procs);
-    while (proc != NULL) {
-        next = STAILQ_NEXT(proc, next);
-
-        if (proc->flags & BLE_FSM_PROC_F_PENDING) {
-            ble_fsm_proc_remove(&fsm->procs, proc, prev);
-            STAILQ_INSERT_TAIL(&proc_list, proc, next);
-        } else {
-            prev = proc;
-        }
-
-        proc = next;
-    }
-
-    ble_fsm_unlock(fsm);
-
-    /* Process each of the pending procs. */
-    prev = NULL;
-    proc = STAILQ_FIRST(&proc_list);
-    while (proc != NULL) {
-        next = STAILQ_NEXT(proc, next);
-
-        proc->flags &= ~BLE_FSM_PROC_F_PENDING;
-        rc = fsm->kick_cb(proc);
-        switch (rc) {
-        case 0:
-            /* Transmit succeeded.  Response expected. */
-            ble_fsm_proc_set_expecting(proc);
-
-            /* Current proc remains; reseat prev. */
-            prev = proc;
-            break;
-
-        case BLE_HS_EAGAIN:
-            /* Transmit failed; Reschedule. */
-            /* Current proc remains; reseat prev. */
-            prev = proc;
-            break;
-
-        case BLE_HS_EDONE:
-            /* Procedure complete. */
-            ble_fsm_proc_remove(&proc_list, proc, prev);
-            fsm->free_cb(proc);
-
-            /* Current proc removed; old prev still valid. */
-            break;
-
-        default:
-            BLE_HS_DBG_ASSERT(0);
-            break;
-        }
-
-        proc = next;
-    }
-
-    /* Concatenate the tempororary list to the end of the main list. */
-    ble_fsm_proc_concat(fsm, &proc_list);
-}
-
-/**
- * Initializes an fsm instance.
- *
- * Lock restrictions: none.
- *
- * @return                      0 on success; nonzero on failure.
- */
-int
-ble_fsm_new(struct ble_fsm *fsm, ble_fsm_kick_fn *kick_cb,
-            ble_fsm_free_fn *free_cb)
-{
-    int rc;
-
-    BLE_HS_DBG_ASSERT(kick_cb != NULL);
-    BLE_HS_DBG_ASSERT(free_cb != NULL);
-
-    memset(fsm, 0, sizeof *fsm);
-
-    rc = os_mutex_init(&fsm->mutex);
-    if (rc != 0) {
-        return BLE_HS_EOS;
-    }
-
-    STAILQ_INIT(&fsm->procs);
-
-    fsm->kick_cb = kick_cb;
-    fsm->free_cb = free_cb;
-
-    return 0;
-}

http://git-wip-us.apache.org/repos/asf/incubator-mynewt-core/blob/e32f9f9f/net/nimble/host/src/ble_fsm_priv.h
----------------------------------------------------------------------
diff --git a/net/nimble/host/src/ble_fsm_priv.h b/net/nimble/host/src/ble_fsm_priv.h
deleted file mode 100644
index cc874c4..0000000
--- a/net/nimble/host/src/ble_fsm_priv.h
+++ /dev/null
@@ -1,88 +0,0 @@
-/**
- * Licensed to the Apache Software Foundation (ASF) under one
- * or more contributor license agreements.  See the NOTICE file
- * distributed with this work for additional information
- * regarding copyright ownership.  The ASF licenses this file
- * to you under the Apache License, Version 2.0 (the
- * "License"); you may not use this file except in compliance
- * with the License.  You may obtain a copy of the License at
- *
- *  http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing,
- * software distributed under the License is distributed on an
- * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
- * KIND, either express or implied.  See the License for the
- * specific language governing permissions and limitations
- * under the License.
- */
-
-#ifndef H_BLE_FSM_PRIV_
-#define H_BLE_FSM_PRIV_
-
-#include "os/os_mutex.h"
-
-struct ble_fsm_proc {
-    STAILQ_ENTRY(ble_fsm_proc) next;
-
-    uint8_t op;
-    uint8_t flags;
-    uint16_t conn_handle;
-    uint32_t tx_time; /* OS ticks. */
-};
-
-/** Procedure has a tx pending. */
-#define BLE_FSM_PROC_F_PENDING     0x01
-
-/** Procedure currently expects a response. */
-#define BLE_FSM_PROC_F_EXPECTING   0x02
-
-/** Procedure failed to tx due to too many outstanding txes. */
-#define BLE_FSM_PROC_F_CONGESTED   0x04
-
-/** Procedure failed to tx due to memory exhaustion. */
-#define BLE_FSM_PROC_F_NO_MEM      0x08
-
-STAILQ_HEAD(ble_fsm_proc_list, ble_fsm_proc);
-
-typedef int ble_fsm_kick_fn(struct ble_fsm_proc *proc);
-typedef void ble_fsm_free_fn(struct ble_fsm_proc *proc);
-typedef int ble_fsm_extract_fn(struct ble_fsm_proc *proc, void *arg);
-
-#define BLE_FSM_EXTRACT_EMOVE_CONTINUE      0
-#define BLE_FSM_EXTRACT_EMOVE_STOP          1
-#define BLE_FSM_EXTRACT_EKEEP_CONTINUE      2
-#define BLE_FSM_EXTRACT_EKEEP_STOP          3
-
-struct ble_fsm {
-    struct os_mutex mutex;
-    struct ble_fsm_proc_list procs;
-
-    ble_fsm_kick_fn *kick_cb;
-    ble_fsm_free_fn *free_cb;
-};
-
-void ble_fsm_lock(struct ble_fsm *fsm);
-void ble_fsm_unlock(struct ble_fsm *fsm);
-int ble_fsm_locked_by_cur_task(struct ble_fsm *fsm);
-void ble_fsm_proc_remove(struct ble_fsm_proc_list *src_list,
-                         struct ble_fsm_proc *proc,
-                         struct ble_fsm_proc *prev);
-void ble_fsm_proc_concat(struct ble_fsm *fsm,
-                         struct ble_fsm_proc_list *tail_list);
-int ble_fsm_proc_can_pend(struct ble_fsm_proc *proc);
-void ble_fsm_proc_set_pending(struct ble_fsm_proc *proc);
-int ble_fsm_tx_postpone_chk(struct ble_fsm_proc *proc, int rc);
-void ble_fsm_process_rx_status(struct ble_fsm *fsm, struct ble_fsm_proc *proc,
-                               int status);
-int ble_fsm_proc_extract(struct ble_fsm *fsm,
-                         struct ble_fsm_proc **out_proc,
-                         ble_fsm_extract_fn *extract_cb, void *arg);
-int ble_fsm_proc_extract_list(struct ble_fsm *fsm,
-                              struct ble_fsm_proc_list *dst_list,
-                              ble_fsm_extract_fn *extract_cb, void *arg);
-void ble_fsm_wakeup(struct ble_fsm *fsm);
-int ble_fsm_new(struct ble_fsm *fsm, ble_fsm_kick_fn *kick_cb,
-                ble_fsm_free_fn *free_cb);
-
-#endif