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

KR920 LBT test faillure

Open dennisvbussel opened this issue 2 years ago • 0 comments

Hi,

We are attempting to approbate region KR920 and the test house reports failure on the listen-before-talk test.

Looking at the following code snippet: https://github.com/Lora-net/LoRaMac-node/blob/2bf36bde72f68257eb96b5c00900619546bedca8/src/radio/sx126x/radio.c#L586-L618

The default return value bool status = true; Seems to be problematic in our case. For some reason (probably a race-condition) the loop while( TimerGetElapsedTime( carrierSenseTime ) < maxCarrierSenseTime ) exits immediately without measuring the RSSI even once and the function returns true

Adding a check rssi != 0 resolves this problem.

Example solution:

bool RadioIsChannelFree( uint32_t freq, uint32_t rxBandwidth, int16_t rssiThresh, uint32_t maxCarrierSenseTime )
{
    ...
    RadioSleep( );
    // Make sure that the carrier sense is executed once
    return (rssi != 0) ? status : false; 
}

Or maybe nicer, change while -> do while:

bool RadioIsChannelFree( uint32_t freq, uint32_t rxBandwidth, int16_t rssiThresh, uint32_t maxCarrierSenseTime )
{
    bool     status           = true;
    int16_t  rssi             = 0;
    uint32_t carrierSenseTime = 0;

    RadioSetModem( MODEM_FSK );

    RadioSetChannel( freq );

    // Set Rx bandwidth. Other parameters are not used.
    RadioSetRxConfig( MODEM_FSK, rxBandwidth, 600, 0, rxBandwidth, 3, 0, false,
                      0, false, 0, 0, false, true );
    RadioRx( 0 );

    DelayMs( 1 );

    carrierSenseTime = TimerGetCurrentTime( );

    // Perform carrier sense for maxCarrierSenseTime
    do 
    {
        rssi = RadioRssi( MODEM_FSK );

        if( rssi > rssiThresh )
        {
            status = false;
            break;
        }
    }
    while( TimerGetElapsedTime( carrierSenseTime ) < maxCarrierSenseTime );

    RadioSleep( );
    return status;
}

What is your opinion on this?

dennisvbussel avatar Apr 14 '23 10:04 dennisvbussel