You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@mynewt.apache.org by GitBox <gi...@apache.org> on 2022/06/14 20:48:53 UTC

[GitHub] [mynewt-nimble] kasjer commented on a diff in pull request #1276: Properly accumulate full ACL packet before sending to BLE controller

kasjer commented on code in PR #1276:
URL: https://github.com/apache/mynewt-nimble/pull/1276#discussion_r897305306


##########
nimble/transport/apollo3/src/apollo3_ble_hci.c:
##########
@@ -40,10 +40,10 @@ typedef enum {
 /* Structure for holding outgoing HCI packets. */
 typedef struct {
     uint32_t len;
-    uint32_t data[MYNEWT_VAL(BLE_TRANSPORT_APOLLO3_MAX_TX_PACKET) / sizeof(uint32_t)];
+    uint8_t data[MYNEWT_VAL(BLE_TRANSPORT_APOLLO3_MAX_TX_PACKET)];

Review Comment:
   The way it is used later, I would leave `data `here and `g_read_buf` as uint32_t to avoid alignment confusion (warning that could pop up with -Wcast-align).
   Maybe just rounding up from origin code for possibly buffers that are not multiply of 4 in size.



##########
nimble/transport/apollo3/src/apollo3_ble_hci.c:
##########
@@ -275,16 +255,22 @@ apollo3_ble_hci_acl_tx(struct os_mbuf *om)
 {
     struct os_mbuf *x;
     int rc = 0;
+    hci_drv_write_t write_buf;
+    uint8_t *ptr = &write_buf.data[1];
+    
+    write_buf.data[0] = HCI_H4_ACL;
+    write_buf.len = 1;
 
     x = om;
     while (x) {
-        rc = apollo3_hci_write(HCI_H4_ACL, x->om_len, x->om_data);
-        if (rc < 0) {
-            break;
-        }
+        memcpy(ptr, x->om_data, x->om_len);

Review Comment:
   maybe `os_mbuf_copydata()` could be used instead of a loop as it seems it does similar thing.



##########
nimble/transport/apollo3/src/apollo3_ble_hci.c:
##########
@@ -275,16 +255,22 @@ apollo3_ble_hci_acl_tx(struct os_mbuf *om)
 {
     struct os_mbuf *x;
     int rc = 0;
+    hci_drv_write_t write_buf;
+    uint8_t *ptr = &write_buf.data[1];
+    
+    write_buf.data[0] = HCI_H4_ACL;
+    write_buf.len = 1;
 
     x = om;
     while (x) {
-        rc = apollo3_hci_write(HCI_H4_ACL, x->om_len, x->om_data);
-        if (rc < 0) {
-            break;
-        }
+        memcpy(ptr, x->om_data, x->om_len);
+        ptr += x->om_len;
+        write_buf.len += x->om_len;
         x = SLIST_NEXT(x, om_next);
     }
 
+    apollo3_hci_write(&write_buf);

Review Comment:
   **rc** does not seem to be change from initial 0 value any more



-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: commits-unsubscribe@mynewt.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org