summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorJim Mussared <jim.mussared@gmail.com>2021-07-21 17:04:41 +1000
committerDamien George <damien@micropython.org>2021-07-23 21:58:04 +1000
commitedfb5d56c8392b1c0933abf49e757b90f2c07859 (patch)
tree7ecf9c319ede5603eb3a06af08b0eeb45ae3b5af
parent53dfb279da4c2502c5040227329b06e3ea79fd63 (diff)
extmod/nimble: Allow modbluetooth binding to hook "sent HCI packet".
-rw-r--r--extmod/nimble/hal/hal_uart.c6
-rw-r--r--extmod/nimble/modbluetooth_nimble.c3
-rw-r--r--extmod/nimble/modbluetooth_nimble.h3
3 files changed, 12 insertions, 0 deletions
diff --git a/extmod/nimble/hal/hal_uart.c b/extmod/nimble/hal/hal_uart.c
index cd5e49e30..84a964fde 100644
--- a/extmod/nimble/hal/hal_uart.c
+++ b/extmod/nimble/hal/hal_uart.c
@@ -27,6 +27,7 @@
#include "py/runtime.h"
#include "py/mphal.h"
#include "nimble/ble.h"
+#include "extmod/nimble/modbluetooth_nimble.h"
#include "extmod/nimble/hal/hal_uart.h"
#include "extmod/nimble/nimble/nimble_npl_os.h"
#include "extmod/mpbthci.h"
@@ -74,6 +75,11 @@ void hal_uart_start_tx(uint32_t port) {
#endif
mp_bluetooth_hci_uart_write(mp_bluetooth_hci_cmd_buf, len);
+
+ if (len > 0) {
+ // Allow modbluetooth bindings to hook "sent packet" (e.g. to unstall l2cap channels).
+ mp_bluetooth_nimble_sent_hci_packet();
+ }
}
int hal_uart_close(uint32_t port) {
diff --git a/extmod/nimble/modbluetooth_nimble.c b/extmod/nimble/modbluetooth_nimble.c
index 8bbec5488..f3679354f 100644
--- a/extmod/nimble/modbluetooth_nimble.c
+++ b/extmod/nimble/modbluetooth_nimble.c
@@ -1392,6 +1392,9 @@ int mp_bluetooth_gattc_exchange_mtu(uint16_t conn_handle) {
#endif // MICROPY_PY_BLUETOOTH_ENABLE_GATT_CLIENT
+void mp_bluetooth_nimble_sent_hci_packet(void) {
+}
+
#if MICROPY_PY_BLUETOOTH_ENABLE_L2CAP_CHANNELS
// Fortunately NimBLE uses mbuf chains correctly with L2CAP COC (rather than
diff --git a/extmod/nimble/modbluetooth_nimble.h b/extmod/nimble/modbluetooth_nimble.h
index 9ed64368b..15648a995 100644
--- a/extmod/nimble/modbluetooth_nimble.h
+++ b/extmod/nimble/modbluetooth_nimble.h
@@ -71,5 +71,8 @@ void mp_bluetooth_nimble_port_start(void);
// Tell the port to stop its background task.
void mp_bluetooth_nimble_port_shutdown(void);
+// --- Called by the HCI UART layer to let us know when packets have been sent.
+void mp_bluetooth_nimble_sent_hci_packet(void);
+
#endif // MICROPY_INCLUDED_EXTMOD_NIMBLE_MODBLUETOOTH_NIMBLE_H