cancel
Showing results for 
Search instead for 
Did you mean: 

WICED Smart Bluetooth

Anonymous
Not applicable

How can I register callback for ADV events, for example when the timer for HIGH_UNDIRECTED_DISCOVERABLE expires ?

I managed to do similar thing for SCAN events using:

blecen_usertimerCb = hello_client_timer_callback;

but this does not work for ADV events.



1 Solution
VictorZ_46
Employee

on_timer_events()

{

    if (running_high_duty_adverts && (time_since_started_high_duty_adverts == 31) && need_to_keep_high_duty_adverts)

    {

        start_high_duty_adverts();

    }

}

View solution in original post

0 Likes
7 Replies
VictorZ_46
Employee

you can register event to be notified when advertisements stop

bleprofile_regAppEvtHandler(BLECM_APP_EVT_ADV_TIMEOUT, hello_sensor_advertisement_stopped);

If you need to know when advertisement changes from high duty to low duty, you will need to monitor time.  For example if you configured high duty advertisement durations for 30 seconds

/*.high_undirect_adv_duration =*/ 30,  // seconds

and you have 1 second timer running

bleprofile_regTimerCb(hello_sensor_fine_timeout, hello_sensor_timeout);

bleprofile_StartTimer();

you can bet that after 30 times you enter hello_sensor_timeout the advertisements will go from high duty to low duty.

Anonymous
Not applicable

I need to intercept the transition HIGH->LOW and LOW->OFF (before it happens)

For SCAN it can be done this way:

extern BLEAPP_TIMER_CB  blecen_usertimerCb;

void app_create(void)

{

    ...

    blecen_usertimerCb = app_timer_callback ;

    ...

}

void app_timer_callback(UINT32 arg)

{

    switch(arg)

    {

    case BLEAPP_APP_TIMER_SCAN:

        if (blecen_GetScan() == HIGH_SCAN)

        {

          //custom code here

        }

        else if (blecen_GetScan() == LOW_SCAN)

        {

          //custom code here       

        }

        break;

    }

}

Please note that the above also works for CONN:

just add:

     case BLEAPP_APP_TIMER_CONN:

but it does not work for:

     case BLEAPP_APP_TIMER_ADV:

So how can I do same thing for ADV ?

Why is BLEAPP_APP_TIMER_ADV special ? how to handle it ?

victorz

0 Likes
VictorZ_46
Employee

There is no API for that.  If you set high duty advertisements for 30 seconds and you want to be notified before that the best resolution you can get is 30 seconds - 12.5 milliseconds.  And this is done only using timers.  And as I mentioned you are notified when transition is to OFF.

Anonymous
Not applicable

The reason I want to intercept this event is that I want to control the transition:

Here is working example for SCAN:

    case BLEAPP_APP_TIMER_SCAN:

        if (blecen_GetScan() == HIGH_SCAN)

        {

          //decide whether change to LOW_SCAN or not

          if (change_to_low)

               blecen_Scan(LOW_SCAN);

        }


Knowing only when this happens using different timer does not help here.

Is it possible at all for ADV ?

0 Likes
VictorZ_46
Employee

on_timer_events()

{

    if (running_high_duty_adverts && (time_since_started_high_duty_adverts == 31) && need_to_keep_high_duty_adverts)

    {

        start_high_duty_adverts();

    }

}

View solution in original post

0 Likes
Anonymous
Not applicable

is there a reason why :

BLEAPP_APP_TIMER_ADV


unlike:

BLEAPP_APP_TIMER_CONN and

BLEAPP_APP_TIMER_SCAN

cannot be handled in user's timer callback ?

0 Likes
VictorZ_46
Employee

Very good question. We will consider your suggestion for the next version of ROM.