Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Potential Bug: FMP Unresponsiveness after Receiving multiple FMP_DEV_REBOOT_TIME_REQ msg's #48

Closed
MpmTwtg opened this issue Mar 6, 2024 · 3 comments

Comments

@MpmTwtg
Copy link

MpmTwtg commented Mar 6, 2024

FMP does not respond after it got a valid FMP_DEV_REBOOT_TIME_REQ.
The first time it responds with an answer and after that not.

lorawan_api_send_stack_cid_req( cid_buffer, cid_request_size, stack_id );

my proposal is to remove this from line 321:

    case ANS_CMD_TASK_MASK: {
        ctx->fmp_task_ctx_mask &= ~( ANS_CMD_TASK_MASK );
        break;
    } 

And implant it with:

lorawan_api_payload_send(
                FMP_PORT, true, ctx->fmp_tx_payload_ans, ctx->fmp_tx_payload_ans_size, UNCONF_DATA_UP,
                smtc_modem_hal_get_time_in_ms( ) + smtc_modem_hal_get_random_nb_in_range( 0, ctx->fmp_ans_delay ),
                ctx->stack_id );

            ctx->fmp_tx_payload_ans_size = 0;
            ctx->fmp_task_ctx_mask &= ~( ANS_CMD_TASK_MASK );

or

status_lorawan_t status = lorawan_api_payload_send(
                FMP_PORT, true, ctx->fmp_tx_payload_ans, ctx->fmp_tx_payload_ans_size, UNCONF_DATA_UP,
                smtc_modem_hal_get_time_in_ms( ) + smtc_modem_hal_get_random_nb_in_range( 0, ctx->fmp_ans_delay ),
                ctx->stack_id );

            if(status == OKLORAWAN)
            {
                ctx->fmp_tx_payload_ans_size = 0;
                ctx->fmp_task_ctx_mask &= ~( ANS_CMD_TASK_MASK );
            }

This seems to works, would this be a correct fix and are am i missing something?

@lbm-team
Copy link
Contributor

lbm-team commented Mar 8, 2024

Hi MpmTwtg,
Each service is composed of 3 parts:

  • on_launch(), to launch an action by the service, at this step the lorawan stack is reserved for the service, any lorawan action must be carried out in this function.
  • on_update(), always called after on_launch() (or after a lorawan task if there was a lorawan task) and can be used to schedule a new on_launch() in the future (in the near future if you wish to respond to a request)
  • downlink_handler() can be called at any time if a downlink is received by the lorawan stack, can also schedule a task in the future if a response is required

After received your FMP_DEV_REBOOT_TIME_REQ downlink with a valid time

can you check if the mask is correctly set with
ctx->fmp_task_ctx_mask |= ANS_CMD_TASK_MASK;

and that a new task is scheduled with fmp_add_task()

Best

@MpmTwtg
Copy link
Author

MpmTwtg commented Mar 11, 2024

Hi lbm-team

the ctx->fmp_task_ctx_mask |= ANS_CMD_TASK_MASK; is set
but after a second message it is reset by the fmp_add_task before it has a change to send the FMP_DEV_REBOOT_TIME_ANS

see output log
out.log

@lbm-team
Copy link
Contributor

Hi MpmTwtg,

I understand your point, the modem received a new downlink that request the same answer the current answering command.

your proposition is correct to remove line 321:

case ANS_CMD_TASK_MASK: {
       // ctx->fmp_task_ctx_mask &= ~( ANS_CMD_TASK_MASK );
        break;
    } 

and to check the output of lorawan_api_send()

if( lorawan_api_payload_send(
                    FMP_PORT, true, ctx->fmp_tx_payload_ans, ctx->fmp_tx_payload_ans_size, UNCONF_DATA_UP,
                    smtc_modem_hal_get_time_in_ms( ) + smtc_modem_hal_get_random_nb_in_range( 0, ctx->fmp_ans_delay ),
                    ctx->stack_id ) == OKLORAWAN )
            {
                ctx->fmp_task_ctx_mask &= ~( ANS_CMD_TASK_MASK );
                ctx->fmp_tx_payload_ans_size = 0;
            }

@lbm-team lbm-team closed this as completed May 6, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants