mirror of
https://github.com/RIOT-OS/RIOT.git
synced 2025-01-18 12:52:44 +01:00
Merge pull request #16586 from jia200x/pr/fix_gnrc_lorawan_psdu_null
gnrc_lorawan: fix undefined state when PSDU is NULL
This commit is contained in:
commit
d9973d4bf8
@ -176,6 +176,17 @@ void gnrc_lorawan_radio_rx_timeout_cb(gnrc_lorawan_t *mac);
|
||||
*/
|
||||
void gnrc_lorawan_radio_tx_done_cb(gnrc_lorawan_t *mac);
|
||||
|
||||
/**
|
||||
* @brief Indicate the MAC layer reception of a frame went wrong.
|
||||
*
|
||||
* @param[in] mac pointer to the MAC descriptor
|
||||
*/
|
||||
static inline void gnrc_lorawan_radio_rx_error_cb(gnrc_lorawan_t *mac)
|
||||
{
|
||||
/* The failed reception is seen by the MAC layer as an RX timeout */
|
||||
gnrc_lorawan_radio_rx_timeout_cb(mac);
|
||||
}
|
||||
|
||||
/**
|
||||
* @brief Indicate the MAC layer that the timer was fired
|
||||
*
|
||||
@ -226,8 +237,9 @@ void gnrc_lorawan_mcps_request(gnrc_lorawan_t *mac,
|
||||
* To be called on radio RX done event.
|
||||
*
|
||||
* @param[in] mac pointer to the MAC descriptor
|
||||
* @param[in] data pointer to the psdu. Pass NULL if the packet was wrong (or
|
||||
* allocation failed)
|
||||
* @param[in] data pointer to the psdu. Must not be NULL. Use
|
||||
* @ref gnrc_lorawan_radio_rx_error_cb instead if the reception was
|
||||
* not successful.
|
||||
* @param[in] size size of the PSDU
|
||||
*/
|
||||
void gnrc_lorawan_radio_rx_done_cb(gnrc_lorawan_t *mac, uint8_t *data,
|
||||
|
@ -242,10 +242,8 @@ void gnrc_lorawan_send_pkt(gnrc_lorawan_t *mac, iolist_t *psdu, uint8_t dr)
|
||||
void gnrc_lorawan_radio_rx_done_cb(gnrc_lorawan_t *mac, uint8_t *psdu,
|
||||
size_t size)
|
||||
{
|
||||
assert(psdu);
|
||||
_sleep_radio(mac);
|
||||
if (psdu == NULL) {
|
||||
return;
|
||||
}
|
||||
mac->state = LORAWAN_STATE_IDLE;
|
||||
gnrc_lorawan_remove_timer(mac);
|
||||
|
||||
|
@ -180,13 +180,13 @@ static void _rx_done(gnrc_lorawan_t *mac)
|
||||
DEBUG("_recv_lorawan: cannot allocate pktsnip.\n");
|
||||
/* Discard packet on netdev device */
|
||||
dev->driver->recv(dev, NULL, bytes_expected, NULL);
|
||||
gnrc_lorawan_radio_rx_done_cb(mac, NULL, 0);
|
||||
gnrc_lorawan_radio_rx_error_cb(mac);
|
||||
return;
|
||||
}
|
||||
nread = dev->driver->recv(dev, pkt->data, bytes_expected, &rx_info);
|
||||
if (nread <= 0) {
|
||||
gnrc_pktbuf_release(pkt);
|
||||
gnrc_lorawan_radio_rx_done_cb(mac, NULL, 0);
|
||||
gnrc_lorawan_radio_rx_error_cb(mac);
|
||||
return;
|
||||
}
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user