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.

CC2541DK-MINI: Stopping advertising and about advertising parameters CC2541

Part Number: CC2541DK-MINI

Hello,

developing on simplebleperipheral app, i noticed that the function 

GAPRole_SetParameter( GAPROLE_ADVERT_OFF_TIME, sizeof( uint16 ), &gapRole_AdvertOffTime );

actually doesnt stop advertising. So i used GAP_SetParamValue(TGAP_LIM_ADV_TIMEOUT, 10), in the init routine, to stop the packets after 10 seconds. Again, i noticed this one works only if i DONT make to update advertising during init phase and maintain the declaration

static uint8 advertData[] =

{
// Flags; this sets the device to use limited discoverable
// mode (advertises for 30 seconds at a time) instead of general
// discoverable mode (advertises indefinitely)
0x02, // length of this data
GAP_ADTYPE_FLAGS,
DEFAULT_DISCOVERABLE_MODE | GAP_ADTYPE_FLAGS_BREDR_NOT_SUPPORTED,

// service UUID, to notify central devices what services are included
// in this peripheral
0x03, // length of this data
GAP_ADTYPE_16BIT_MORE, // some of the UUID's, but not all
LO_UINT16( SIMPLEPROFILE_SERV_UUID ),
HI_UINT16( SIMPLEPROFILE_SERV_UUID ),

};

in this way my first two advertising packets, on power up, arent useful, they contain only static data. Can i solve this and still able to stop advertising after a fixed time?

  • Hi Vito,

    You are correct: GAPRole_SetParameter( GAPROLE_ADVERT_OFF_TIME, sizeof( uint16 ), &gapRole_AdvertOffTime ) does not turn off advertising, it sets the amount of time that advertising will be disabled for limited advertising. You can see this if you look at the GAP_END_DISCOVERABLE_DONE_EVENT you will see that after advertising ends, gapRole_AdvertOffTime is used to start a timer that will prompt advertising to start again when it elapses. If you do not want advertising to automatically restart after a period of time, you should set this to zero.

    To put your device in limited discoverable mode, you should make sure you are using the GAP_ADTYPE_FLAGS_LIMITED flag as indicated by the code comments. GAP_SetParamValue(TGAP_LIM_ADV_TIMEOUT, 10) will change the amount of time that it takes for advertisements to stop.
  • Thanks for you reply, Rachel.
    It seems that the GAP_ADTYPE_FLAGS_LIMITED flag (assigned through #define DEFAULT_DISCOVERABLE_MODE GAP_ADTYPE_FLAGS_LIMIT in the costants section) works only if the following vector is inserted in the code:
    static uint8 advertData[] =
    {

    0x02, // length of this data
    GAP_ADTYPE_FLAGS,
    DEFAULT_DISCOVERABLE_MODE | GAP_ADTYPE_FLAGS_BREDR_NOT_SUPPORTED,
    };

    but this prevents me from updating the advertising data already in the simple BLE Peripheral Init, so the first two packets are not useful for my purposes.
  • Hi Vito,

    If you don't want to use the flag but you want to stop advertisements after a certain time, you could also try using a timer to disable advertising by setting the GAPROLE_ADVERT_ENABLED parameter with a value of false.