@@ -73,11 +73,11 @@ LoRaWANStack::LoRaWANStack()
7373      _app_port(INVALID_PORT),
7474      _link_check_requested(false ),
7575      _automatic_uplink_ongoing(false ),
76-       _ready_for_rx(true ),
7776      _queue(NULL )
7877{
7978    _tx_metadata.stale  = true ;
8079    _rx_metadata.stale  = true ;
80+     core_util_atomic_flag_clear (&_rx_payload_in_use);
8181
8282#ifdef  MBED_CONF_LORA_APP_PORT
8383    if  (is_port_valid (MBED_CONF_LORA_APP_PORT)) {
@@ -519,11 +519,10 @@ void LoRaWANStack::tx_interrupt_handler(void)
519519void  LoRaWANStack::rx_interrupt_handler (const  uint8_t  *payload, uint16_t  size,
520520                                        int16_t  rssi, int8_t  snr)
521521{
522-     if  (!_ready_for_rx ||  size > sizeof  _rx_payload) {
522+     if  (size > sizeof  _rx_payload ||  core_util_atomic_flag_test_and_set (&_rx_payload_in_use) ) {
523523        return ;
524524    }
525525
526-     _ready_for_rx = false ;
527526    memcpy (_rx_payload, payload, size);
528527
529528    const  uint8_t  *ptr = _rx_payload;
@@ -709,13 +708,13 @@ void LoRaWANStack::process_reception(const uint8_t *const payload, uint16_t size
709708        mlme_confirm_handler ();
710709
711710        if  (_loramac.get_mlme_confirmation ()->req_type  == MLME_JOIN) {
712-             _ready_for_rx =  true ;
711+             core_util_atomic_flag_clear (&_rx_payload_in_use) ;
713712            return ;
714713        }
715714    }
716715
717716    if  (!_loramac.nwk_joined ()) {
718-         _ready_for_rx =  true ;
717+         core_util_atomic_flag_clear (&_rx_payload_in_use) ;
719718        return ;
720719    }
721720
@@ -744,7 +743,7 @@ void LoRaWANStack::process_reception(const uint8_t *const payload, uint16_t size
744743        mlme_indication_handler ();
745744    }
746745
747-     _ready_for_rx =  true ;
746+     core_util_atomic_flag_clear (&_rx_payload_in_use) ;
748747}
749748
750749void  LoRaWANStack::process_reception_timeout (bool  is_timeout)
0 commit comments