We can advertise with selected no. of packets using the API " CyBle_GappSetNumOfAdvPkts (CYBLE_GAPP_DISC_MODE_INFO_T *advInfo, uint16 NumOfAdvPkts) " this function sets number of advertisement packets to be sent over the air and starts Advertisement. Gap Peripheral receives CYBLE_EVT_GAPP_ADVERTISEMENT_START_STOP event after specified no. of adv packets are transmitted successfully.
To start and stop the advertisement wherever you want below APIs can be used in code:
CyBle_GappStartAdvertisement (uint8 advertisingIntervalType) - This function is used to start the advertisement.
Similarly, CyBle_GappStopAdvertisement (void ) - This function can be used to exit from discovery mode. After the execution of this function, there will no longer be any advertisements.
Please refer the component datasheet for more information on these APIs.