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

LORAMAC_STATUS_SKIPPED_APP_DATA never pushed to application layer

Open omogenot opened this issue 1 year ago • 0 comments

I am using LoRaMAC version 4.70 and face an issue with the application data not being sent.

After a join procedure, the application layer is supposed to quickly send a couple of upload frames in order to verify the unit installation and to allow the server to send some unit extra configuration (besides of the LoRaMAC commands it could eventually send to setup channels, etc.). However, as it is clearly written in the LoRaMAC code in loramac.c in function PrepareFrame:

                // There is application payload available but the MAC commands does NOT fit into FOpts field.
                else if( ( MacCtx.AppDataSize > 0 ) && ( macCmdsSize > LORA_MAC_COMMAND_MAX_FOPTS_LENGTH ) )
                {

                    if( LoRaMacCommandsSerializeCmds( availableSize, &macCmdsSize, MacCtx.MacCommandsBuffer ) != LORAMAC_COMMANDS_SUCCESS )
                    {
                        return LORAMAC_STATUS_MAC_COMMAD_ERROR;
                    }
                    return LORAMAC_STATUS_SKIPPED_APP_DATA;
                }

which is fine by me. However, this LORAMAC_STATUS_SKIPPED_APP_DATA is never sent back to the user application as its sole usage is in the send function that will overwrite this status value in the next call:

    // Prepare the frame
    status = PrepareFrame( macHdr, &fCtrl, fPort, fBuffer, fBufferSize );

    // Validate status
    if( ( status == LORAMAC_STATUS_OK ) || ( status == LORAMAC_STATUS_SKIPPED_APP_DATA ) )
    {
        // Schedule frame, do not allow delayed transmissions
        status = ScheduleTx( false );
    }

In other words, my application will never be aware that the initial packets were never sent. A return of this LORAMAC_STATUS_SKIPPED_APP_DATA value instead of LORAMAC_STATUS_OK would be nice, so that the user application is aware that the application data has not been sent and perform any correction method.

Olivier.

omogenot avatar Jun 08 '23 09:06 omogenot