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.

Side effect of GAP_UpdateAdvertisingData() to dynamically update advertising data

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 );
      }

  • I am having the exact same problem, did you solve it? If yes, how?

  • It all depends on where you are calling 

    GAP_UpdateAdvertisingData(simpleBLEPeripheral_TaskID, TRUE, sizeof( advertData ), advertData );

    I had a requirement, where I used to update the advertisement data periodically. Even when the advertisement was off, this used to re enable the advertisement. For this, I added the condition to check whether the device is advertising or not before updating the advertData.

    if (gapProfileState == GAPROLE_ADVERTISING) {
        GAP_UpdateAdvertisingData(simpleBLEPeripheral_TaskID, TRUE, sizeof( advertData ), advertData );
    }