LoRaMac-node icon indicating copy to clipboard operation
LoRaMac-node copied to clipboard

Stack writes to NVM while radio is transmitting

Open ndiddy99 opened this issue 7 months ago • 0 comments

Hi,

I noticed that if the call to NvmDataMgmtStore at src/apps/LoRaMac/common/LmHandler/LmHandler.c line 389 blocks while the radio is transmitting, the transmitter will stay on. This can cause problems with various radio transmission dwell-time limits (for example, the limit for the US915 region is 400 ms), and means that the radio transmission duty cycle is higher than expected.

Our internal fix for this is to check that the radio is not transmitting before trying to write to NVM:

if ( Radio.GetStatus( ) != RF_TX_RUNNING )
{    
    // Store to NVM if required
    size = NvmDataMgmtStore( );

    if( size > 0 )
    {
        if( LmHandlerCallbacks->OnNvmDataChange != NULL )
        {
            LmHandlerCallbacks->OnNvmDataChange( LORAMAC_HANDLER_NVM_STORE, size );
        }
    }
}

If you think this is an acceptable fix, I can do a pull request if you want.

ndiddy99 avatar Nov 28 '23 17:11 ndiddy99