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/11/01 17:16:49 UTC

[06/11] incubator-mynewt-core git commit: BLE Controller: Event codes -> callbacks

BLE Controller: Event codes -> callbacks


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

Branch: refs/heads/develop
Commit: cf38f1ff6fc2946e3e4caafb37c521890fcfc251
Parents: 98c990f
Author: Christopher Collins <cc...@apache.org>
Authored: Mon Oct 31 17:43:27 2016 -0700
Committer: Christopher Collins <cc...@apache.org>
Committed: Tue Nov 1 10:08:12 2016 -0700

----------------------------------------------------------------------
 .../controller/include/controller/ble_ll.h      | 12 +--
 .../controller/include/controller/ble_ll_adv.h  |  3 -
 .../controller/include/controller/ble_ll_conn.h |  4 +-
 .../controller/include/controller/ble_ll_hci.h  |  3 -
 .../controller/include/controller/ble_ll_scan.h |  3 -
 net/nimble/controller/src/ble_ll.c              | 83 ++++++++------------
 net/nimble/controller/src/ble_ll_adv.c          | 20 +++--
 net/nimble/controller/src/ble_ll_conn.c         | 38 +++++----
 net/nimble/controller/src/ble_ll_conn_hci.c     |  2 +-
 net/nimble/controller/src/ble_ll_conn_priv.h    |  2 -
 net/nimble/controller/src/ble_ll_ctrl.c         | 19 ++---
 net/nimble/controller/src/ble_ll_hci.c          |  6 +-
 net/nimble/controller/src/ble_ll_resolv.c       | 24 +++---
 net/nimble/controller/src/ble_ll_scan.c         |  8 +-
 14 files changed, 99 insertions(+), 128 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/incubator-mynewt-core/blob/cf38f1ff/net/nimble/controller/include/controller/ble_ll.h
----------------------------------------------------------------------
diff --git a/net/nimble/controller/include/controller/ble_ll.h b/net/nimble/controller/include/controller/ble_ll.h
index 875665f..e349d71 100644
--- a/net/nimble/controller/include/controller/ble_ll.h
+++ b/net/nimble/controller/include/controller/ble_ll.h
@@ -85,7 +85,7 @@ struct ble_ll_obj
     struct os_event ll_dbuf_overflow_ev;
 
     /* HW error callout */
-    struct os_callout_func ll_hw_err_timer;
+    struct os_callout ll_hw_err_timer;
 };
 extern struct ble_ll_obj g_ble_ll_data;
 
@@ -132,16 +132,6 @@ extern STATS_SECT_DECL(ble_ll_stats) ble_ll_stats;
 #define BLE_LL_STATE_INITIATING     (3)
 #define BLE_LL_STATE_CONNECTION     (4)
 
-/* BLE LL Task Events */
-#define BLE_LL_EVENT_HCI_CMD        (OS_EVENT_T_PERUSER)
-#define BLE_LL_EVENT_ADV_EV_DONE    (OS_EVENT_T_PERUSER + 1)
-#define BLE_LL_EVENT_RX_PKT_IN      (OS_EVENT_T_PERUSER + 2)
-#define BLE_LL_EVENT_SCAN           (OS_EVENT_T_PERUSER + 3)
-#define BLE_LL_EVENT_CONN_SPVN_TMO  (OS_EVENT_T_PERUSER + 4)
-#define BLE_LL_EVENT_CONN_EV_END    (OS_EVENT_T_PERUSER + 5)
-#define BLE_LL_EVENT_TX_PKT_IN      (OS_EVENT_T_PERUSER + 6)
-#define BLE_LL_EVENT_DBUF_OVERFLOW  (OS_EVENT_T_PERUSER + 7)
-
 /* LL Features */
 #define BLE_LL_FEAT_LE_ENCRYPTION   (0x01)
 #define BLE_LL_FEAT_CONN_PARM_REQ   (0x02)

http://git-wip-us.apache.org/repos/asf/incubator-mynewt-core/blob/cf38f1ff/net/nimble/controller/include/controller/ble_ll_adv.h
----------------------------------------------------------------------
diff --git a/net/nimble/controller/include/controller/ble_ll_adv.h b/net/nimble/controller/include/controller/ble_ll_adv.h
index 0f46f18..613efc0 100644
--- a/net/nimble/controller/include/controller/ble_ll_adv.h
+++ b/net/nimble/controller/include/controller/ble_ll_adv.h
@@ -129,9 +129,6 @@ uint8_t *ble_ll_adv_get_local_rpa(void);
 /* Returns peer resolvable private address */
 uint8_t *ble_ll_adv_get_peer_rpa(void);
 
-/* Called when advertising event done posted to LL task */
-void ble_ll_adv_event_done(void *arg);
-
 /* Called to initialize advertising functionality. */
 void ble_ll_adv_init(void);
 

http://git-wip-us.apache.org/repos/asf/incubator-mynewt-core/blob/cf38f1ff/net/nimble/controller/include/controller/ble_ll_conn.h
----------------------------------------------------------------------
diff --git a/net/nimble/controller/include/controller/ble_ll_conn.h b/net/nimble/controller/include/controller/ble_ll_conn.h
index f7dd1ae..6e6688c 100644
--- a/net/nimble/controller/include/controller/ble_ll_conn.h
+++ b/net/nimble/controller/include/controller/ble_ll_conn.h
@@ -231,13 +231,13 @@ struct ble_ll_conn_sm
     };
 
     /* LL control procedure response timer */
-    struct os_callout_func ctrl_proc_rsp_timer;
+    struct os_callout ctrl_proc_rsp_timer;
 
     /* For scheduling connections */
     struct ble_ll_sched_item conn_sch;
 
 #if (MYNEWT_VAL(BLE_LL_CFG_FEAT_LE_PING) == 1)
-    struct os_callout_func auth_pyld_timer;
+    struct os_callout auth_pyld_timer;
 #endif
 
     /*

http://git-wip-us.apache.org/repos/asf/incubator-mynewt-core/blob/cf38f1ff/net/nimble/controller/include/controller/ble_ll_hci.h
----------------------------------------------------------------------
diff --git a/net/nimble/controller/include/controller/ble_ll_hci.h b/net/nimble/controller/include/controller/ble_ll_hci.h
index a272aa6..05f0be6 100644
--- a/net/nimble/controller/include/controller/ble_ll_hci.h
+++ b/net/nimble/controller/include/controller/ble_ll_hci.h
@@ -40,9 +40,6 @@ extern const uint8_t g_ble_ll_supp_cmds[BLE_LL_SUPP_CMD_LEN];
 /* Initialize LL HCI */
 void ble_ll_hci_init(void);
 
-/* HCI command processing function */
-void ble_ll_hci_cmd_proc(struct os_event *ev);
-
 /* Used to determine if the LE event is enabled/disabled */
 uint8_t ble_ll_hci_is_le_event_enabled(int subev);
 

http://git-wip-us.apache.org/repos/asf/incubator-mynewt-core/blob/cf38f1ff/net/nimble/controller/include/controller/ble_ll_scan.h
----------------------------------------------------------------------
diff --git a/net/nimble/controller/include/controller/ble_ll_scan.h b/net/nimble/controller/include/controller/ble_ll_scan.h
index 91357a6..f9689f0 100644
--- a/net/nimble/controller/include/controller/ble_ll_scan.h
+++ b/net/nimble/controller/include/controller/ble_ll_scan.h
@@ -90,9 +90,6 @@ int ble_ll_scan_set_scan_params(uint8_t *cmd);
 int ble_ll_scan_set_enable(uint8_t *cmd);
 
 /*--- Controller Internal API ---*/
-/* Process scan window end event */
-void ble_ll_scan_event_proc(void *arg);
-
 /* Initialize the scanner */
 void ble_ll_scan_init(void);
 

http://git-wip-us.apache.org/repos/asf/incubator-mynewt-core/blob/cf38f1ff/net/nimble/controller/src/ble_ll.c
----------------------------------------------------------------------
diff --git a/net/nimble/controller/src/ble_ll.c b/net/nimble/controller/src/ble_ll.c
index f694b6d..3504b60 100644
--- a/net/nimble/controller/src/ble_ll.c
+++ b/net/nimble/controller/src/ble_ll.c
@@ -181,6 +181,10 @@ STATS_NAME_START(ble_ll_stats)
     STATS_NAME(ble_ll_stats, scan_rsp_txg)
 STATS_NAME_END(ble_ll_stats)
 
+static void ble_ll_event_rx_pkt(struct os_event *ev);
+static void ble_ll_event_tx_pkt(struct os_event *ev);
+static void ble_ll_event_dbuf_overflow(struct os_event *ev);
+
 /* The BLE LL task data structure */
 #define BLE_LL_STACK_SIZE   (80)
 struct os_task g_ble_ll_task;
@@ -744,7 +748,7 @@ ble_ll_data_buffer_overflow(void)
 void
 ble_ll_hw_error(void)
 {
-    os_callout_reset(&g_ble_ll_data.ll_hw_err_timer.cf_c, 0);
+    os_callout_reset(&g_ble_ll_data.ll_hw_err_timer, 0);
 }
 
 /**
@@ -753,7 +757,7 @@ ble_ll_hw_error(void)
  * @param arg
  */
 static void
-ble_ll_hw_err_timer_cb(void *arg)
+ble_ll_hw_err_timer_cb(struct os_event *ev)
 {
     if (ble_ll_hci_ev_hw_err(BLE_HW_ERR_HCI_SYNC_LOSS)) {
         /*
@@ -761,7 +765,7 @@ ble_ll_hw_err_timer_cb(void *arg)
          * event every 50 milliseconds (or each OS tick if a tick is longer
          * than 100 msecs).
          */
-        os_callout_reset(&g_ble_ll_data.ll_hw_err_timer.cf_c,
+        os_callout_reset(&g_ble_ll_data.ll_hw_err_timer,
                          OS_TICKS_PER_SEC / 20);
     }
 }
@@ -953,6 +957,24 @@ ble_ll_rx_end(uint8_t *rxbuf, struct ble_mbuf_hdr *rxhdr)
     return rc;
 }
 
+static void
+ble_ll_event_rx_pkt(struct os_event *ev)
+{
+    ble_ll_rx_pkt_in();
+}
+
+static void
+ble_ll_event_tx_pkt(struct os_event *ev)
+{
+    ble_ll_tx_pkt_in();
+}
+
+static void
+ble_ll_event_dbuf_overflow(struct os_event *ev)
+{
+    ble_ll_hci_ev_databuf_overflow();
+}
+
 /**
  * Link Layer task.
  *
@@ -963,9 +985,6 @@ ble_ll_rx_end(uint8_t *rxbuf, struct ble_mbuf_hdr *rxhdr)
 void
 ble_ll_task(void *arg)
 {
-    struct os_event *ev;
-    struct os_callout_func *cf;
-
     /* Init ble phy */
     ble_phy_init();
 
@@ -977,44 +996,8 @@ ble_ll_task(void *arg)
 
     ble_ll_rand_start();
 
-    /* Wait for an event */
     while (1) {
-        ev = os_eventq_get(&g_ble_ll_data.ll_evq);
-        switch (ev->ev_type) {
-        case OS_EVENT_T_TIMER:
-            cf = (struct os_callout_func *)ev;
-            assert(cf->cf_func);
-            cf->cf_func(ev->ev_arg);
-            break;
-        case BLE_LL_EVENT_HCI_CMD:
-            /* Process HCI command */
-            ble_ll_hci_cmd_proc(ev);
-            break;
-        case BLE_LL_EVENT_ADV_EV_DONE:
-            ble_ll_adv_event_done(ev->ev_arg);
-            break;
-        case BLE_LL_EVENT_SCAN:
-            ble_ll_scan_event_proc(ev->ev_arg);
-            break;
-        case BLE_LL_EVENT_RX_PKT_IN:
-            ble_ll_rx_pkt_in();
-            break;
-        case BLE_LL_EVENT_TX_PKT_IN:
-            ble_ll_tx_pkt_in();
-            break;
-        case BLE_LL_EVENT_DBUF_OVERFLOW:
-            ble_ll_hci_ev_databuf_overflow();
-            break;
-        case BLE_LL_EVENT_CONN_SPVN_TMO:
-            ble_ll_conn_spvn_timeout(ev->ev_arg);
-            break;
-        case BLE_LL_EVENT_CONN_EV_END:
-            ble_ll_conn_event_end(ev->ev_arg);
-            break;
-        default:
-            assert(0);
-            break;
-        }
+        os_eventq_run(&g_ble_ll_data.ll_evq);
     }
 }
 
@@ -1244,15 +1227,15 @@ ble_ll_init(void)
     STAILQ_INIT(&lldata->ll_rx_pkt_q);
 
     /* Initialize transmit (from host) and receive packet (from phy) event */
-    lldata->ll_rx_pkt_ev.ev_type = BLE_LL_EVENT_RX_PKT_IN;
-    lldata->ll_tx_pkt_ev.ev_type = BLE_LL_EVENT_TX_PKT_IN;
-    lldata->ll_dbuf_overflow_ev.ev_type = BLE_LL_EVENT_DBUF_OVERFLOW;
+    lldata->ll_rx_pkt_ev.ev_cb = ble_ll_event_rx_pkt;
+    lldata->ll_tx_pkt_ev.ev_cb = ble_ll_event_tx_pkt;
+    lldata->ll_dbuf_overflow_ev.ev_cb = ble_ll_event_dbuf_overflow;
 
     /* Initialize the HW error timer */
-    os_callout_func_init(&g_ble_ll_data.ll_hw_err_timer,
-                         &g_ble_ll_data.ll_evq,
-                         ble_ll_hw_err_timer_cb,
-                         NULL);
+    os_callout_init(&g_ble_ll_data.ll_hw_err_timer,
+                    &g_ble_ll_data.ll_evq,
+                    ble_ll_hw_err_timer_cb,
+                    NULL);
 
     /* Initialize wait for response timer */
     os_cputime_timer_init(&g_ble_ll_data.ll_wfr_timer, ble_ll_wfr_timer_exp,

http://git-wip-us.apache.org/repos/asf/incubator-mynewt-core/blob/cf38f1ff/net/nimble/controller/src/ble_ll_adv.c
----------------------------------------------------------------------
diff --git a/net/nimble/controller/src/ble_ll_adv.c b/net/nimble/controller/src/ble_ll_adv.c
index 856b8af..a4c59c6 100644
--- a/net/nimble/controller/src/ble_ll_adv.c
+++ b/net/nimble/controller/src/ble_ll_adv.c
@@ -104,6 +104,8 @@ struct ble_ll_adv_sm
 /* The advertising state machine global object */
 struct ble_ll_adv_sm g_ble_ll_adv_sm;
 
+static void ble_ll_adv_done(struct ble_ll_adv_sm *advsm);
+
 /*
  * Worst case time needed for scheduled advertising item. This is the longest
  * possible time to receive a scan request and send a scan response (with the
@@ -122,7 +124,6 @@ struct ble_ll_adv_sm g_ble_ll_adv_sm;
 #define BLE_LL_ADV_SCHED_MAX_USECS          (852)
 #define BLE_LL_ADV_DIRECT_SCHED_MAX_USECS   (502)
 
-
 #if (MYNEWT_VAL(BLE_LL_CFG_FEAT_LL_PRIVACY) == 1)
 /**
  * Called to change advertisers ADVA and INITA (for directed advertisements)
@@ -1194,7 +1195,7 @@ ble_ll_adv_rx_pkt_in(uint8_t ptype, uint8_t *rxbuf, struct ble_mbuf_hdr *hdr)
     }
 
     if (adv_event_over) {
-        ble_ll_adv_event_done(&g_ble_ll_adv_sm);
+        ble_ll_adv_done(&g_ble_ll_adv_sm);
     }
 }
 
@@ -1257,18 +1258,15 @@ ble_ll_adv_rx_isr_start(uint8_t pdu_type)
  *
  * @param arg Pointer to advertising state machine.
  */
-void
-ble_ll_adv_event_done(void *arg)
+static void
+ble_ll_adv_done(struct ble_ll_adv_sm *advsm)
 {
     uint8_t mask;
     uint8_t final_adv_chan;
     int32_t delta_t;
     uint32_t itvl;
     uint32_t start_time;
-    struct ble_ll_adv_sm *advsm;
 
-    /* Stop advertising event */
-    advsm = (struct ble_ll_adv_sm *)arg;
     assert(advsm->enabled);
 
     /* Remove the element from the schedule if it is still there. */
@@ -1377,6 +1375,12 @@ ble_ll_adv_event_done(void *arg)
     }
 }
 
+static void
+ble_ll_adv_event_done(struct os_event *ev)
+{
+    ble_ll_adv_done(ev->ev_arg);
+}
+
 /**
  * Checks if the controller can change the whitelist. If advertising is enabled
  * and is using the whitelist the controller is not allowed to change the
@@ -1511,7 +1515,7 @@ ble_ll_adv_init(void)
     advsm->adv_chanmask = BLE_HCI_ADV_CHANMASK_DEF;
 
     /* Initialize advertising tx done event */
-    advsm->adv_txdone_ev.ev_type = BLE_LL_EVENT_ADV_EV_DONE;
+    advsm->adv_txdone_ev.ev_cb = ble_ll_adv_event_done;
     advsm->adv_txdone_ev.ev_arg = advsm;
 }
 

http://git-wip-us.apache.org/repos/asf/incubator-mynewt-core/blob/cf38f1ff/net/nimble/controller/src/ble_ll_conn.c
----------------------------------------------------------------------
diff --git a/net/nimble/controller/src/ble_ll_conn.c b/net/nimble/controller/src/ble_ll_conn.c
index ab04e7f..ec61fa4 100644
--- a/net/nimble/controller/src/ble_ll_conn.c
+++ b/net/nimble/controller/src/ble_ll_conn.c
@@ -216,6 +216,9 @@ STATS_NAME_START(ble_ll_conn_stats)
     STATS_NAME(ble_ll_conn_stats, mic_failures)
 STATS_NAME_END(ble_ll_conn_stats)
 
+static void ble_ll_conn_spvn_timeout(struct os_event *ev);
+static void ble_ll_conn_event_end(struct os_event *ev);
+
 /**
  * Get the event buffer allocated to send the connection complete event
  * when we are initiating.
@@ -1300,11 +1303,11 @@ ble_ll_conn_can_send_next_pdu(struct ble_ll_conn_sm *connsm, uint32_t begtime)
  * @param arg
  */
 void
-ble_ll_conn_auth_pyld_timer_cb(void *arg)
+ble_ll_conn_auth_pyld_timer_cb(struct os_event *ev)
 {
     struct ble_ll_conn_sm *connsm;
 
-    connsm = (struct ble_ll_conn_sm *)arg;
+    connsm = (struct ble_ll_conn_sm *)ev->ev_arg;
     ble_ll_auth_pyld_tmo_event_send(connsm);
     ble_ll_ctrl_proc_start(connsm, BLE_LL_CTRL_PROC_LE_PING);
     ble_ll_conn_auth_pyld_timer_start(connsm);
@@ -1322,7 +1325,7 @@ ble_ll_conn_auth_pyld_timer_start(struct ble_ll_conn_sm *connsm)
 
     /* Timeout in is in 10 msec units */
     tmo = (int32_t)BLE_LL_CONN_AUTH_PYLD_OS_TMO(connsm->auth_pyld_tmo);
-    os_callout_reset(&connsm->auth_pyld_timer.cf_c, tmo);
+    os_callout_reset(&connsm->auth_pyld_timer, tmo);
 }
 #endif
 
@@ -1458,12 +1461,12 @@ ble_ll_conn_sm_new(struct ble_ll_conn_sm *connsm)
     /* Initialize event */
     connsm->conn_spvn_ev.ev_arg = connsm;
     connsm->conn_spvn_ev.ev_queued = 0;
-    connsm->conn_spvn_ev.ev_type = BLE_LL_EVENT_CONN_SPVN_TMO;
+    connsm->conn_spvn_ev.ev_cb = ble_ll_conn_spvn_timeout;
 
     /* Connection end event */
     connsm->conn_ev_end.ev_arg = connsm;
     connsm->conn_ev_end.ev_queued = 0;
-    connsm->conn_ev_end.ev_type = BLE_LL_EVENT_CONN_EV_END;
+    connsm->conn_ev_end.ev_cb = ble_ll_conn_event_end;
 
     /* Initialize transmit queue and ack/flow control elements */
     STAILQ_INIT(&connsm->conn_txq);
@@ -1498,10 +1501,10 @@ ble_ll_conn_sm_new(struct ble_ll_conn_sm *connsm)
 #if MYNEWT_VAL(BLE_LL_CFG_FEAT_LE_PING)
     connsm->auth_pyld_tmo = BLE_LL_CONN_DEF_AUTH_PYLD_TMO;
     CONN_F_LE_PING_SUPP(connsm) = 1;
-    os_callout_func_init(&connsm->auth_pyld_timer,
-                         &g_ble_ll_data.ll_evq,
-                         ble_ll_conn_auth_pyld_timer_cb,
-                         connsm);
+    os_callout_init(&connsm->auth_pyld_timer,
+                    &g_ble_ll_data.ll_evq,
+                    ble_ll_conn_auth_pyld_timer_cb,
+                    connsm);
 #endif
 
     /* Add to list of active connections */
@@ -1582,10 +1585,10 @@ ble_ll_conn_end(struct ble_ll_conn_sm *connsm, uint8_t ble_err)
     os_cputime_timer_stop(&connsm->conn_spvn_timer);
 
     /* Stop any control procedures that might be running */
-    os_callout_stop(&connsm->ctrl_proc_rsp_timer.cf_c);
+    os_callout_stop(&connsm->ctrl_proc_rsp_timer);
 
 #if MYNEWT_VAL(BLE_LL_CFG_FEAT_LE_PING)
-    os_callout_stop(&connsm->auth_pyld_timer.cf_c);
+    os_callout_stop(&connsm->auth_pyld_timer);
 #endif
 
     /* Remove from the active connection list */
@@ -1882,14 +1885,14 @@ ble_ll_conn_created(struct ble_ll_conn_sm *connsm, uint32_t endtime)
  * @param void *arg Pointer to connection state machine
  *
  */
-void
-ble_ll_conn_event_end(void *arg)
+static void
+ble_ll_conn_event_end(struct os_event *ev)
 {
     uint8_t ble_err;
     struct ble_ll_conn_sm *connsm;
 
     /* Better be a connection state machine! */
-    connsm = (struct ble_ll_conn_sm *)arg;
+    connsm = (struct ble_ll_conn_sm *)ev->ev_arg;
     assert(connsm);
 
     /* Check if we need to resume scanning */
@@ -2449,10 +2452,11 @@ ble_ll_conn_timeout(struct ble_ll_conn_sm *connsm, uint8_t ble_err)
  *
  * @param arg Pointer to connection state machine.
  */
-void
-ble_ll_conn_spvn_timeout(void *arg)
+static void
+ble_ll_conn_spvn_timeout(struct os_event *ev)
 {
-    ble_ll_conn_timeout((struct ble_ll_conn_sm *)arg, BLE_ERR_CONN_SPVN_TMO);
+    ble_ll_conn_timeout((struct ble_ll_conn_sm *)ev->ev_arg,
+                        BLE_ERR_CONN_SPVN_TMO);
 }
 
 /**

http://git-wip-us.apache.org/repos/asf/incubator-mynewt-core/blob/cf38f1ff/net/nimble/controller/src/ble_ll_conn_hci.c
----------------------------------------------------------------------
diff --git a/net/nimble/controller/src/ble_ll_conn_hci.c b/net/nimble/controller/src/ble_ll_conn_hci.c
index d961b90..0ce49f8 100644
--- a/net/nimble/controller/src/ble_ll_conn_hci.c
+++ b/net/nimble/controller/src/ble_ll_conn_hci.c
@@ -1182,7 +1182,7 @@ ble_ll_conn_hci_wr_auth_pyld_tmo(uint8_t *cmdbuf, uint8_t *rsp, uint8_t *rsplen)
         rc = BLE_ERR_INV_HCI_CMD_PARMS;
     } else {
         connsm->auth_pyld_tmo = tmo;
-        if (os_callout_queued(&connsm->auth_pyld_timer.cf_c)) {
+        if (os_callout_queued(&connsm->auth_pyld_timer)) {
             ble_ll_conn_auth_pyld_timer_start(connsm);
         }
     }

http://git-wip-us.apache.org/repos/asf/incubator-mynewt-core/blob/cf38f1ff/net/nimble/controller/src/ble_ll_conn_priv.h
----------------------------------------------------------------------
diff --git a/net/nimble/controller/src/ble_ll_conn_priv.h b/net/nimble/controller/src/ble_ll_conn_priv.h
index 9e393b5..f1abbdc 100644
--- a/net/nimble/controller/src/ble_ll_conn_priv.h
+++ b/net/nimble/controller/src/ble_ll_conn_priv.h
@@ -110,9 +110,7 @@ int ble_ll_conn_slave_start(uint8_t *rxbuf, uint32_t conn_req_end, uint8_t pat);
 void ble_ll_conn_module_init(void);
 void ble_ll_conn_set_global_chanmap(uint8_t num_used_chans, uint8_t *chanmap);
 void ble_ll_conn_module_reset(void);
-void ble_ll_conn_event_end(void *arg);
 void ble_ll_conn_tx_pkt_in(struct os_mbuf *om, uint16_t handle, uint16_t len);
-void ble_ll_conn_spvn_timeout(void *arg);
 int ble_ll_conn_rx_isr_start(struct ble_mbuf_hdr *rxhdr, uint32_t aa);
 int ble_ll_conn_rx_isr_end(uint8_t *rxbuf, struct ble_mbuf_hdr *rxhdr);
 void ble_ll_conn_rx_data_pdu(struct os_mbuf *rxpdu, struct ble_mbuf_hdr *hdr);

http://git-wip-us.apache.org/repos/asf/incubator-mynewt-core/blob/cf38f1ff/net/nimble/controller/src/ble_ll_ctrl.c
----------------------------------------------------------------------
diff --git a/net/nimble/controller/src/ble_ll_ctrl.c b/net/nimble/controller/src/ble_ll_ctrl.c
index 8e79f10..4231e40 100644
--- a/net/nimble/controller/src/ble_ll_ctrl.c
+++ b/net/nimble/controller/src/ble_ll_ctrl.c
@@ -308,7 +308,7 @@ ble_ll_ctrl_proc_unk_rsp(struct ble_ll_conn_sm *connsm, uint8_t *dptr)
     case BLE_LL_CTRL_PING_REQ:
         CONN_F_LE_PING_SUPP(connsm) = 0;
 #if (MYNEWT_VAL(BLE_LL_CFG_FEAT_LE_PING) == 1)
-        os_callout_stop(&connsm->auth_pyld_timer.cf_c);
+        os_callout_stop(&connsm->auth_pyld_timer);
 #endif
         ctrl_proc = BLE_LL_CTRL_PROC_LE_PING;
         break;
@@ -1232,10 +1232,11 @@ ble_ll_ctrl_rx_chanmap_req(struct ble_ll_conn_sm *connsm, uint8_t *dptr)
  * @param arg Pointer to connection state machine.
  */
 void
-ble_ll_ctrl_proc_rsp_timer_cb(void *arg)
+ble_ll_ctrl_proc_rsp_timer_cb(struct os_event *ev)
 {
     /* Control procedure has timed out. Kill the connection */
-    ble_ll_conn_timeout((struct ble_ll_conn_sm *)arg, BLE_ERR_LMP_LL_RSP_TMO);
+    ble_ll_conn_timeout((struct ble_ll_conn_sm *)ev->ev_arg,
+                        BLE_ERR_LMP_LL_RSP_TMO);
 }
 
 /**
@@ -1365,7 +1366,7 @@ void
 ble_ll_ctrl_proc_stop(struct ble_ll_conn_sm *connsm, int ctrl_proc)
 {
     if (connsm->cur_ctrl_proc == ctrl_proc) {
-        os_callout_stop(&connsm->ctrl_proc_rsp_timer.cf_c);
+        os_callout_stop(&connsm->ctrl_proc_rsp_timer);
         connsm->cur_ctrl_proc = BLE_LL_CTRL_PROC_IDLE;
     }
     CLR_PENDING_CTRL_PROC(connsm, ctrl_proc);
@@ -1428,13 +1429,13 @@ ble_ll_ctrl_proc_start(struct ble_ll_conn_sm *connsm, int ctrl_proc)
 
             /* Initialize the procedure response timeout */
             if (ctrl_proc != BLE_LL_CTRL_PROC_CHAN_MAP_UPD) {
-                os_callout_func_init(&connsm->ctrl_proc_rsp_timer,
-                                     &g_ble_ll_data.ll_evq,
-                                     ble_ll_ctrl_proc_rsp_timer_cb,
-                                     connsm);
+                os_callout_init(&connsm->ctrl_proc_rsp_timer,
+                                &g_ble_ll_data.ll_evq,
+                                ble_ll_ctrl_proc_rsp_timer_cb,
+                                connsm);
 
                 /* Re-start timer. Control procedure timeout is 40 seconds */
-                os_callout_reset(&connsm->ctrl_proc_rsp_timer.cf_c,
+                os_callout_reset(&connsm->ctrl_proc_rsp_timer,
                                  OS_TICKS_PER_SEC * BLE_LL_CTRL_PROC_TIMEOUT);
             }
         }

http://git-wip-us.apache.org/repos/asf/incubator-mynewt-core/blob/cf38f1ff/net/nimble/controller/src/ble_ll_hci.c
----------------------------------------------------------------------
diff --git a/net/nimble/controller/src/ble_ll_hci.c b/net/nimble/controller/src/ble_ll_hci.c
index f3624c1..7b549ad 100644
--- a/net/nimble/controller/src/ble_ll_hci.c
+++ b/net/nimble/controller/src/ble_ll_hci.c
@@ -34,6 +34,8 @@
 #include "controller/ble_ll_resolv.h"
 #include "ble_ll_conn_priv.h"
 
+static void ble_ll_hci_cmd_proc(struct os_event *ev);
+
 /* LE event mask */
 static uint8_t g_ble_ll_hci_le_event_mask[BLE_HCI_SET_LE_EVENT_MASK_LEN];
 static uint8_t g_ble_ll_hci_event_mask[BLE_HCI_SET_EVENT_MASK_LEN];
@@ -906,7 +908,7 @@ ble_ll_hci_status_params_cmd_proc(uint8_t *cmdbuf, uint16_t ocf, uint8_t *rsplen
  *
  * @param ev Pointer to os event containing a pointer to command buffer
  */
-void
+static void
 ble_ll_hci_cmd_proc(struct os_event *ev)
 {
     int rc;
@@ -1009,7 +1011,7 @@ ble_ll_hci_cmd_rx(uint8_t *cmd, void *arg)
 
     /* Fill out the event and post to Link Layer */
     ev->ev_queued = 0;
-    ev->ev_type = BLE_LL_EVENT_HCI_CMD;
+    ev->ev_cb = ble_ll_hci_cmd_proc;
     ev->ev_arg = cmd;
     os_eventq_put(&g_ble_ll_data.ll_evq, ev);
 

http://git-wip-us.apache.org/repos/asf/incubator-mynewt-core/blob/cf38f1ff/net/nimble/controller/src/ble_ll_resolv.c
----------------------------------------------------------------------
diff --git a/net/nimble/controller/src/ble_ll_resolv.c b/net/nimble/controller/src/ble_ll_resolv.c
index 7fb5859..975f271 100644
--- a/net/nimble/controller/src/ble_ll_resolv.c
+++ b/net/nimble/controller/src/ble_ll_resolv.c
@@ -38,7 +38,7 @@ struct ble_ll_resolv_data
     uint8_t rl_size;
     uint8_t rl_cnt;
     uint32_t rpa_tmo;
-    struct os_callout_func rpa_timer;
+    struct os_callout rpa_timer;
 };
 struct ble_ll_resolv_data g_ble_ll_resolv_data;
 
@@ -70,11 +70,9 @@ ble_ll_resolv_list_chg_allowed(void)
 /**
  * Called when the Resolvable private address timer expires. This timer
  * is used to regenerate local RPA's in the resolving list.
- *
- * @param arg
  */
 void
-ble_ll_resolv_rpa_timer_cb(void *arg)
+ble_ll_resolv_rpa_timer_cb(struct os_event *ev)
 {
     int i;
     os_sr_t sr;
@@ -89,7 +87,7 @@ ble_ll_resolv_rpa_timer_cb(void *arg)
         OS_EXIT_CRITICAL(sr);
         ++rl;
     }
-    os_callout_reset(&g_ble_ll_resolv_data.rpa_timer.cf_c,
+    os_callout_reset(&g_ble_ll_resolv_data.rpa_timer,
                      (int32_t)g_ble_ll_resolv_data.rpa_tmo);
 }
 
@@ -319,9 +317,9 @@ ble_ll_resolv_enable_cmd(uint8_t *cmdbuf)
             if ((enabled ^ g_ble_ll_resolv_data.addr_res_enabled) != 0) {
                 if (enabled) {
                     tmo = (int32_t)g_ble_ll_resolv_data.rpa_tmo;
-                    os_callout_reset(&g_ble_ll_resolv_data.rpa_timer.cf_c, tmo);
+                    os_callout_reset(&g_ble_ll_resolv_data.rpa_timer, tmo);
                 } else {
-                    os_callout_stop(&g_ble_ll_resolv_data.rpa_timer.cf_c);
+                    os_callout_stop(&g_ble_ll_resolv_data.rpa_timer);
                 }
                 g_ble_ll_resolv_data.addr_res_enabled = enabled;
             }
@@ -363,7 +361,7 @@ ble_ll_resolv_set_rpa_tmo(uint8_t *cmdbuf)
     if ((tmo_secs > 0) && (tmo_secs <= 0xA1B8)) {
         g_ble_ll_resolv_data.rpa_tmo = tmo_secs * OS_TICKS_PER_SEC;
         if (g_ble_ll_resolv_data.addr_res_enabled) {
-            os_callout_reset(&g_ble_ll_resolv_data.rpa_timer.cf_c,
+            os_callout_reset(&g_ble_ll_resolv_data.rpa_timer,
                              (int32_t)g_ble_ll_resolv_data.rpa_tmo);
         }
     } else {
@@ -543,7 +541,7 @@ void
 ble_ll_resolv_list_reset(void)
 {
     g_ble_ll_resolv_data.addr_res_enabled = 0;
-    os_callout_stop(&g_ble_ll_resolv_data.rpa_timer.cf_c);
+    os_callout_stop(&g_ble_ll_resolv_data.rpa_timer);
     ble_ll_resolv_list_clr();
     ble_ll_resolv_init();
 }
@@ -562,10 +560,10 @@ ble_ll_resolv_init(void)
     }
     g_ble_ll_resolv_data.rl_size = hw_size;
 
-    os_callout_func_init(&g_ble_ll_resolv_data.rpa_timer,
-                         &g_ble_ll_data.ll_evq,
-                         ble_ll_resolv_rpa_timer_cb,
-                         NULL);
+    os_callout_init(&g_ble_ll_resolv_data.rpa_timer,
+                    &g_ble_ll_data.ll_evq,
+                    ble_ll_resolv_rpa_timer_cb,
+                    NULL);
 }
 
 #endif  /* if MYNEWT_VAL(BLE_LL_CFG_FEAT_LL_PRIVACY) == 1 */

http://git-wip-us.apache.org/repos/asf/incubator-mynewt-core/blob/cf38f1ff/net/nimble/controller/src/ble_ll_scan.c
----------------------------------------------------------------------
diff --git a/net/nimble/controller/src/ble_ll_scan.c b/net/nimble/controller/src/ble_ll_scan.c
index 808d090..01b8b1b 100644
--- a/net/nimble/controller/src/ble_ll_scan.c
+++ b/net/nimble/controller/src/ble_ll_scan.c
@@ -744,8 +744,8 @@ ble_ll_scan_sm_start(struct ble_ll_scan_sm *scansm)
  *
  * @param arg
  */
-void
-ble_ll_scan_event_proc(void *arg)
+static void
+ble_ll_scan_event_proc(struct os_event *ev)
 {
     os_sr_t sr;
     int rxstate;
@@ -763,7 +763,7 @@ ble_ll_scan_event_proc(void *arg)
      * Get the scanning state machine. If not enabled (this is possible), just
      * leave and do nothing (just make sure timer is stopped).
      */
-    scansm = (struct ble_ll_scan_sm *)arg;
+    scansm = (struct ble_ll_scan_sm *)ev->ev_arg;
     if (!scansm->scan_enabled) {
         os_cputime_timer_stop(&scansm->scan_timer);
         return;
@@ -1473,7 +1473,7 @@ ble_ll_scan_init(void)
     memset(scansm, 0, sizeof(struct ble_ll_scan_sm));
 
     /* Initialize scanning window end event */
-    scansm->scan_sched_ev.ev_type = BLE_LL_EVENT_SCAN;
+    scansm->scan_sched_ev.ev_cb = ble_ll_scan_event_proc;
     scansm->scan_sched_ev.ev_arg = scansm;
 
     /* Set all non-zero default parameters */