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.

Set AdvertData during initialization

Hello,

I am using the SensorTag platform running the SensorTag example without changing any line of code and I found that during the initialization, exactly during the SensorTag_init() function, setting the parameter GAPROLE_ADVERT_DATA with the GAPRole_SetParameter() API returns an error. Exactly the GAP_UpdateAdvertisingData() function returns a bleIncorrectMode error (0x12). This happens only during initialization but I am a bit afraid because this error means a mismatch with the ble role but I did not change anything in the Stack configuration, I am just debugging with a JTAG USB probe. Can you please let me know what is the situation?
Thank you.

Kind Regards,

Simone Frau

  • I found a way to have a SUCCESS return value when I set the GAPROLE_ADVERT_DATA inside the SensorTag_init() function. I changed only the following lines in the SensorTag example code:


    /*******************************************************************************
    * @fn SensorTag_init
    *
    * @brief Called during initialization and contains application
    * specific initialization (ie. hardware initialization/setup,
    * table initialization, power up notification, etc), and
    * profile initialization/setup.
    *
    * @param none
    *
    * @return none
    */
    static void SensorTag_init(void)
    {
    ...

    // Setup the GAP Peripheral Role Profile
    {
    // For all hardware platforms, device starts advertising upon initialization
    uint8_t initialAdvertEnable = FALSE;

    ...

    // Set the GAP Role Parameters
    GAPRole_SetParameter(GAPROLE_ADVERT_ENABLED, sizeof(uint8_t),
    &initialAdvertEnable);

    ...

    //GAPRole_SetParameter(GAPROLE_ADVERT_DATA, sizeof(advertData), advertData);

    ...

    // Start the Device
    GAPRole_StartDevice(&SensorTag_gapRoleCBs);

    initialAdvertEnable = TRUE;

    GAPRole_SetParameter(GAPROLE_ADVERT_ENABLED, sizeof(uint8_t),
    &initialAdvertEnable);

    GAPRole_SetParameter(GAPROLE_ADVERT_DATA, sizeof(advertData), advertData);

    ...
    }


    Then what I am doing now is just start the device without advertising, and only after the GAPRole_StartDevice() enable the advertising and set the data. Please let me know if this procedure is correct or there are side effects that I do not know, thank you.

    Kind Regards,


    Simone Frau
  • I don't see GAP_UpdateAdvertisingData() getting called in the init function of the BLE 2.2.0 release. Where are you seeing this?
  • Hello Tim,

    unfortunately I am still working with BLE 2.1.1, are you no more supporting that?