You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@mynewt.apache.org by st...@apache.org on 2016/08/01 04:59:24 UTC

[07/16] incubator-mynewt-core git commit: ble apps - Update for latest NimBLE host API.

ble apps - Update for latest NimBLE host API.


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

Branch: refs/heads/sterly_refactor
Commit: ee4eaac5a936abb7db6927b1eb75dde9b75cb11d
Parents: 39bc059
Author: Christopher Collins <cc...@apache.org>
Authored: Wed Jul 27 17:41:50 2016 -0700
Committer: Sterling Hughes <st...@apache.org>
Committed: Sun Jul 31 21:58:57 2016 -0700

----------------------------------------------------------------------
 apps/blehci/src/main.c     | 33 +++++++++++++--------------------
 apps/bletiny/src/bletiny.h |  6 +++---
 apps/bletiny/src/cmd.c     |  9 ++++++---
 apps/bletiny/src/main.c    |  6 +++---
 4 files changed, 25 insertions(+), 29 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/incubator-mynewt-core/blob/ee4eaac5/apps/blehci/src/main.c
----------------------------------------------------------------------
diff --git a/apps/blehci/src/main.c b/apps/blehci/src/main.c
index 3ec6bdb..09fb456 100755
--- a/apps/blehci/src/main.c
+++ b/apps/blehci/src/main.c
@@ -109,35 +109,28 @@ static struct {
 } hci;
 
 int
-ble_hs_rx_data(struct os_mbuf **om)
+ble_hs_rx_data(struct os_mbuf *om)
 {
     struct os_event *ev;
     os_sr_t sr;
-    int rc;
 
     ev = os_memblock_get(&g_hci_os_event_pool);
-    if (ev != NULL) {
-        ev->ev_type = BLE_HOST_HCI_EVENT_CTLR_DATA;
-        ev->ev_arg = *om;
-        ev->ev_queued = 1;
-
-        *om = NULL;
-
-        OS_ENTER_CRITICAL(sr);
-        STAILQ_INSERT_TAIL(&hci.rx_pkts, ev, ev_next);
-        OS_EXIT_CRITICAL(sr);
+    if (!ev) {
+        os_mbuf_free_chain(om);
+        return -1;
+    }
 
-        hal_uart_start_tx(HCI_UART);
+    ev->ev_type = BLE_HOST_HCI_EVENT_CTLR_DATA;
+    ev->ev_arg = om;
+    ev->ev_queued = 1;
 
-        rc = 0;
-    } else {
-        rc = -1;
-    }
+    OS_ENTER_CRITICAL(sr);
+    STAILQ_INSERT_TAIL(&hci.rx_pkts, ev, ev_next);
+    OS_EXIT_CRITICAL(sr);
 
-    /* Free the mbuf if we weren't able to enqueue it. */
-    os_mbuf_free_chain(*om);
+    hal_uart_start_tx(HCI_UART);
 
-    return rc;
+    return 0;
 }
 
 int

http://git-wip-us.apache.org/repos/asf/incubator-mynewt-core/blob/ee4eaac5/apps/bletiny/src/bletiny.h
----------------------------------------------------------------------
diff --git a/apps/bletiny/src/bletiny.h b/apps/bletiny/src/bletiny.h
index c744edb..e24f0f0 100644
--- a/apps/bletiny/src/bletiny.h
+++ b/apps/bletiny/src/bletiny.h
@@ -140,11 +140,11 @@ int bletiny_read_by_uuid(uint16_t conn_handle, uint16_t start_handle,
 int bletiny_read_mult(uint16_t conn_handle, uint16_t *attr_handles,
                        int num_attr_handles);
 int bletiny_write(uint16_t conn_handle, uint16_t attr_handle,
-                  struct os_mbuf **om);
+                  struct os_mbuf *om);
 int bletiny_write_no_rsp(uint16_t conn_handle, uint16_t attr_handle,
-                         struct os_mbuf **om);
+                         struct os_mbuf *om);
 int bletiny_write_long(uint16_t conn_handle, uint16_t attr_handle,
-                       struct os_mbuf **om);
+                       struct os_mbuf *om);
 int bletiny_write_reliable(uint16_t conn_handle,
                            struct ble_gatt_attr *attrs, int num_attrs);
 int bletiny_adv_start(uint8_t own_addr_type, uint8_t peer_addr_type,

http://git-wip-us.apache.org/repos/asf/incubator-mynewt-core/blob/ee4eaac5/apps/bletiny/src/cmd.c
----------------------------------------------------------------------
diff --git a/apps/bletiny/src/cmd.c b/apps/bletiny/src/cmd.c
index 7671253..1d133da 100644
--- a/apps/bletiny/src/cmd.c
+++ b/apps/bletiny/src/cmd.c
@@ -1892,17 +1892,20 @@ cmd_write(int argc, char **argv)
             rc = -EINVAL;
             goto done;
         }
-        rc = bletiny_write_no_rsp(conn_handle, attrs[0].handle, &attrs[0].om);
+        rc = bletiny_write_no_rsp(conn_handle, attrs[0].handle, attrs[0].om);
+        attrs[0].om = NULL;
     } else if (is_long) {
         if (num_attrs != 1) {
             rc = -EINVAL;
             goto done;
         }
-        rc = bletiny_write_long(conn_handle, attrs[0].handle, &attrs[0].om);
+        rc = bletiny_write_long(conn_handle, attrs[0].handle, attrs[0].om);
+        attrs[0].om = NULL;
     } else if (num_attrs > 1) {
         rc = bletiny_write_reliable(conn_handle, attrs, num_attrs);
     } else if (num_attrs == 1) {
-        rc = bletiny_write(conn_handle, attrs[0].handle, &attrs[0].om);
+        rc = bletiny_write(conn_handle, attrs[0].handle, attrs[0].om);
+        attrs[0].om = NULL;
     } else {
         rc = -EINVAL;
     }

http://git-wip-us.apache.org/repos/asf/incubator-mynewt-core/blob/ee4eaac5/apps/bletiny/src/main.c
----------------------------------------------------------------------
diff --git a/apps/bletiny/src/main.c b/apps/bletiny/src/main.c
index 50084c1..f5c57ba 100755
--- a/apps/bletiny/src/main.c
+++ b/apps/bletiny/src/main.c
@@ -1250,7 +1250,7 @@ bletiny_read_mult(uint16_t conn_handle, uint16_t *attr_handles,
 }
 
 int
-bletiny_write(uint16_t conn_handle, uint16_t attr_handle, struct os_mbuf **om)
+bletiny_write(uint16_t conn_handle, uint16_t attr_handle, struct os_mbuf *om)
 {
     int rc;
 
@@ -1266,7 +1266,7 @@ bletiny_write(uint16_t conn_handle, uint16_t attr_handle, struct os_mbuf **om)
 
 int
 bletiny_write_no_rsp(uint16_t conn_handle, uint16_t attr_handle,
-                     struct os_mbuf **om)
+                     struct os_mbuf *om)
 {
     int rc;
 
@@ -1277,7 +1277,7 @@ bletiny_write_no_rsp(uint16_t conn_handle, uint16_t attr_handle,
 
 int
 bletiny_write_long(uint16_t conn_handle, uint16_t attr_handle,
-                   struct os_mbuf **om)
+                   struct os_mbuf *om)
 {
     int rc;