Skip to content

Commit edfb5d5

Browse files
jimmodpgeorge
authored andcommitted
extmod/nimble: Allow modbluetooth binding to hook "sent HCI packet".
1 parent 53dfb27 commit edfb5d5

File tree

3 files changed

+12
-0
lines changed

3 files changed

+12
-0
lines changed

extmod/nimble/hal/hal_uart.c

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -27,6 +27,7 @@
2727
#include "py/runtime.h"
2828
#include "py/mphal.h"
2929
#include "nimble/ble.h"
30+
#include "extmod/nimble/modbluetooth_nimble.h"
3031
#include "extmod/nimble/hal/hal_uart.h"
3132
#include "extmod/nimble/nimble/nimble_npl_os.h"
3233
#include "extmod/mpbthci.h"
@@ -74,6 +75,11 @@ void hal_uart_start_tx(uint32_t port) {
7475
#endif
7576

7677
mp_bluetooth_hci_uart_write(mp_bluetooth_hci_cmd_buf, len);
78+
79+
if (len > 0) {
80+
// Allow modbluetooth bindings to hook "sent packet" (e.g. to unstall l2cap channels).
81+
mp_bluetooth_nimble_sent_hci_packet();
82+
}
7783
}
7884

7985
int hal_uart_close(uint32_t port) {

extmod/nimble/modbluetooth_nimble.c

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1392,6 +1392,9 @@ int mp_bluetooth_gattc_exchange_mtu(uint16_t conn_handle) {
13921392

13931393
#endif // MICROPY_PY_BLUETOOTH_ENABLE_GATT_CLIENT
13941394

1395+
void mp_bluetooth_nimble_sent_hci_packet(void) {
1396+
}
1397+
13951398
#if MICROPY_PY_BLUETOOTH_ENABLE_L2CAP_CHANNELS
13961399

13971400
// Fortunately NimBLE uses mbuf chains correctly with L2CAP COC (rather than

extmod/nimble/modbluetooth_nimble.h

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -71,5 +71,8 @@ void mp_bluetooth_nimble_port_start(void);
7171
// Tell the port to stop its background task.
7272
void mp_bluetooth_nimble_port_shutdown(void);
7373

74+
// --- Called by the HCI UART layer to let us know when packets have been sent.
75+
void mp_bluetooth_nimble_sent_hci_packet(void);
76+
7477

7578
#endif // MICROPY_INCLUDED_EXTMOD_NIMBLE_MODBLUETOOTH_NIMBLE_H

0 commit comments

Comments
 (0)