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.

CC2340R5: CC2340R5 : Multiple advertising at a time.

Part Number: CC2340R5
Other Parts Discussed in Thread: SYSCONFIG

Hello. 

I'm Rushikesh. 

I'm using CC2340R5 and SDK 7.20. 

I want to advertise data into burst mode, for example: I want to advertise 5 times with delay of less than 10ms in between each advertisement and go to standby state for 10 seconds.

And repeat this cycle.

Please guide me how to achieve this.

Thanks & Regards,

Rushikesh.

  • Hi Rushikesh,

    Per Bluetooth specifications, the minimum advertising interval is 20 ms. You can workaround this limitation by enabling simultaneously several advertising sets.

    In order to enable a second advertising set (or more), create a new advertising set in SysConfig (this will raise a benign warning) and ensure to initialize it (BLEAppUtil_initAdvSet) and enable it (BLEAppUtil_advStart / BLEAppUtil_advStop) as already done in the app_peripheral.c file for the existing advertisement.

    Limited advertising can be set using the field "durationOrMaxEvents" of the structure BLEAppUtil_AdvStart_t passed to BLEAppUtil_advStart.

    I hope this will help,

    Best regards,

  • Hello Clement, 

    I've done this and able to advertise 7 times before going to standby state for 30 seconds. 

    But, currently I'm advertising using a GPIO interrupt. i.e. I'm advertising only when a GPIO interrupt occurs. 

    For this, my current code works well with single advertising when interrupt generates. 

    But, I want to advertise 7 sets one by one before going to standby state with interrupt code. 

    Please suggest how can I achieve this. I have tried to add advertisement sets in syscfg and initialize & start them using broadcasterAdvHandle_1  and broadcasterStartAdvSet1 in Broadcaster_start();  like below: But it does not work as my code goes into the ICall_abort(void) function.

        /*For SET 2*/
        status = BLEAppUtil_initAdvSet(&broadcasterAdvHandle_2, &broadcasterInitAdvSet2);
        if(status != SUCCESS)
        {
            // Return status value
            return(status);
        }
    
        status = BLEAppUtil_advStart(broadcasterAdvHandle_2, &broadcasterStartAdvSet2);
        if(status != SUCCESS)
        {
            // Return status value
            return(status);
        }

    Below is my code for the interrupt.

    1)Interrupt Config:

    void mainThread(void)
    {
        /* Configure GPIO pin */
        GPIO_setConfig(CONFIG_GPIO_EXT_WAKEUP, GPIO_CFG_IN_PD | GPIO_CFG_IN_INT_FALLING);  //Since, low & high value interrupts are not available for Low Power F3 devices
    
    //    GPIO_setConfig(CONFIG_GPIO_EXT_WAKEUP, GPIO_CFG_IN_INT_FALLING);
    
        /* Install GPIO Interrupt callback */
        GPIO_setCallback(CONFIG_GPIO_EXT_WAKEUP, gpioButtonFxn0);
    
        /* Enable interrupts */
        GPIO_enableInt(CONFIG_GPIO_EXT_WAKEUP);
    
    }

    2)Callback:

    /*Interrupt Callback*/
    void gpioButtonFxn0(uint8_t index)
    {
        BLEAppUtil_invokeFunctionNoData(enableAdvertising);
    }

    3)Enabling Advertisement:

    void enableAdvertising()
    {
        bStatus_t status;
    
        /*Set 1*/
        BLEAppUtil_advStart(broadcasterAdvHandle_1, &broadcasterStartAdvSet1);
        /*Don't free anything since we're going to use the same buffer to re-load*/
        status = GapAdv_prepareLoadByBuffer(advData1, FALSE);
    
        if (status == SUCCESS)   /*   Only update the data when return is successful*/
        {
    
            SensorMeasure();   /*Read sensor value from i2c*/
    
            uint8_t ADV_DATA2_LEN = sizeof(advData1); /* Reload buffer to handle*/
    
            GapAdv_loadByBuffer(ADV_DATA2_LEN, advData1);
    
        }
    }

    4)Disabling advertisement in void Broadcaster_AdvEventHandler(uint32 event, BLEAppUtil_msgHdr_t *pMsgData) in app_broadaster.c

        switch(event)
        {
            case BLEAPPUTIL_ADV_START_AFTER_ENABLE:
            {
                MenuModule_printf(APP_MENU_ADV_EVENT, 0, "Adv status: Started - handle: "
                                  MENU_MODULE_COLOR_YELLOW "%d" MENU_MODULE_COLOR_RESET,
                                  advData->pBuf->advHandle);
                break;
            }
    
            case BLEAPPUTIL_ADV_END_AFTER_DISABLE:
            {
                MenuModule_printf(APP_MENU_ADV_EVENT, 0, "Adv status: Ended - handle: "
                                  MENU_MODULE_COLOR_YELLOW "%d" MENU_MODULE_COLOR_RESET,
                                  advData->pBuf->advHandle);
                break;
            }
    
            case BLEAPPUTIL_ADV_END:
            {
                MenuModule_printf(APP_MENU_ADV_EVENT, 0, "Adv just ssent: - handle: "
                                  MENU_MODULE_COLOR_YELLOW "%d" MENU_MODULE_COLOR_RESET,
                                  ((BLEAppUtil_AdvEventData_t *)pMsgData)->pBuf->advHandle);
    
                // Disable advertisement
                BLEAppUtil_advStop(broadcasterAdvHandle_1);
                break;
            }
    5)

    BLEAppUtil_EventHandler_t broadcasterAdvHandler =
    {
        .handlerType    = BLEAPPUTIL_GAP_ADV_TYPE,
        .pEventHandler  = Broadcaster_AdvEventHandler,
        .eventMask      = BLEAPPUTIL_ADV_START_AFTER_ENABLE |
                          BLEAPPUTIL_ADV_END_AFTER_DISABLE | BLEAPPUTIL_ADV_END
    
    };

    Please let me know if any concern. 

    Regards,

    Rushikesh.

  • Hi Rushikesh,

    Please see the following guidance to trigger execution on clock interrupts - https://dev.ti.com/tirex/content/simplelink_academy_for_cc23xx_7_40_00_00/_build_simplelink_academy_for_cc23xx_7_40_00_00/source/cc2340rx_04_connections.html#task-3-create-a-oneshot-or-periodic-clock-using-clockp-module

    I am not sure I understand why you need 7 advertisement sets, but the issue you are experiencing seems to be caused by the configuration of the advertising set. Ensure you have configured the second advertising set exactly as the first one, without missing the scan response or any other element. Also, ensure the structures broadcasterInitAdvSet1/broadcasterInitAdvSet2 and broadcasterStartAdvSet1/broadcasterStartAdvSet2 are correct.

    Hope this will help,

    Best regards,

  • Hello Clement, 

    Let me explain,

    I have a sensor which is connected to BLE CC2340R5 and it sends an interrupt periodically(10s) to wakeup BLE from standby.

    And also, sends data 'x' to the BLE through I2C. 

    Now at BLE side, I want to advertise this data 'x' 7 times and then put BLE to standby state until next interrupt occurs(After 10s).

    Please check below current waveform so you could understand better how I want the advertisement to happen.

      

    This is not working within the interrupt code.

    So, I wanted to understand more about advertising in this way. 

    Hope you understood.

    Regards,

    Rushikesh.

  • Hi Rushikesh,

    - Consider using the parameter advSetStartParamsSet_1.enableOptions and advSetStartParamsSet_1.durationOrMaxEvents to control the number of times the advertisement set is transmitted before being disabled

    - Review the content of your function enableAdvertising. Among others: you should not modify the advertising data after calling BLEAppUtil_advStart. The way I suggest to write enableAdvertising function is:

    1. Read the sensor data
    2. Update the content of advData1
    3. Call BLEAppUtil_advStart

    GapAdv_prepareLoadByBuffer API should not be mixed with the BLEAppUtil APIs as both have impact on the same data and may create conflicts.

    I hope this will help,

    Regards,

  • Hello Clement, 

    I'm following the same code flow you have mentioned here. 

    It is not working properly. 

    After calling GapAdv_prepareLoadByBuffer(advData1, FALSE); function it goes into the timeout error in 

     (icall_directAPI(ICALL_SERVICE_CLASS_BLE, (uint32_t) IDX_GapAdv_prepareLoadByBuffer , ##__VA_ARGS__))

    and 

    goes into the while loop of  ICall_abort(); function.

    1.Does the timeout error occurring because I'm calling GapAdv_prepareLoadByBuffer(advData1, FALSE); and GapAdv_loadByBuffer(ADV_DATA2_LEN, advData1);  multiple times?

    2.What is the exact condition or method to use these APi's in order to advertise same data multiple times?

    Regards,

    Rushikesh.

  • Hi,

    In the suggestion below,

    • Read the sensor data
    • Update the content of advData1
    • Call BLEAppUtil_advStart

    I am suggesting to directly modify the content of advData1. GapAdv_prepareLoadByBuffer / GapAdv_loadByBuffer should NOT be used.

    Regards,

  • Hello Clement, 

    This works fine for a single broadcasting. 

    However, I want to broadcast 7 times and it isn't working as expected. 

    I'm calling BLEAppUtil_advStart(broadcasterAdvHandle_1, &broadcasterStartAdvSet1); function

    7 times in interrupt callback function. But it is broadcasting only one time. 

    Also, I've tried to call 4 different  sets configured in syscfg in the same callback as well. 

    void enableAdvertising()
    {
        SensorMeasure();   /*Read sensor value from i2c*/
    
        BLEAppUtil_advStart(broadcasterAdvHandle_1, &broadcasterStartAdvSet1);
    
        BLEAppUtil_advStart(broadcasterAdvHandle_2, &broadcasterStartAdvSet2);
    
        BLEAppUtil_advStart(broadcasterAdvHandle_3, &broadcasterStartAdvSet3);
    
        BLEAppUtil_advStart(broadcasterAdvHandle_4, &broadcasterStartAdvSet4);
    }

    Still this is also not working. 

    Regards,

    Rushikesh.

  • Hi,

    BLEAppUtil_advStart should be called in a task context.

    If I may, it is still unclear to me why you want to use 7 advertising sets (instead of 1 advertising set that is being repeated multiple times).

    Also, can you explain how you verify the number of advertising sets working?

    Regards,

  • Hello Clement,

    Its not that I want to use 7 advertising sets I just want to advertise  the same data 7 times. 

    I've tried both the solutions(using 7 advertising sets and 1 adv set repeating multiple times) but its not working.

    Also, I'm verifying it through a sniffer tool and the device's current measurement tool where I get current spikes of advertisement. 

    Please check above attached image of the waveform for the same.

    Regards, 

    Rushikesh.

  • Hi,

    Its not that I want to use 7 advertising sets I just want to advertise  the same data 7 times. 

    Let's then focus on having only one advertising set.

    Ensure the following:

    - data is set before turning on advertisement

    - status SUCCESS is reported by the BLEAppUtil_advStart

    - BLEAppUtil_advStart is called in a ICall enabled task context

    - in case advertising does not work check if the program crashed and collect debug information

    Please check above attached image of the waveform for the same.

    Are the wave-forms quoted below the ones you were referring to? What are the results you are getting now?

      

    Best regards,

  • Hello Clement, 

    1.Data is set before turning on advertisement.

    2.I get state SUCCESS if I'm advertising single set. (Did not get state success when multiple adv sets.)

    3.BLEAppUtil_advStart is called in a ICall enabled task context.

    - I didn't understand exactly. Can you show me an example?

    4.For single set, advertising works fine. But for multiple sets it goes into the ICall_Abort(); 

    5.Yes, the waveforms are the one which I should get on advertising within interrupt code. 

    6.For now, I'm trying to generate interrupt multiple times instead of calling a single set multiple times. But this consumes more power and also increases the run time of both BLE and sensor. 

    Regards,

    Rushikesh.

  • Hi,

    3.BLEAppUtil_advStart is called in a ICall enabled task context.

    - I didn't understand exactly. Can you show me an example?

    This element is explained here: https://software-dl.ti.com/simplelink/esd/simplelink_lowpower_f3_sdk/7.40.00.64/exports/docs/ble5stack/ble_user_guide/html/ble-stack-5.x/the-application-cc23xx.html?highlight=bleapputil_stackregister#processing-stack-events-from-the-icall-message-queue

    But this seems to be correct as single advertisement is working

    4.For single set, advertising works fine. But for multiple sets it goes into the ICall_Abort(); 

    As you mentioned before, you seem to need only one advertising set. So I would suggest to not focus on this for the moment.

    Let me know if more support is required.

    Best regards,

  • Hello Clement, 

    I think I should try and implement a different method to be able to achieve the given application. 

    Thank you for your support. 

    Will let you know if I need your support. 

    Regards,

    Rushikesh.