You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@mynewt.apache.org by ja...@apache.org on 2017/04/26 22:41:12 UTC

[24/50] [abbrv] incubator-mynewt-core git commit: MYNEWT-736 NimBLE - UART xport can't send multibuf

MYNEWT-736 NimBLE - UART xport can't send multibuf

The UART transport assumes outgoing ACL data packets consist of a single
mbuf. If the chain contains multiple buffers, the later part of the
outgoing packet consists of all zeros.


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

Branch: refs/heads/bluetooth5
Commit: 7669e9715e9eee5cccea0074208e6915258d3d3a
Parents: fd7bf2b
Author: Christopher Collins <cc...@apache.org>
Authored: Wed Apr 19 20:13:59 2017 -0700
Committer: Christopher Collins <cc...@apache.org>
Committed: Wed Apr 19 20:13:59 2017 -0700

----------------------------------------------------------------------
 net/nimble/transport/uart/src/ble_hci_uart.c | 12 ++++++++++--
 1 file changed, 10 insertions(+), 2 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/incubator-mynewt-core/blob/7669e971/net/nimble/transport/uart/src/ble_hci_uart.c
----------------------------------------------------------------------
diff --git a/net/nimble/transport/uart/src/ble_hci_uart.c b/net/nimble/transport/uart/src/ble_hci_uart.c
index 6584112..9de4ad7 100755
--- a/net/nimble/transport/uart/src/ble_hci_uart.c
+++ b/net/nimble/transport/uart/src/ble_hci_uart.c
@@ -275,6 +275,7 @@ ble_hci_uart_tx_pkt_type(void)
 static int
 ble_hci_uart_tx_char(void *arg)
 {
+    uint8_t u8;
     int rc = -1;
 
     switch (ble_hci_uart_state.tx_type) {
@@ -293,12 +294,19 @@ ble_hci_uart_tx_char(void *arg)
         break;
 
     case BLE_HCI_UART_H4_ACL:
-        rc = *OS_MBUF_DATA(ble_hci_uart_state.tx_acl, uint8_t *);
+        /* Copy the first unsent byte from the tx buffer and remove it from the
+         * source.
+         */
+        os_mbuf_copydata(ble_hci_uart_state.tx_acl, 0, 1, &u8);
         os_mbuf_adj(ble_hci_uart_state.tx_acl, 1);
-        if (!OS_MBUF_PKTLEN(ble_hci_uart_state.tx_acl)) {
+
+        /* Free the tx buffer if this is the last byte to send. */
+        if (OS_MBUF_PKTLEN(ble_hci_uart_state.tx_acl) == 0) {
             os_mbuf_free_chain(ble_hci_uart_state.tx_acl);
             ble_hci_uart_state.tx_type = BLE_HCI_UART_H4_NONE;
         }
+
+        rc = u8;
         break;
     }