I am trying to dynamically update the advertData as done in http://e2e.ti.com/support/low_power_rf/f/538/t/72681.aspx. But I am running into a side effect that the HAL_KEY_SW_2 (right key on the CC2541 keyfob) key is not switching the advertising on/off. I am updating the advertData with the battery level in the peripheralStateNotificationCB() function as below. I have also tried to update the advertData() in the KFD_BATTERY_CHECK_EVT but it gives the same side effect. I am using the keyfob project of BLE Stack v1.3. I will appreciate any help. Thanks in advance!!
case GAPROLE_ADVERTISING:
{
// Visual feedback that we are advertising.
HalLedSet( HAL_LED_2, HAL_LED_MODE_ON );
// Update the battery level in the AdvertData
uint8 newBattLevel;
Batt_GetParameter( BATT_PARAM_LEVEL, &newBattLevel );
advertData [10] = newBattLevel;
GAPRole_SetParameter( GAPROLE_ADVERT_DATA, sizeof( advertData ), advertData );
}
In peripheral.c
case GAPROLE_ADVERT_DATA:
if ( len <= B_MAX_ADV_LEN )
{
VOID osal_memset( gapRole_AdvertData, 0, B_MAX_ADV_LEN );
VOID osal_memcpy( gapRole_AdvertData, pValue, len );
gapRole_AdvertDataLen = len;
// Update the advertising data
GAP_UpdateAdvertisingData( gapRole_TaskID, TRUE, gapRole_AdvertDataLen, gapRole_AdvertData );
}