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 2015/11/09 21:58:43 UTC

incubator-mynewt-larva git commit: Merge host_hci task into ble_hs task.

Repository: incubator-mynewt-larva
Updated Branches:
  refs/heads/master 98a83fa71 -> 5113d5f92


Merge host_hci task into ble_hs task.


Project: http://git-wip-us.apache.org/repos/asf/incubator-mynewt-larva/repo
Commit: http://git-wip-us.apache.org/repos/asf/incubator-mynewt-larva/commit/5113d5f9
Tree: http://git-wip-us.apache.org/repos/asf/incubator-mynewt-larva/tree/5113d5f9
Diff: http://git-wip-us.apache.org/repos/asf/incubator-mynewt-larva/diff/5113d5f9

Branch: refs/heads/master
Commit: 5113d5f9236e3d9d95ceb21830266d1fbb726efc
Parents: 98a83fa
Author: Christopher Collins <cc...@gmail.com>
Authored: Mon Nov 9 12:55:51 2015 -0800
Committer: Christopher Collins <cc...@gmail.com>
Committed: Mon Nov 9 12:55:51 2015 -0800

----------------------------------------------------------------------
 net/nimble/host/include/host/ble_hs.h      |  6 +--
 net/nimble/host/include/host/host_hci.h    |  3 +-
 net/nimble/host/src/ble_hs.c               | 69 +++++++++++++++++--------
 net/nimble/host/src/host_hci.c             | 48 -----------------
 net/nimble/host/src/test/ble_hs_att_test.c |  4 +-
 net/nimble/host/src/test/ble_l2cap_test.c  |  2 +-
 project/bletest/src/main.c                 |  5 +-
 project/host_test/src/main.c               |  4 +-
 8 files changed, 60 insertions(+), 81 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/incubator-mynewt-larva/blob/5113d5f9/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 f9a3a94..e16bccd 100644
--- a/net/nimble/host/include/host/ble_hs.h
+++ b/net/nimble/host/include/host/ble_hs.h
@@ -23,10 +23,10 @@ extern int ble_host_listen_enabled;
 
 /** --- */
 
-void ble_host_task_handler(void *arg);
+void ble_hs_task_handler(void *arg);
 int ble_host_send_data_connectionless(uint16_t con_handle, uint16_t cid,
                                       uint8_t *data, uint16_t len);
-int ble_host_poll(void);
-int host_init(void);
+int ble_hs_poll(void);
+int ble_hs_init(void);
 
 #endif /* _BLE_HOST_H */

http://git-wip-us.apache.org/repos/asf/incubator-mynewt-larva/blob/5113d5f9/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 c3ccb90..aa080f2 100644
--- a/net/nimble/host/include/host/host_hci.h
+++ b/net/nimble/host/include/host/host_hci.h
@@ -19,8 +19,7 @@
 
 #include "nimble/hci_common.h"
 
-int host_hci_init(void);
-void host_hci_task(void *arg);
+void host_hci_event_proc(struct os_event *ev);
 int host_hci_cmd_le_set_scan_rsp_data(uint8_t *data, uint8_t len);
 int host_hci_cmd_le_set_adv_data(uint8_t *data, uint8_t len);
 int host_hci_cmd_le_set_adv_params(struct hci_adv_params *adv);

http://git-wip-us.apache.org/repos/asf/incubator-mynewt-larva/blob/5113d5f9/net/nimble/host/src/ble_hs.c
----------------------------------------------------------------------
diff --git a/net/nimble/host/src/ble_hs.c b/net/nimble/host/src/ble_hs.c
index af02ae7..d929491 100644
--- a/net/nimble/host/src/ble_hs.c
+++ b/net/nimble/host/src/ble_hs.c
@@ -16,6 +16,7 @@
 
 #include <assert.h>
 #include "os/os.h"
+#include "host/host_hci.h"
 #include "host/ble_hs.h"
 #include "ble_hs_att.h"
 #include "ble_hs_conn.h"
@@ -23,11 +24,24 @@
 #include "ble_hs_itf.h"
 #endif
 
+#define HCI_CMD_BUFS        (8)
+#define HCI_CMD_BUF_SIZE    (260)       /* XXX: temporary, Fix later */
+struct os_mempool g_hci_cmd_pool;
+os_membuf_t g_hci_cmd_buf[OS_MEMPOOL_SIZE(HCI_CMD_BUFS, HCI_CMD_BUF_SIZE)];
 
-int ble_host_listen_enabled;
+/* XXX: this might be transport layer*/
+#define HCI_NUM_OS_EVENTS       (32)
+#define HCI_OS_EVENT_BUF_SIZE   (sizeof(struct os_event))
+
+struct os_mempool g_hci_os_event_pool;
+os_membuf_t g_hci_os_event_buf[OS_MEMPOOL_SIZE(HCI_NUM_OS_EVENTS,
+                                               HCI_OS_EVENT_BUF_SIZE)];
 
-static struct os_eventq host_task_evq;
-static struct os_callout ble_host_task_timer;
+/* Host HCI Task Events */
+struct os_eventq g_ble_host_hci_evq;
+#define BLE_HOST_HCI_EVENT_CTLR_EVENT   (OS_EVENT_T_PERUSER)
+
+int ble_host_listen_enabled;
 
 int
 ble_host_send_data_connectionless(uint16_t con_handle, uint16_t cid,
@@ -48,7 +62,7 @@ ble_host_send_data_connectionless(uint16_t con_handle, uint16_t cid,
  * XXX: This is only here for testing.
  */
 int 
-ble_host_poll(void)
+ble_hs_poll(void)
 {
     int rc;
 
@@ -62,25 +76,26 @@ ble_host_poll(void)
 }
 
 void
-ble_host_task_handler(void *arg)
+ble_hs_task_handler(void *arg)
 {
     struct os_event *ev;
+    struct os_callout_func *cf;
 
-    os_callout_reset(&ble_host_task_timer, 50);
-
-    /**
-     * How do we decide what channels to listen on for data?  This must be 
-     * configured to the host task.  Maintain a list of channels to 
-     *
-     */
     while (1) {
-        ev = os_eventq_get(&host_task_evq);
+        ev = os_eventq_get(&g_ble_host_hci_evq);
         switch (ev->ev_type) {
-            case OS_EVENT_T_TIMER:
-                /* Poll the attribute channel */
-                /* Reset callout, wakeup every 50ms */
-                os_callout_reset(&ble_host_task_timer, 50);
-                break;
+        case OS_EVENT_T_TIMER:
+            cf = (struct os_callout_func *)ev;
+            assert(cf->cf_func);
+            cf->cf_func(cf->cf_arg);
+            break;
+        case BLE_HOST_HCI_EVENT_CTLR_EVENT:
+            /* Process HCI event from controller */
+            host_hci_event_proc(ev);
+            break;
+        default:
+            assert(0);
+            break;
         }
     }
 }
@@ -89,12 +104,24 @@ ble_host_task_handler(void *arg)
  * Initialize the host portion of the BLE stack.
  */
 int
-host_init(void)
+ble_hs_init(void)
 {
     int rc;
 
-    os_eventq_init(&host_task_evq);
-    os_callout_init(&ble_host_task_timer, &host_task_evq, NULL);
+    /* Create memory pool of command buffers */
+    rc = os_mempool_init(&g_hci_cmd_pool, HCI_CMD_BUFS, HCI_CMD_BUF_SIZE,
+                         &g_hci_cmd_buf, "HCICmdPool");
+    assert(rc == 0);
+
+    /* XXX: really only needed by the transport */
+    /* Create memory pool of OS events */
+    rc = os_mempool_init(&g_hci_os_event_pool, HCI_NUM_OS_EVENTS,
+                         HCI_OS_EVENT_BUF_SIZE, &g_hci_os_event_buf,
+                         "HCIOsEventPool");
+    assert(rc == 0);
+
+    /* Initialize eventq */
+    os_eventq_init(&g_ble_host_hci_evq);
 
     rc = ble_hs_conn_init();
     if (rc != 0) {

http://git-wip-us.apache.org/repos/asf/incubator-mynewt-larva/blob/5113d5f9/net/nimble/host/src/host_hci.c
----------------------------------------------------------------------
diff --git a/net/nimble/host/src/host_hci.c b/net/nimble/host/src/host_hci.c
index 5a91336..04917d2 100644
--- a/net/nimble/host/src/host_hci.c
+++ b/net/nimble/host/src/host_hci.c
@@ -412,31 +412,6 @@ ble_hci_transport_ctlr_event_send(uint8_t *hci_ev)
     return 0;
 }
 
-void
-host_hci_task(void *arg)
-{
-    struct os_event *ev;
-    struct os_callout_func *cf;
-
-    while (1) {
-        ev = os_eventq_get(&g_ble_host_hci_evq);
-        switch (ev->ev_type) {
-        case OS_EVENT_T_TIMER:
-            cf = (struct os_callout_func *)ev;
-            assert(cf->cf_func);
-            cf->cf_func(cf->cf_arg);
-            break;
-        case BLE_HOST_HCI_EVENT_CTLR_EVENT:
-            /* Process HCI event from controller */
-            host_hci_event_proc(ev);
-            break;
-        default:
-            assert(0);
-            break;
-        }
-    }
-}
-
 static int
 host_hci_data_parse_hdr(void *pkt, uint16_t len, struct hci_data_hdr *hdr)
 {
@@ -491,26 +466,3 @@ host_hci_data_rx(void *pkt, uint16_t len)
 
     return 0;
 }
-
-int
-host_hci_init(void)
-{
-    int rc;
-
-    /* Create memory pool of command buffers */
-    rc = os_mempool_init(&g_hci_cmd_pool, HCI_CMD_BUFS, HCI_CMD_BUF_SIZE, 
-                         &g_hci_cmd_buf, "HCICmdPool");
-    assert(rc == 0);
-
-    /* XXX: really only needed by the transport */
-    /* Create memory pool of OS events */
-    rc = os_mempool_init(&g_hci_os_event_pool, HCI_NUM_OS_EVENTS, 
-                         HCI_OS_EVENT_BUF_SIZE, &g_hci_os_event_buf, 
-                         "HCIOsEventPool");
-    assert(rc == 0);
-
-    /* Initialize eventq */
-    os_eventq_init(&g_ble_host_hci_evq);
-
-    return rc;
-}

http://git-wip-us.apache.org/repos/asf/incubator-mynewt-larva/blob/5113d5f9/net/nimble/host/src/test/ble_hs_att_test.c
----------------------------------------------------------------------
diff --git a/net/nimble/host/src/test/ble_hs_att_test.c b/net/nimble/host/src/test/ble_hs_att_test.c
index 4717dee..c325f73 100644
--- a/net/nimble/host/src/test/ble_hs_att_test.c
+++ b/net/nimble/host/src/test/ble_hs_att_test.c
@@ -144,7 +144,7 @@ TEST_CASE(ble_hs_att_test_read)
     uint8_t uuid[16] = {0};
     int rc;
 
-    rc = host_init();
+    rc = ble_hs_init();
     TEST_ASSERT_FATAL(rc == 0);
 
     conn = ble_hs_conn_alloc();
@@ -206,7 +206,7 @@ TEST_CASE(ble_hs_att_test_write)
     uint8_t uuid[16] = {0};
     int rc;
 
-    rc = host_init();
+    rc = ble_hs_init();
     TEST_ASSERT_FATAL(rc == 0);
 
     conn = ble_hs_conn_alloc();

http://git-wip-us.apache.org/repos/asf/incubator-mynewt-larva/blob/5113d5f9/net/nimble/host/src/test/ble_l2cap_test.c
----------------------------------------------------------------------
diff --git a/net/nimble/host/src/test/ble_l2cap_test.c b/net/nimble/host/src/test/ble_l2cap_test.c
index e167095..26015fa 100644
--- a/net/nimble/host/src/test/ble_l2cap_test.c
+++ b/net/nimble/host/src/test/ble_l2cap_test.c
@@ -62,7 +62,7 @@ TEST_SUITE(l2cap_gen)
 {
     int rc;
 
-    rc = host_init();
+    rc = ble_hs_init();
     TEST_ASSERT_FATAL(rc == 0);
 
     l2cap_test_bad_header();

http://git-wip-us.apache.org/repos/asf/incubator-mynewt-larva/blob/5113d5f9/project/bletest/src/main.c
----------------------------------------------------------------------
diff --git a/project/bletest/src/main.c b/project/bletest/src/main.c
index 934a625..8e7daeb 100755
--- a/project/bletest/src/main.c
+++ b/project/bletest/src/main.c
@@ -25,6 +25,7 @@
 /* BLE */
 #include "nimble/ble.h"
 #include "host/host_hci.h"
+#include "host/ble_hs.h"
 #include "controller/ble_ll.h"
 
 /* Init all tasks */
@@ -226,7 +227,7 @@ host_task_handler(void *arg)
     assert(rc == 0);
 
     /* Initialize host HCI */
-    host_hci_init();
+    ble_hs_init();
 
     /* Initialize the BLE LL */
     ble_ll_init();
@@ -249,7 +250,7 @@ host_task_handler(void *arg)
     console_printf("Nimble stack initialized");
 
     /* Call the host hci task */
-    host_hci_task(arg);
+    ble_hs_task_handler(arg);
 }
 
 void

http://git-wip-us.apache.org/repos/asf/incubator-mynewt-larva/blob/5113d5f9/project/host_test/src/main.c
----------------------------------------------------------------------
diff --git a/project/host_test/src/main.c b/project/host_test/src/main.c
index 846a3f7..9e4b9ed 100755
--- a/project/host_test/src/main.c
+++ b/project/host_test/src/main.c
@@ -32,7 +32,7 @@ host_test_task_handler(void *arg)
 {
     int rc;
 
-    host_init();
+    ble_hs_init();
 
     while (1) {
         os_time_delay(1000);
@@ -40,7 +40,7 @@ host_test_task_handler(void *arg)
             rc = ble_host_send_data_connectionless(1, 4, (uint8_t *)"BLAH", 4);
             printf("ble_host_send_data_connectionless(); rc=%d\n", rc);
         } else {
-            ble_host_poll();
+            ble_hs_poll();
         }
     }
 }