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.

How to stop the device from advertising

Hi everyone,

My device is a peripheral. I want to stop my device from advertising and turn off the radio. If connected, I want to shut the connection and turn off the radio. I want to be able to disable all functionality when I sense a critical battery level.

I see the function GAPRole_StartDevice, but I don't see the opposite.

Anyone know a workaround?

Regards,

Jerome

  • Hi Jerome,

    It is controlled via a GAP parameter (this is set by the initial_advertising_enable variable in the peripheral init function). GAPRole_StartDevice is for initialization. 

    To disable:

    bool Enable = false;
    GAPRole_SetParameter( GAPROLE_ADVERT_ENABLED, sizeof( bool ), &Enable );

    To enable:

    bool Enable = true;
    GAPRole_SetParameter( GAPROLE_ADVERT_ENABLED, sizeof( bool ), &Enable );

    The code behind the  GAPRole_SetParameter function appears to incorporate delay logic for stopping and starting too.