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.

CC2541: Unable to modify advertisement name while advertising

Part Number: CC2541

Hello,

Problem: Not able to change advertising name while CC2541 is advertising

Setup:

IAR Version: 8051 10.20.1
SDK Version: BLE-CC254x-1.4.2.2
Example: SimpleBLEBroadcaster
Configuration: Non-Connectable Advertisements

Board: Custom Board with CC2541

Code Snippet to modify name:

// GAP - Advertisement data (max size = 31 bytes, though this is
// best kept short to conserve power while advertisting)

static uint8 advertData[] = 
{ 
// Flags; this sets the device to use limited discoverable
// mode (advertises for 30 seconds at a time) instead of general
// discoverable mode (advertises indefinitely)
0x02, // length of this data
GAP_ADTYPE_FLAGS,
GAP_ADTYPE_FLAGS_GENERAL,

// complete name
0x07, // length of first data structure (11 bytes excluding length byte)
GAP_ADTYPE_LOCAL_NAME_COMPLETE, // AD Type = Complete local name
0x47, //'G'
0x47, //'G'
0x58, //'X'
0x31, //'1'
0x32, //'2'
0x30, //'0'

// 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
1,
2,
3
};
//In event processing function: SimpleBLEBroadcaster_ProcessEvent(), within an event the following lines have been used to change the name:

advertData[5]=0x53; //'S' 
GAPRole_SetParameter( GAPROLE_ADVERT_DATA, sizeof ( advertData ),advertData);
uint8 turnOnAdv = TRUE;
GAPRole_SetParameter( GAPROLE_ADVERT_ENABLED, sizeof( uint8 ), &turnOnAdv );

With the code snippet above, name is being changed very rarely in order of 1-2 times in 30-40 tries. Can you please suggest a better way to make the modification.

Thank you,

Madhav

  • What are you using to read the advertising data? If it's a phone, smart phones tend to cache the name of advertising BLE devices so you will need to clear the phones cache in order to see the updated name.

    You can confirm the advertising name change much more reliably when using a sniffer.
  • Hey,

    Thank you for your prompt reply. Actually, after inserting the code to modify, it stops advertising all together. So, can you suggest an approach to change device name. Also, I have checked with sniffer, but it doesn't advertise.
  • Can you share your code that you added to modify the example?

    Typically i would recommend you shut off advertising, change the advertising set data and then re-enable the advertising. similar to the following

    uint8 initial_advertising_enable = FALSE;
    GAPRole_SetParameter( GAPROLE_ADVERT_ENABLED, sizeof( uint8 ), &initial_advertising_enable );

    //CHANGE DATA

    uint8 initial_advertising_enable = TRUE;
    GAPRole_SetParameter( GAPROLE_ADVERT_ENABLED, sizeof( uint8 ), &initial_advertising_enable );

    Where in the application are you trying to make the change to the advert data?
  • Hey,

    I used the following code, and the issue got resolved.

    //Change Data
    GAPRole_SetParameter( GAPROLE_ADVERT_DATA, sizeof ( advertData ),advertData);
    
    uint8 new_adv_enabled_status=TRUE;
    GAPRole_SetParameter( GAPROLE_ADVERT_ENABLED, sizeof( uint8 ), &new_adv_enabled_status );
    
    GAP_UpdateAdvertisingData( simpleBLEBroadcaster_TaskID,TRUE,sizeof ( advertData ),advertData);

    Thank you for your input.