circuitpython/extmod/nimble
Jim Mussared 47d02b3104 extmod/nimble: Improve the flow control for l2cap recv path.
If the _IRQ_L2CAP_RECV handler does the actual consumption of the incoming
data (i.e. via l2cap_recvinto), rather than setting a flag for
non-scheduler-context to handle it later, then two things can happen:

- It can starve the VM (i.e. the scheduled task never terminates).  This is
  because calling l2cap_recvinto will empty the rx buffer, which will grant
  more credits to the channel (an HCI command), meaning more data can
  arrive.  This means that the loop in hal_uart.c that keeps reading HCI
  data from the uart and executing NimBLE events as they are created will
  not terminate, preventing other VM code from running.

- There's no flow control (i.e. data will arrive too quickly).  The channel
  shouldn't be given credits until after we return from scheduler context.

It's preferable that no work is done in scheduler/IRQ context.  But to
prevent this being a problem this commit changes l2cap_recvinto so that if
it is called in IRQ context, and the Python handler empties the rx buffer,
then don't grant credits until the Python handler is complete.

Signed-off-by: Jim Mussared <jim.mussared@gmail.com>
2021-01-30 13:22:40 +11:00
..
bsp extmod/nimble: Add nimble bindings. 2019-10-01 09:51:02 +10:00
hal extmod/nimble: Make stm32 and unix NimBLE ports use synchronous events. 2020-11-13 17:19:05 +11:00
logcfg extmod/modbluetooth: Refactor stack/hci/driver/port bindings. 2020-09-08 11:41:31 +10:00
nimble extmod/modbluetooth: Add API for L2CAP channels. 2020-11-24 01:07:17 +11:00
syscfg extmod/modbluetooth: Allow configuration of pairing/bonding parameters. 2020-12-02 14:40:49 +11:00
modbluetooth_nimble.c extmod/nimble: Improve the flow control for l2cap recv path. 2021-01-30 13:22:40 +11:00
modbluetooth_nimble.h extmod/modbluetooth: Add API for L2CAP channels. 2020-11-24 01:07:17 +11:00
nimble.mk extmod/modbluetooth: Add support for bonding (key persistence). 2020-12-02 14:41:41 +11:00