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.

does broadcast contains some useful data?

Other Parts Discussed in Thread: CC2540

Hi all,

I want to realize that broadcast some useful data to any listeners. 

My first implementation is using one characteristic of one service to send out the data. I set the property of the characteristic as notify.

there is one problem that if listener want to get the data ,it must be connected to the sender. what our manager does just want is listeners can get the data before it is connected to the sender.So I want to add the data to the broadcast package, then make the CC2540 broadcast them.

My question is the contains of the broadcast is fixed after the system finishes initialization , how can I modify it? Because the data I want to broadcast is not fixed.

  • You can revise advertData[] to put your information in it.
  • I can add a few bytes in the advDat[] and broadcast to any listener. but the data I have added cannot be modified ,it still broadcast the fixed data.

    do you know how to modify the advertise data dynamically?

  • Hello,

    Please see the "5.2.1 Peripheral Role" section of the BLE SW Developer's Guide on how to set/update GAP Role params:
    GAPRole_SetParameter(GAPROLE_ADVERT_DATA, sizeof(advertData), advertData);

    Best wishes
  • Hi JXS,

     From the BLE software developper's Guide, I cannot find the 5.2.1 section. I find the 3.4.1  GAP  Peripheral Role Profile , there is one parameter  GAPROLE_PARAM_UPDATE_ENABLE which works only when the device is connected, I want  the device broadcast content modified  dynamically without connected. how do I realize it?

  • It is described in section 5.2.1 Peripheral Role of CC2640 Bluetooth low energy Software Developer's Guide.

  • Thanks for your reply. Also I use CC2540,and the setting in my project is the same with the document wrote.My code is following:


    /***********************************************************************************************************************/
    uint8 initial_advertising_enable = TRUE;//FALSE;

    BLE_State = BLE_STATE_ADVERTISING;
    // By setting this to zero, the device will go into the waiting state after
    // being discoverable for 30.72 second, and will not being advertising again
    // until the enabler is set back to TRUE
    uint16 gapRole_AdvertOffTime = 0;
    uint8 enable_update_request = DEFAULT_ENABLE_UPDATE_REQUEST; //true
    uint16 desired_min_interval = DEFAULT_DESIRED_MIN_CONN_INTERVAL;
    uint16 desired_max_interval = DEFAULT_DESIRED_MAX_CONN_INTERVAL;
    uint16 desired_slave_latency = DEFAULT_DESIRED_SLAVE_LATENCY;
    uint16 desired_conn_timeout = DEFAULT_DESIRED_CONN_TIMEOUT;

    // Set the GAP Role Parameters
    GAPRole_SetParameter( GAPROLE_ADVERT_ENABLED, sizeof( uint8 ), &initial_advertising_enable );
    GAPRole_SetParameter( GAPROLE_ADVERT_OFF_TIME, sizeof( uint16 ), &gapRole_AdvertOffTime );


    GAPRole_SetParameter( GAPROLE_SCAN_RSP_DATA, sizeof ( scanRspData ), scanRspData );
    GAPRole_SetParameter( GAPROLE_ADVERT_DATA, sizeof( advertData ), advertData );//广播数据

    GAPRole_SetParameter( GAPROLE_PARAM_UPDATE_ENABLE, sizeof( uint8 ), &enable_update_request );
    GAPRole_SetParameter( GAPROLE_MIN_CONN_INTERVAL, sizeof( uint16 ), &desired_min_interval );
    GAPRole_SetParameter( GAPROLE_MAX_CONN_INTERVAL, sizeof( uint16 ), &desired_max_interval );
    GAPRole_SetParameter( GAPROLE_SLAVE_LATENCY, sizeof( uint16 ), &desired_slave_latency );
    GAPRole_SetParameter( GAPROLE_TIMEOUT_MULTIPLIER, sizeof( uint16 ), &desired_conn_timeout );
    BLE_DELAY = 20;
    /***********************************************************************************************************************/

    what I want to realize is change the content of the advertData [] dynamically. As my code shows that I have already done the setting GAPRole_SetParameter( GAPROLE_PARAM_UPDATE_ENABLE, sizeof( uint8 ), &enable_update_request );
    But the broadcast content has not been modified.

    what I have modifed is when the data from other MCU is received by CC2540 though UART, I close the braodcast , modify the advertData[], then open the broadcast and update . But the broadcast content does not modify. The modfiying advertData[] code is following:

    /***********************************************************************************************************************/
    extern uint8 advertData[];
    static uint8 tempCount = 0;
    uint8 initial_advertising_temp_enable = FALSE;

    GAPRole_SetParameter( GAPROLE_ADVERT_ENABLED, sizeof( uint8 ), &initial_advertising_temp_enable );//先关闭广播,对内容进行修改。

    tempCount++;
    tempCount %= 250;
    advertData[advertDataLength - 1] = tempCount;

    HCI_LE_SetAdvDataCmd(advertDataLength,advertData);
    GAP_UpdateAdvertisingData( sensorTag_TaskID, TRUE, advertDataLength, advertData );
    initial_advertising_temp_enable = TRUE;

    GAPRole_SetParameter( GAPROLE_ADVERT_ENABLED, sizeof( uint8 ), &initial_advertising_temp_enable );
    /***********************************************************************************************************************/

    anything wrong? How can I realzie my purpose?