From ba57c415a57d5c49d0b6446d99f1b2352616216a Mon Sep 17 00:00:00 2001 From: Matthias Ringwald Date: Tue, 22 Sep 2020 22:56:17 +0200 Subject: [PATCH] stm32-sx1280: ignore empty packets --- chipset/sx128x/ll_sx1280.c | 19 +++++++++++++------ 1 file changed, 13 insertions(+), 6 deletions(-) diff --git a/chipset/sx128x/ll_sx1280.c b/chipset/sx128x/ll_sx1280.c index 811504130..b8ac552b5 100644 --- a/chipset/sx128x/ll_sx1280.c +++ b/chipset/sx128x/ll_sx1280.c @@ -620,16 +620,23 @@ static void radio_fetch_rx_pdu(void){ // fetch reserved rx pdu ll_pdu_t * rx_packet = ctx.rx_pdu; btstack_assert(rx_packet != NULL); - ctx.rx_pdu = NULL; - // mark as data packet - rx_packet->flags |= LL_PDU_FLAG_DATA_PDU; + // read max packet uint16_t max_packet_len = 2 + 27; - SX1280HalReadBuffer( SX1280_RX0_OFFSET, &rx_packet->header, max_packet_len); - // queue received packet - btstack_linked_queue_enqueue(&ctx.rx_queue, (btstack_linked_item_t *) rx_packet); + // queue if not empty + if (rx_packet->len != 0){ + + // packet used + ctx.rx_pdu = NULL; + + // mark as data packet + rx_packet->flags |= LL_PDU_FLAG_DATA_PDU; + + // queue received packet + btstack_linked_queue_enqueue(&ctx.rx_queue, (btstack_linked_item_t *) rx_packet); + } } /** Radio IRQ handlers */