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.

CC2540 Stops Advertising After Two Minutes When Extra Data in Advertisement Packet Is Added

Greetings,

I am running the SimpleBLEBroadcaster project. I have made changes to advertise for 5 seconds and do nothing for 60 seconds  and then repeat - using a timer event.

This works very well, however when I add extra data into advertisement packets the device only advertises for 2 minutes and then stops.

My event code and two examples of working / not-working advertisement packets are below.

Any suggestions? Thanks.

// -----------------Timer Event Code------------------------------------------------------------

if (events & START_ADV_TX)

  {
    uint8 current_adv_status;
    GAPRole_GetParameter( GAPROLE_ADVERT_ENABLED, &current_adv_status);
    if (current_adv_status == FALSE)   {
        uint8 adv_status = TRUE;
        GAPRole_SetParameter( GAPROLE_ADVERT_ENABLED, sizeof( uint8 ), &adv_status );   
        osal_start_timerEx( simpleBLEBroadcaster_TaskID, START_ADV_TX, 5000);
    }  else   {
        uint8 adv_status = FALSE;
        GAPRole_SetParameter( GAPROLE_ADVERT_ENABLED, sizeof( uint8 ), &adv_status );   
    }
 ....

if ( events & SBP_START_DEVICE_EVT )
  {
    // Start the Device
    VOID GAPRole_StartDevice( &simpleBLEBroadcaster_BroadcasterCBs );
    osal_start_timerEx( simpleBLEBroadcaster_TaskID, START_ADV_TX, 60000);
    return ( events ^ SBP_START_DEVICE_EVT );
  }

// -----------------Advertisement Packet Code------------------------------------------------------------

// Advertises For Two Minutes and and Stops :(

static uint8 advertData[] =
{
  0x02,   // length of this data
  GAP_ADTYPE_FLAGS,
  GAP_ADTYPE_FLAGS_GENERAL | GAP_ADTYPE_FLAGS_BREDR_NOT_SUPPORTED
  // GAP_ADTYPE_FLAGS_BREDR_NOT_SUPPORTED,

  // three-byte broadcast of the data "1 2 3"
  0x04,   // length of this data including the data type byte
  GAP_ADTYPE_MANUFACTURER_SPECIFIC,      // manufacturer specific advertisement data type
  0x11,
  0x12,
  0x13
};

// Advertises indefinitely. :)

static uint8 advertData[] =
{
  0x02,   // length of this data
  GAP_ADTYPE_FLAGS,
  GAP_ADTYPE_FLAGS_GENERAL | GAP_ADTYPE_FLAGS_BREDR_NOT_SUPPORTED
};

  • Hi David, 

    You can try as follow:

    1. If you want to advertise for 5 second only, you should use limited advertisement mode not general advertisement mode. Enable advertisement again on event.

    2. Your advert data will contain flag

    "GAP_ADTYPE_FLAGS_LIMITED | GAP_ADTYPE_FLAGS_BREDR_NOT_SUPPORTED"

    3.For other structure:

    static uint8 advertData[] = 

      0x02,   // length of this data
      GAP_ADTYPE_FLAGS,
      GAP_ADTYPE_FLAGS_LIMITED | GAP_ADTYPE_FLAGS_BREDR_NOT_SUPPORTED,
      // GAP_ADTYPE_FLAGS_BREDR_NOT_SUPPORTED,

      // three-byte broadcast of the data "1 2 3"
      0x04,   // length of this data including the data type byte
      GAP_ADTYPE_MANUFACTURER_SPECIFIC,      // manufacturer specific advertisement data type
      0x11,
      0x12,
      0x13
    };

    You forgot comma at highlighted line. Didn't it give you compiler warning?

    3. Instead of turning on and off advertisement, Set advertisement to limited mode and timeout = 5 second. So device will stop advertisement after 5 second automatically.

    GAP_SetParamValue( TGAP_LIM_ADV_TIMEOUT, 5);

    Hope this will help.

    Maulik