Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
11 changes: 8 additions & 3 deletions drivers/ieee802154/ieee802154_nrf5.c
Original file line number Diff line number Diff line change
Expand Up @@ -150,7 +150,7 @@ static void nrf5_rx_thread(void *arg1, void *arg2, void *arg3)
if (IS_ENABLED(CONFIG_IEEE802154_NRF5_FCS_IN_LENGTH)) {
pkt_len = rx_frame->psdu[0];
} else {
pkt_len = rx_frame->psdu[0] - NRF5_FCS_LENGTH;
pkt_len = rx_frame->psdu[0] - IEEE802154_FCS_LENGTH;
}

#if defined(CONFIG_NET_BUF_DATA_SIZE)
Expand Down Expand Up @@ -378,7 +378,7 @@ static int handle_ack(struct nrf5_802154_data *nrf5_radio)
if (IS_ENABLED(CONFIG_IEEE802154_NRF5_FCS_IN_LENGTH)) {
ack_len = nrf5_radio->ack_frame.psdu[0];
} else {
ack_len = nrf5_radio->ack_frame.psdu[0] - NRF5_FCS_LENGTH;
ack_len = nrf5_radio->ack_frame.psdu[0] - IEEE802154_FCS_LENGTH;
}

ack_pkt = net_pkt_rx_alloc_with_buffer(nrf5_radio->iface, ack_len,
Expand Down Expand Up @@ -582,9 +582,14 @@ static int nrf5_tx(const struct device *dev,
uint8_t *payload = frag->data;
bool ret = true;

if (payload_len > IEEE802154_MTU) {
LOG_ERR("Payload too large: %d", payload_len);
return -EMSGSIZE;
}

LOG_DBG("%p (%u)", payload, payload_len);

nrf5_radio->tx_psdu[0] = payload_len + NRF5_FCS_LENGTH;
nrf5_radio->tx_psdu[0] = payload_len + IEEE802154_FCS_LENGTH;
memcpy(nrf5_radio->tx_psdu + 1, payload, payload_len);

/* Reset semaphore in case ACK was received after timeout */
Expand Down
4 changes: 1 addition & 3 deletions drivers/ieee802154/ieee802154_nrf5.h
Original file line number Diff line number Diff line change
Expand Up @@ -10,8 +10,6 @@

#include <zephyr/net/ieee802154_radio.h>

#define NRF5_FCS_LENGTH (2)
#define NRF5_PSDU_LENGTH (125)
#define NRF5_PHR_LENGTH (1)

struct nrf5_802154_rx_frame {
Expand Down Expand Up @@ -61,7 +59,7 @@ struct nrf5_802154_data {
/* TX buffer. First byte is PHR (length), remaining bytes are
* MPDU data.
*/
uint8_t tx_psdu[NRF5_PHR_LENGTH + NRF5_PSDU_LENGTH + NRF5_FCS_LENGTH];
uint8_t tx_psdu[NRF5_PHR_LENGTH + IEEE802154_MAX_PHY_PACKET_SIZE];

/* TX result, updated in radio transmit callbacks. */
uint8_t tx_result;
Expand Down