Delay function not working as desired

Hello All,

I am using FXT009 modem.
I am really struggling with this bit, any help is much appreciated.
I am trying to apply following logic but the delay is not being applied between steps 2 and 3, the main functions continues regardless of the delay and the delay only happens once the main function is finished. Why and is there another way of doing this?

For the delay I am using the following function;
adl_tmrSubscribe(FALSE, hysterisis_value, ADL_TMR_TYPE_100MS, (adl_tmrHandler_t) wait_for_hyst);

Send when something changes function
{
Step 1
Step 2
Go to delay check timer function
Step 3
Step 4
}

delay check timer function
{
Go to delay function
}

Delay function
{
wait for a couple of seconds
}

Thanks in advance :slight_smile:

Calling

adl_tmrSubscribe(FALSE, hysterisis_value, ADL_TMR_TYPE_100MS, (adl_tmrHandler_t) wait_for_hyst);

will start a timer that runs in the background, and will call the callback function after <hysterisis_value * 100ms>. Your code will still continue to run. You have 2 options when implementing a delay:

Send when something changes function
{
    Step 1
    Step 2
    adl_tmrSubscribe(FALSE, hysterisis_value, ADL_TMR_TYPE_100MS, (adl_tmrHandler_t) wait_for_hyst);
}

void wait_for_hyst (u8 Id, void * Context)
{
    Step 3
    Step 4
}
Send when something changes function
{
    Step 1
    Step 2
    adl_ctxSleep(ADL_TMR_S_TO_TICK(hysterisis_value) );
    Step 3
    Step 4
}

Thank you very much Tom.
cheers

Note that adl_ctxSleep() will not work if you have only one task.

Open-AT is Event-Driven - you should not be inserting inline delays :exclamation:

https://forum.sierrawireless.com/t/good-paper-on-event-driven-programming/3848/7

@Awneil: I am using one task and it worked for me however while downloading the application, if sleep time is > than the time out period then the modem gives timeout error but application download is successful.