Fixes problems with oversized H5 packets; ensures logging on alloc failure
This commit is contained in:
parent
52dbf7ba41
commit
52edd92f00
10
src/main.c
10
src/main.c
|
@ -16,6 +16,7 @@
|
|||
|
||||
#define LOG_MODULE_NAME hci_uart_h5
|
||||
#include <logging/log.h>
|
||||
#include <logging/log_ctrl.h>
|
||||
|
||||
|
||||
#include <misc/util.h>
|
||||
|
@ -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;
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue