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.

Stop Advertising to enter Sleep mode does not work

Other Parts Discussed in Thread: CC2540

Hi all, i'm using the Keyfobdemo on my cc2540 chip.

i want to set it into advertising mode for 10s, and after that i want to disable advertising and go into sleep mode.

For some reason i'm not able to disable advertising and so i cant go into sleep mode.

I tried it two ways.

first way:

I set the gapRole_AdvertOffTime to 10000 (10s) after enable advertising.

second way i set a timer to stop advertising:

osal_start_timerEx( keyfobapp_TaskID, STOPADVERTISING,10000);

if ( events & STOPADVERTISING)
{
uint8 advstat = FALSE;
GAPRole_SetParameter( GAPROLE_ADVERT_ENABLED, sizeof( uint8 ), &advstat ); // Stop Advertising
osal_start_timerEx( keyfobapp_TaskID, ADVERTISING,10000); // Restart Timer - Advertising after 60s
return ( events ^ ADVERTISING );
}


On my first way the CC2540 always stays in Advertising mode for some reason i dont know.

at the second way, after i disabled advertising the current consumption increases to 11,6 mA and stays in advertising mode.

Does anybody know why this issue appears and how to solve it?

  • Hi Daniel,

    I think you might have misunderstood the purpose of  gapRole_AdvertOffTime, it defines how long time to wait to start advertising once you have stopped advertising. Set it to zero and your STOPADVERTISING event should work, although please clear the correct flag:

    if ( events & STOPADVERTISING)
    {
    uint8 advstat = FALSE;
    GAPRole_SetParameter( GAPROLE_ADVERT_ENABLED, sizeof( uint8 ), &advstat ); // Stop Advertising
    osal_start_timerEx( keyfobapp_TaskID, ADVERTISING,10000); // Restart Timer - Advertising after 60s
    return ( events ^ STOPADVERTISING ); 
    }

     Best Regards

    Joakim

  • Thanks for your quick response,

    i now changed my code:

    if ( events & ADVERTISING) 
    {
    uint8 gapRole_AdvertOffTime=0; 
    uint8 initial_advertising_enable = TRUE; 
    GAPRole_SetParameter( GAPROLE_ADVERT_ENABLED, sizeof( uint8 ), &initial_advertising_enable );
    GAPRole_SetParameter( GAPROLE_ADVERT_OFF_TIME, sizeof( uint16 ), &gapRole_AdvertOffTime );

    osal_start_timerEx( keyfobapp_TaskID, STOPADVERTISING,10000);
    return ( events ^ ADVERTISING );
    }

    if ( events & STOPADVERTISING)
    {
    uint8 advstat = FALSE;
    GAPRole_SetParameter( GAPROLE_ADVERT_ENABLED, sizeof( uint8 ), &advstat ); 
    osal_start_timerEx( keyfobapp_TaskID, ADVERTISING,10000);
    return ( events ^ STOPADVERTISING );
    }


    The CC2540 does not stop advertising...

  • Hi,

    You need to set gapRole_AdvertOffTime before you trigger advertisements, proposedly during the initiation of the application.

    One more thing, what numbers have you given your events ADVERTISING and STOPADVERTISING? Note that the events need to be bitmasked, ex. 0x0001, 0x0002, 0x0004, 0x0008, 0x0010, 0x0020 etc.

    Do you mind posting your application for me to have a look at?

    Best Regards

    Joakim Lindh

  • Yes of course,

    just tell me which files of the application do you need?

  • Hi Daniel,

    I assume you are using the keyfobdemo project, so the files keyfobdemo.c/h would be appropriate.

    Best Regards 

    Joakim

  • I solved my problem, i had a mistake in the call back for GAPROLE_WAITING

    Thanks for your help.