This thread has been locked.

If you have a related question, please click the "Ask a related question" button in the top right corner. The newly created question will be automatically linked to this question.

RTOS/CC2640R2F: How to disable auto advertising after disconnect in Project Zero?

Part Number: CC2640R2F

Tool/software: TI-RTOS

Hi everyone!


How to disable auto advertising after disconnect?


I  want save power so I set Project Zero in Limited discoverable mode and set TGAP_LIM_ADV_TIMEOUT to 3 seconds.

It work fine when Button is pushed, it advertises for 3 seconds and then stops the ad.

But there have a question is it will auto advertising for 3 seconds after disconnect.

How to disable this function?

I have try this, but it doesn't work:  http://e2e.ti.com/support/wireless-connectivity/bluetooth/f/538/t/337534



Many thanks, Gary

  • Hi Gary,

    Can you double check that there's nothing in your code enabling advertising? (e.g. in the GAP_LINK_TERMINATED case?)
  • Hi Gary,

    Do you use ble5stack? If not, try to disable peripheral.c --> gapRole_processGAPMsg --> case GAP_LINK_TERMINATED_EVENT: --> gapRole_setEvent(START_ADVERTISING_EVT);
  • Hi Marie H,

    Without modification, there actually have a code of Start advertising in the GAP_LINK_TERMINATED case:

    // Start advertising, if enabled.
    gapRole_setEvent(START_ADVERTISING_EVT);

    The following reply to Kimi Hu contains test results.

    Many thanks, Gary
  • Hi Kimi Hu,

    I tried this way, but there will be another problem.
    Project Zero can't advertise again when the button is pressed again.

    In debug mode, I can observed that flag "gapRole_AdvEnabled" won't
    be cleared after disable the code of gapRole_setEvent(START_ADVERTISING_EVT) or connected

    So I try to add 「gapRole_AdvEnabled = FALSE」 with gapRole_state = GAPROLE_WAITING to the 「else circle」 above;

    else
    {
    gapRole_state = GAPROLE_WAITING;
    gapRole_AdvEnabled = FALSE; // clear AdvEnabled flag.
    }

    // Start advertising, if enabled.
    // gapRole_setEvent(START_ADVERTISING_EVT);

    Although I am not sure if this code modification is appropriate, it is working fine now.

    I think should be an API can close auto adverting, no?

    Many thanks, Gary
  • Hi Gary,

    I think there is no API to close auto advertising. Depend on your application, you can add gapRole_AdvEnabled = FALSE in "case GAP_LINK_TERMINATED_EVENT:" or modify "GAPRole_SetParameter --> case GAPROLE_ADVERT_ENABLED:"