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.

[FAQ] CC2642R: Periodic Advertising with CC2642R / CC2652R7

Part Number: CC2642R
Other Parts Discussed in Thread: CC2652R, CC2652R7, SYSCONFIG

Hi,

Here are some steps to enable periodic advertising on CC2642R, CC2652R or CC2652R7.

This guide assumes you are using the simple_peripheral example for the device selected. This guide has been tested on SDK 7.10.00.98.

1- Enable support for Periodic Advertising in SysConfig

2- Create a new advertising set in SysConfig

3- Setup the advertising data for the newly created advertisement set

4- Save and close SysConfig

5- (Optional) Disable the other advertisements set by commenting out the "GapAdv_enable" commands found

6- Add the global data needed

 // Create non connectable & non scannable advertising
#define GAPADV_PARAMS_AE_NC_NS {                                           \
  .eventProps = 0,                                                         \
  .primIntMin = 160,                                                       \
  .primIntMax = 160,                                                       \
  .primChanMap = GAP_ADV_CHAN_ALL,                                         \
  .peerAddrType = PEER_ADDRTYPE_PUBLIC_OR_PUBLIC_ID,                       \
  .peerAddr = { 0xaa, 0xaa, 0xaa, 0xaa, 0xaa, 0xaa },                      \
  .filterPolicy = GAP_ADV_WL_POLICY_ANY_REQ,                               \
  .txPower = GAP_ADV_TX_POWER_NO_PREFERENCE,                               \
  .primPhy = GAP_ADV_PRIM_PHY_1_MBPS,                                      \
  .secPhy = GAP_ADV_SEC_PHY_1_MBPS,                                        \
  .sid = 1                                                                 \
}

static uint8 advHandleNCNS;      // Non-Connactable & Non-Scannable

// Periodic Advertising Data

static uint8_t periodicData[] =

{
  'P',
  'e',
  'r',
  'i',
  'o',
  'd',
  'i',
  'c',
  'A',
  'd',
  'v'
};

7- Add the following code at the end of the handling of the GAP_DEVICE_INIT_DONE_EVENT event in SimplePeripheral_processGapMessage()

        // Create Advertisement set #3 and assign handle
        GapAdv_params_t advParamNonConn = GAPADV_PARAMS_AE_NC_NS;

        status = GapAdv_create(&SimplePeripheral_advCallback, &advParamNonConn,
                                             &advHandleNCNS);

        // Load advertising data for set #3 that is statically allocated by the app
        status = GapAdv_loadByHandle(advHandleNCNS, GAP_ADV_DATA_TYPE_ADV,
                                     sizeof(advData3), advData3);


        // Set event mask for set #3
        status = GapAdv_setEventMask(advHandleNCNS,
                                     GAP_ADV_EVT_MASK_START_AFTER_ENABLE |
                                     GAP_ADV_EVT_MASK_END_AFTER_DISABLE |
                                     GAP_ADV_EVT_MASK_SET_TERMINATED);


        // Enable non connectable & non scannable advertising for set #3
        // This is a must in order to enable periodic advertisement
        status = GapAdv_enable(advHandleNCNS, GAP_ADV_ENABLE_OPTIONS_USE_MAX , 0);


        // Set Periodic Advertising parameters
        GapAdv_periodicAdvParams_t perParams = {240, 240, 0x40};
        status = GapAdv_SetPeriodicAdvParams(advHandleNCNS, &perParams);

8- Add the handling for GAP_ADV_SET_PERIODIC_ADV_PARAMS_EVENT and GAP_ADV_SET_PERIODIC_ADV_DATA_EVENT events within SimplePeripheral_processGapMessage()

    case GAP_ADV_SET_PERIODIC_ADV_PARAMS_EVENT:
    {
        uint8_t status;
        GapAdv_periodicAdvData_t periodicDataParams = {0x03, sizeof(periodicData), periodicData};
        status = GapAdv_SetPeriodicAdvData(advHandleNCNS, &periodicDataParams);
    }
    break;

    case GAP_ADV_SET_PERIODIC_ADV_DATA_EVENT:
    {
        uint8_t status;
        status = GapAdv_SetPeriodicAdvEnable(1, advHandleNCNS);
    }
    break;

9- (Optional) Enable the RF Observables as described in the Debugging Guide (really useful when not having a Bluetooth Sniffer).
In main.c add the following include: "#include <driverlib/ioc.h>"

Then add the following code right after Board_initGeneral()

  // Map LNA enable pin RFC_GPO0 to DIO6
  IOCPortConfigureSet(IOID_6, IOC_PORT_RFC_GPO0,
                      IOC_IOMODE_NORMAL);
  // Map Tx start pin RFC_GPO3 to DIO7
  IOCPortConfigureSet(IOID_7, IOC_PORT_RFC_GPO3,
                      IOC_IOMODE_NORMAL);

10- Build the code and flash the device

Hexfile for CC26X2R1 LaunchPad enabling periodic advertising: /cfs-file/__key/communityserver-components-multipleuploadfilemanager/d35fa551_2D00_8bfa_2D00_42ea_2D00_8c7f_2D00_ea501b1a1ce7-370266-complete/simple_5F00_peripheral_5F00_CC26X2R1_5F00_LAUNCHXL_5F00_tirtos7_5F00_ticlang.hex

Hexfile for CC2652R7 LaunchPad enabling periodic advertising: /cfs-file/__key/communityserver-discussions-components-files/538/simple_5F00_peripheral_5F00_LP_5F00_CC2652R7_5F00_tirtos7_5F00_ticlang.hex

Please also check Synchronizing with a periodic advertising train - https://e2e.ti.com/support/wireless-connectivity/bluetooth-group/bluetooth/f/bluetooth-forum/1295835/faq-cc2642r-synchronizing-with-a-periodic-advertising-train-cc2642r-cc2652r7

I hope this will help,

Best regards,