Skip to content

[hci] If UART data comes in too fast, we overrun read buffer #396

@kendallgoto

Description

@kendallgoto

https://github.com/tinygo-org/bluetooth/blob/5c615298c3e4400150c44da3636f3d3b10967e3c/hci.go#L199C1-L203C1

While polling HCI, there are many sleeps that should likely be yields, if anything. However, if we're running an operation over HCI that emits a large amount of packets (such as BT scan), it is very easy to overrun the HCI buffer because of these sleeps. Pending HCI messages queue up, then when the system tries to read from the HCI transport, it will attempt to read all of the pending HCI packets at once, rather than filling its buffer.

As long as we don't receive a single HCI message that is larger than our buffer, which appears to be limited at 255 bytes in the spec, all that needs to happen is that we stop reading when the buffer is filled, rather than attempt to read beyond our means.

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugSomething isn't workinghciHost Controller Interface

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions