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.

CC2642R: CC2652R: How to remove #2 (long range) advertisement from simple_peripheral project

Part Number: CC2642R
Other Parts Discussed in Thread: CC1352R, CC2652P, CC2652R, CC1352P, SYSCONFIG

CC26x2


Note: The following instructions have been written for SDK 3_40_00_02 but can be adapted to quite any SDK version (that is why I provided the sources but also the diff files). In addition, the code was written for CC2642R but can be adapted to all the devices of the family (CC2652R, CC2652P, CC1352R, CC1352P)


By removing the secondary advertisement (sometimes called "long range" advertisement) from the simple_peripheral example you can significantly save power. The power consumption due to the secondary advertisement (generally long range advertisement) can represent up to 80% of the power consumption of the advertisement period. Please consult the BT-POWER-CALC to have more details regarding power consumption.
In addition, this modification can help you to save memory.

How to do this?

  1. Import the project you want (the OOB simple_peripheral or the project where you have already removed the display function as presented here)
  2. Using SysConfig, reduce the number of Advertisement Set to only 1 (this must be done in BLE > Broadcaster Configuration). This will raise a warning saying we need to update the application code… this is what we are going to do now :)

    Here is a screenshot showing how to proceed. You can also use the SysConfig I have modified for you (it encloses the modifications we required to remove the display)

    Note: It is perfectly normal and expected if the compilation of your project fails after this step… be patient and go to the next step.


    1586.simple_peripheral.syscfg

  3. Modify simple_peripheral.c to remove the code related to the #2 advertisement. For example, you can look for the variable advHandleLongRange and remove the code associated. The code associated to advData2 and advParams2 should also be removed.

    Here is the diff file and the file you are supposed to get if you also removed the display:

    1881.simple_peripheral_remove_long_range_adv.diff
    Fullscreen
    1
    2
    3
    4
    5
    6
    7
    8
    9
    10
    11
    12
    13
    14
    15
    16
    17
    18
    19
    20
    21
    22
    23
    24
    25
    26
    27
    28
    29
    30
    31
    32
    33
    34
    35
    36
    37
    38
    39
    40
    41
    42
    43
    44
    45
    46
    47
    48
    49
    50
    51
    52
    53
    54
    55
    56
    57
    58
    59
    60
    61
    62
    63
    64
    65
    66
    67
    --- C:\ti\simplelink_cc13x2_26x2_sdk_3_40_00_02\examples\rtos\CC26X2R1_LAUNCHXL\ble5stack\simple_peripheral\Application\simple_peripheral_withoutDisplay.c Mon Feb 10 15:50:31 2020
    +++ C:\ti\simplelink_cc13x2_26x2_sdk_3_40_00_02\examples\rtos\CC26X2R1_LAUNCHXL\ble5stack\simple_peripheral\Application\simple_peripheral_SIMPLE.c Tue Feb 11 16:32:11 2020
    @@ -282,7 +282,6 @@
    // Advertising handles
    static uint8 advHandleLegacy;
    -static uint8 advHandleLongRange;
    // Address mode
    static GAP_Addr_Modes_t addrMode = DEFAULT_ADDRESS_MODE;
    @@ -936,26 +935,6 @@
    status = GapAdv_enable(advHandleLegacy, GAP_ADV_ENABLE_OPTIONS_USE_MAX , 0);
    SIMPLEPERIPHERAL_ASSERT(status == SUCCESS);
    - // Create Advertisement set #2 and assign handle
    - status = GapAdv_create(&SimplePeripheral_advCallback, &advParams2,
    - &advHandleLongRange);
    - SIMPLEPERIPHERAL_ASSERT(status == SUCCESS);
    -
    - // Load advertising data for set #2 that is statically allocated by the app
    - status = GapAdv_loadByHandle(advHandleLongRange, GAP_ADV_DATA_TYPE_ADV,
    - sizeof(advData2), advData2);
    - SIMPLEPERIPHERAL_ASSERT(status == SUCCESS);
    -
    - // Set event mask for set #2
    - status = GapAdv_setEventMask(advHandleLongRange,
    - GAP_ADV_EVT_MASK_START_AFTER_ENABLE |
    - GAP_ADV_EVT_MASK_END_AFTER_DISABLE |
    - GAP_ADV_EVT_MASK_SET_TERMINATED);
    -
    - // Enable long range advertising for set #2
    - status = GapAdv_enable(advHandleLongRange, GAP_ADV_ENABLE_OPTIONS_USE_MAX , 0);
    - SIMPLEPERIPHERAL_ASSERT(status == SUCCESS);
    -
    if (addrMode > ADDRMODE_RANDOM)
    {
    SimplePeripheral_updateRPA();
    @@ -988,12 +967,10 @@
    {
    // Start advertising since there is room for more connections
    GapAdv_enable(advHandleLegacy, GAP_ADV_ENABLE_OPTIONS_USE_MAX , 0);
    - GapAdv_enable(advHandleLongRange, GAP_ADV_ENABLE_OPTIONS_USE_MAX , 0);
    }
    else
    {
    // Stop advertising since there is no room for more connections
    - GapAdv_disable(advHandleLongRange);
    GapAdv_disable(advHandleLegacy);
    }
    break;
    @@ -1017,7 +994,6 @@
    // Start advertising since there is room for more connections
    GapAdv_enable(advHandleLegacy, GAP_ADV_ENABLE_OPTIONS_USE_MAX , 0);
    - GapAdv_enable(advHandleLongRange, GAP_ADV_ENABLE_OPTIONS_USE_MAX , 0);
    break;
    }
    @@ -1521,14 +1497,10 @@
    {
    if (autoConnect != AUTOCONNECT_GROUP_A)
    {
    - GapAdv_disable(advHandleLongRange);
    GapAdv_disable(advHandleLegacy);
    advData1[2] = 'G';
    advData1[3] = 'A';
    - advData2[2] = 'G';
    XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX
       8228.simple_peripheral_SIMPLE.C

  4. Compile and test your project… You might have a warning due to SysConfig (this warning only appears if SysConfig is run, i.e. if you modify the content of the SysConfig file or if you “Rebuild” the project). Above that, no warning or error should be raised at build time and the project should still work smoothly!