Part Number: CC2541
Other Parts Discussed in Thread: BLE-STACK
Hi.
I am using a SimpleBLECentralBroadcaster example (1.4.2.2 BLE-Stack, IAR)
This code are working properly (when press the button once - advertising starts; when press the button again - adverising stops)
-------------------------------------------------------------
// Advertising
if ( keys & HAL_KEY_SW_1 )
{
P0_6 = 0; // Led off
// pressing the right key should toggle advertising on and off
uint8 current_adv_enabled_status;
uint8 new_adv_enabled_status;
//Find the current GAP advertisement status
GAPRole_GetParameter( GAPROLE_ADVERT_ENABLED, ¤t_adv_enabled_status );
if( current_adv_enabled_status == FALSE )
{
new_adv_enabled_status = TRUE;
}
else
{
new_adv_enabled_status = FALSE;
}
//change the GAP advertisement status to opposite of current status
GAPRole_SetParameter( GAPROLE_ADVERT_ENABLED, sizeof( uint8 ), &new_adv_enabled_status );
}
-----------------------------------------------------
But in my device I want it advertise while the button is pressed and stop advertising when the button release.
Please help me with that.
Thank you.