diff --git a/src/main.c b/src/main.c index a16f266..d54b7fc 100644 --- a/src/main.c +++ b/src/main.c @@ -16,6 +16,7 @@ #define LOG_MODULE_NAME hci_uart_h5 #include +#include #include @@ -177,6 +178,7 @@ static inline void bt_uart_drain(struct device *dev) void _reboot_if_not(struct net_buf *buf, char const *file, int line) { if (!buf) { + log_panic(); LOG_ERR("Failed alloc at %s:%d", file, line); sys_reboot(SYS_REBOOT_COLD); } @@ -453,6 +455,14 @@ void bt_uart_isr(struct device *unused) } while (uart_fifo_read(hci_uart_dev, &byte, sizeof(byte))) { + if (buf->len == buf->size && byte != SLIP_DELIMITER) { + /* If our buffer is full, but the packet isn't done... + * unsync'ing SLIP will drop the rest of the packet and the net_buf_reset + * prepares the buffer for reuse without unref/alloc cycle. + */ + net_buf_reset(buf); + slip_state = SLIP_NOSYNC; + } if (slip_state == SLIP_NOSYNC && byte != SLIP_DELIMITER) { continue; }