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.

CC2640R2F: How to enable the long range feature of BLE5 in advertising and scanning?

Part Number: CC2640R2F

Working with CC2640R2F, SDK 2.2 and simplecentral project.

I want to set simplecentral as a pure observer role and would never create connection. The corresponding simpleperipheral would advertising data and support creating connection. It's said that BLE5 is 4 times cover range of BLE4.2, so in my occasion, how could i set BLE5 featured advertising and scanning?

What's more, if i have configured the device with BLE5 featured advertising and scanning, may i compare the communication range to that of BLE4.2? What should i do to get the compare result?

I have searched answer on the forum, but suggestion are given based on different SDK version, so, be aware that i'm working on SDK 2.2.

Looking forward to your reply.

  • Hi,

    I would look at the Bluetooth 5 SimpleLink Academy for Scanning and Advertising here: dev.ti.com/.../
    This also applies to Bluetooth 5 on CC2640R2F. Additionally you should study the BLE Stack User´s Guide.

    We have a range calculator here: www.ti.com/.../rf-range-estimator For practical measurements you can simply compare the same applications running 1 Mbps and Coded PHY advertising.

    Regards,
    Fredrik
  • Hi fredrik
    The academy has updated and there's nothing about long range advertising.
    Well in fact, i have already learned lessons in academy, but there're still something unclear.
    1. PHY
    There's parameters about phy the advertiser using, but what's the difference? Since long range feature of BLE5 means redundancy algorithm in signal modulation, and there's 2M_PHY, 1M_PHY and Coded_PHY, if i want to use the longest modulation method, which phy should i choose? By the way, what does coded_phy means? Is it a fixed value or a phy that should configured by the users?
    2.channels
    It's said that BLE5 can advertising on secondary channels, which means channels except 37, 38,39, is this means it can advertise on all channels? But i didn't find parameter of this, the GAP_ADV_CHAN_ALL means 37 38 39, so it seems there's no way to make device adv on data channels. By the way, how does it adv on secondary channel? because there're up to 37 channels, adv all over on these channels will take lots of time. This seems unuseful.
    3.adv data of long range adv
    Since if we want to use extension adv, ADV_EXT_IND is necessary, but who is responsible for this? Do us users need to configure it or it would be completed by BLE stack?

    Questions may be a little complex, sorry for that, due to i'm still freshman for BLE stack layer.
    Looking forward to your reply and thanks for your time.
  • Part Number: CC2640R2F

    I'm using CC2640R2F, with SDK version 2.2.

    Since i want to enable advertising with the longest range, so i study documentation about advertising and scanning, but the conceptions confuses me. And i don't know what to do with my project.

    1.secondary channels

    Since BLE5 supports extended advertising and scanning on secondary channels, must advertising this way use BLE5 featured PHY, like LE Coded S2?

    More importantly, would it advertising on all secondary channels? This may lead the advertising duration very long.

    What't more, when should i choose to adv on secondary channels? Since we know,we can also use extended adv on legacy adv channels (37~39).

    2.LE Coded phy

    Let's put the most important question in the beginning, does LE Coded S=8 cover the largest area?

    If i create two advertising set, and one of them is using LE Coded s=8 pHY, the other is uncoded phy,like 1M or 2M, after creating connection with a central device, what channel would they communicate on?

    3.the combination

    The above two aspects, does they tied with each other in some situations or they are parellel? 

    When using extended advertising, is the corresponding phy must be coded or users can set whatever legal?

    I didn't find any example project in the SDK, is there any documentation detailed available? By the way, i have already read materials in simplelink academy.

  • 1. Coded PHY is long range mode.
    2. This is documented in the User´s Guide: dev.ti.com/.../gap.html
    3. See 2.

    Regards,
    Fredrik
  • I merged your two threads since they are about the same topic.

    In general I would recommend you to review the Bluetooth specification and the TI BLE Stack User´s Guide to answer your questions.

    1. Coded PHY Advertising does not necessarily require extended advertising, but typically you would use it. You only advertise on one single auxiliary channel for each advertising interval.
    2. S8 coding will give you lowest sensitivity and thus best range. Connections communicate on the data channels.
    3. Advertising extensions can be on any PHY.

    Regards,
    Fredrik
  • Hi Fredrik

    Thanks for your answer, it helps.

    In fact, i'm trying to realize a design that advertising about 100 bytes and covering the largest area at the same time, but things about LE Coded phy and extended adv confuse me, i can't tell them apart very clearly.

    Here i would past my code here, please help me check whether my code satisfies my needs.

    Codes of simple central project:

    static void SimpleCentral_processGapMsg(gapEventHdr_t *pMsg)
    {
      switch (pMsg->opcode)
      {
        case GAP_DEVICE_INIT_DONE_EVENT:
        {
          uint8_t temp8;
          uint16_t temp16;
          gapDeviceInitDoneEvent_t *pPkt = (gapDeviceInitDoneEvent_t *)pMsg;
    
          // Setup scanning
          // For more information, see the GAP section in the User's Guide:
          // software-dl.ti.com/.../
    
          // Register callback to process Scanner events
          GapScan_registerCb(SimpleCentral_scanCb, NULL);
    
          // Set Scanner Event Mask
          GapScan_setEventMask(GAP_EVT_SCAN_ENABLED | GAP_EVT_SCAN_DISABLED |
                               GAP_EVT_ADV_REPORT);
    
          // Set Scan PHY parameters
          GapScan_setPhyParams(DEFAULT_SCAN_PHY, SCAN_TYPE_ACTIVE,SCAN_PARAM_USER_INTERVAL, SCAN_PARAM_USER_INTERVAL);
      //                         SCAN_PARAM_DFLT_INTERVAL, SCAN_PARAM_DFLT_INTERVAL);
    
          // Set Advertising report fields to keep
          temp16 = SC_ADV_RPT_FIELDS;
          GapScan_setParam(SCAN_PARAM_RPT_FIELDS, &temp16);
          // Set Scanning Primary PHY
          temp8 = SCAN_PRIM_PHY_CODED;//DEFAULT_SCAN_PHY;
          GapScan_setParam(SCAN_PARAM_PRIM_PHYS, &temp8);
          // Set LL Duplicate Filter
          temp8 = SCAN_FLT_DUP_ENABLE;
          GapScan_setParam(SCAN_PARAM_FLT_DUP, &temp8);
    
          // Set PDU type filter -
          // Only 'Connectable' and 'Complete' packets are desired.
          // It doesn't matter if received packets are
          // whether Scannable or Non-Scannable, whether Directed or Undirected,
          // whether Scan_Rsp's or Advertisements, and whether Legacy or Extended.
          temp16 = SCAN_FLT_PDU_CONNECTABLE_ONLY | SCAN_FLT_PDU_COMPLETE_ONLY;
          GapScan_setParam(SCAN_PARAM_FLT_PDU_TYPE, &temp16);
    
          scMaxPduSize = pPkt->dataPktLen;
    #if defined(BLE_V42_FEATURES) && (BLE_V42_FEATURES & PRIVACY_1_2_CFG)
          if (addrMode > ADDRMODE_RANDOM)
          {
            // Update the current RPA.
            memcpy(rpa, GAP_GetDevAddress(FALSE), B_ADDR_LEN);
    
            Display_print_user(dispHandle, SC_ROW_RPA, 0, "RP Addr: %s",
                           Util_convertBdAddr2Str(rpa));
    
            // Create one-shot clock for RPA check event.
            Util_constructClock(&clkRpaRead, SimpleCentral_clockHandler,
                                SC_READ_RPA_PERIOD, 0, true, SC_EVT_READ_RPA);
          }
    #endif // PRIVACY_1_2_CFG
    
          Util_constructClock(&clkScanOpen, SimpleCentral_clockHandler,
                              SC_SCAN_PERIOD, 0, false, SC_EVT_OPEN_SCAN);
    
          SimpleCentral_doSetScanPhy(1);//SCAN_PRIM_PHY_CODED
          SimpleCentral_doDiscoverDevices(1);//GapScan_enable
          Display_print_user0(dispHandle, 7, 0, "waiting for methane alarm data...");
          break;
        }
    ...
      }
    }

    There is only SCAN_PRIM_PHY_CODED, no option that clearly points to S=2 or S=8.

    Codes of simple peripheral project:

    static void SimplePeripheral_processGapMessage(gapEventHdr_t *pMsg)
    {
      switch(pMsg->opcode)
      {
        case GAP_DEVICE_INIT_DONE_EVENT:
        {
          bStatus_t status = FAILURE;
    
          gapDeviceInitDoneEvent_t *pPkt = (gapDeviceInitDoneEvent_t *)pMsg;
    
          if(pPkt->hdr.status == SUCCESS)
          {
    ......
    
            // Use long range params to create long range set #2
            GapAdv_params_t advParamLongRange = GAPADV_PARAMS_AE_LONG_RANGE_CONN;
            advParamLongRange.primPhy = GAP_ADV_PRIM_PHY_CODED_S8;
            advParamLongRange.secPhy = GAP_ADV_SEC_PHY_CODED_S8;                  //use long range phy
            // Create Advertisement set #2 and assign handle
            status = GapAdv_create(&SimplePeripheral_advCallback, &advParamLongRange,
                                   &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,
                                         advertDataLength, advertData);//
            SIMPLEPERIPHERAL_ASSERT(status == SUCCESS);
    
            // Load scan response data for set #2 that is statically allocated by the app
            status = GapAdv_loadByHandle(advHandleLongRange, GAP_ADV_DATA_TYPE_SCAN_RSP,
                                         sizeof(scanRspData), scanRspData);
            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 defined(BLE_V42_FEATURES) && (BLE_V42_FEATURES & PRIVACY_1_2_CFG)
            if (addrMode > ADDRMODE_RANDOM)
            {
              SimplePeripheral_updateRPA();
    
              // Create one-shot clock for RPA check event.
              Util_constructClock(&clkRpaRead, SimplePeripheral_clockHandler,
                                  SP_READ_RPA_EVT_PERIOD, 0, true,
                                  (UArg) &argRpaRead);
            }
    #endif // PRIVACY_1_2_CFG
          }
    
          break;
        }
    ......
      }
    }

    The above are my codes. Is it correct corresponding to my design?

    And in my last post, i mis-spell a word, what i want to ask is, if i use LE Coded phy and LE 1M phy, after the connection's created, what phy would the devices in connection use to communicate?

    Thank you for your time and looking forward to your reply.

  • Hi Fredrik
    Are you online? I'm still waiting for your answer.
  • Please refer to the documentation for details on how to implement the various features.

    If you run multiple advertisement sets with different PHYs, the connection PHY will depend on which advertisement the connection is established on.

    Regards,
    Fredrik
  • I have found the problem.

    There's conflict in parameter settings, default scan phy is not coded phy. After i make default scan phy coded phy, the code runs well.