summaryrefslogtreecommitdiffstatshomepage
path: root/extmod/btstack/btstack_hci_uart.c
diff options
context:
space:
mode:
authorDamien George <damien@micropython.org>2023-09-29 16:15:30 +1000
committerDamien George <damien@micropython.org>2023-09-29 18:01:42 +1000
commitfbe58553c2696b18a95e1284b32d7292d49bc486 (patch)
tree5c5d19a353ebaec53413d122ab277673092d04c8 /extmod/btstack/btstack_hci_uart.c
parentfae83a6b4d0d7b3e4917fdeb9b7966a06161af54 (diff)
downloadmicropython-fbe58553c2696b18a95e1284b32d7292d49bc486.tar.gz
micropython-fbe58553c2696b18a95e1284b32d7292d49bc486.zip
extmod/btstack/btstack_hci_uart: Trigger a poll after UART data is sent.
Prior to this commit, BTstack would only be notified of sent UART data when the mp_bluetooth_hci_poll() function was called for some other reason, eg because of incoming data over UART. This is highly suboptimal. With this commit, BTstack is now notified immediately after UART data has been sent out. This improves the multi_bluetooth/perf_gatt_char_write.py performance test by about a factor of 10x for write-without-response, and about 4x for write-with-response (tested on LEGO_HUB_NO6 as instance1). Signed-off-by: Damien George <damien@micropython.org>
Diffstat (limited to 'extmod/btstack/btstack_hci_uart.c')
-rw-r--r--extmod/btstack/btstack_hci_uart.c5
1 files changed, 5 insertions, 0 deletions
diff --git a/extmod/btstack/btstack_hci_uart.c b/extmod/btstack/btstack_hci_uart.c
index f945efc762..19cdfc4b9d 100644
--- a/extmod/btstack/btstack_hci_uart.c
+++ b/extmod/btstack/btstack_hci_uart.c
@@ -36,6 +36,7 @@
#include "extmod/mpbthci.h"
#include "extmod/btstack/btstack_hci_uart.h"
+#include "mpbthciport.h"
#include "mpbtstackport.h"
#define HCI_TRACE (0)
@@ -129,6 +130,10 @@ STATIC void btstack_uart_send_block(const uint8_t *buf, uint16_t len) {
mp_bluetooth_hci_uart_write(buf, len);
send_done = true;
+
+ // Data has been written out synchronously on the UART, so trigger a poll which will
+ // then notify btstack (don't call send_handler here or it may call us recursively).
+ mp_bluetooth_hci_poll_now();
}
STATIC int btstack_uart_get_supported_sleep_modes(void) {