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 switch between connectable and non connectable advertising in clockhandler



this is my handler function for 5 second one shot clock

static void timeoutHandler(UArg arg)
{
// Store the event.
events |= arg;
// Wake up the application.
Semaphore_post(sem);
//making arvertisment nonconnectable
uint8_t gapProfileState;
GAPRole_GetParameter(GAPROLE_STATE,&gapProfileState);
if(gapProfileState != GAPROLE_CONNECTED)
{
uint8_t initialAdvertEnable = FALSE;
uint8_t new_advertising_event;
GAPRole_SetParameter(GAPROLE_ADVERT_ENABLED, sizeof(uint8_t),&initialAdvertEnable);
GAPRole_GetParameter(GAPROLE_STATE,&gapProfileState);
// while(gapProfileState != GAPROLE_WAITING);
new_advertising_event = GAP_ADTYPE_ADV_NONCONN_IND;
GAPRole_SetParameter( GAPROLE_ADV_EVENT_TYPE, sizeof( uint8 ), &new_advertising_event );
initialAdvertEnable = TRUE;
GAPRole_SetParameter(GAPROLE_ADVERT_ENABLED, sizeof(uint8_t),&initialAdvertEnable);

}
SensorTag_blinkLed(Board_LED2,1);
LCD_WRITE_STRING("nonconnectable", LCD_PAGE4);
Util_stopClock(&timeoutclock);//stop timer
}

i am turning off advertising then i am changing the type to non connectable advertisement then again
i am turning on the advertisementbut the type is still Connectable Undirect Advertisement on scanning by btool
what more steps are required to change the type on runtime

one more thing i have digged deeper and into the GAPRole_SetParameter function and found that

GAPRole_SetParameter(GAPROLE_ADVERT_ENABLED, sizeof(uint8_t),false);

simply turns off the advertisement and doesn't generate any event to change gap role but it is turning off the advertisment
while

new_advertising_event = GAP_ADTYPE_ADV_NONCONN_IND;
GAPRole_SetParameter( GAPROLE_ADV_EVENT_TYPE, sizeof( uint8 ), &new_advertising_event );

only changes the value of a variable that could change the advertisment type when event is generated and gapRole_taskFxn is executed
so the event is being generated by this function

GAPRole_SetParameter(GAPROLE_ADVERT_ENABLED, sizeof(uint8_t),true);

since there is a line in the end of this function definition ( gapRole_setEvent(START_ADVERTISING_EVT); )
but no event is being generated to wake up the gapRole_taskFxn task but when i try to cnnect after the handler's execution it connects once and gapRole_taskFxn task gets executed and which then update type of advertisment to nonconnectable
and then the advertisming becomes nonconnectable so my pint is why gapRole_taskFxn task is not executing after setting GAPROLE_ADVERT_ENABLED to TRUE?
please tell me the exact lines or atleast explain how the whole thing and events are working !!i need it get working.