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: Device discovery didn't found some devices

Part Number: CC2640R2F
Other Parts Discussed in Thread: LAUNCHXL-CC2640R2

Hello,

We are currently working on a project with the following details:

Device CC2640R2LAUNCHXL
SDK simplelink_cc2640r2_sdk_4_40_00_10
IDE IAR8.32.2
Reference Project

multi role project

We have the following setup

Here the following are happening:

  1. A1 behaves as central device in continuous scan mode with the following scan parameters
    TGAP_GEN_DISC_SCAN = 0
    TGAP_CONN_SCAN_INT = 80
    TGAP_CONN_SCAN_WIND = 80
    TGAP_CONN_HIGH_SCAN_INT = 80
    TGAP_CONN_HIGH_SCAN_WIND = 80
    TGAP_GEN_DISC_SCAN_INT = 80
    TGAP_GEN_DISC_SCAN_WIND = 80
    TGAP_LIM_DISC_SCAN_INT = 80
    TGAP_LIM_DISC_SCAN_WIND = 80
    TGAP_CONN_EST_SCAN_INT = 80
    TGAP_CONN_EST_SCAN_WIND = 80

    GAPRole_StartDiscovery is started with DEVDISC_MODE_GENERAL without whitelisting enabled

  2. In the central application, every time scan is started, we are cancelling any ongoing scan, clearing the whitelist and then starting the scan.

  3. At first when peripheral B is out side the range of A1, A1 gets the GAP_DEVICE_INFO_EVENT callback for all the advertisers, which are kept closer to A1, rapidly as they are advertising every 100ms.

  4. Now if we slowly move B into range, the expectation is for A1 to get the GAP_DEVICE_INFO_EVENT callback for B as well.

  5. We observed that A1 will not receive the callback for discovering the advertisements of B even when B is kept very close to A1.

We are enabling whitelist in below method:

1. Cancel discovery ->  GAPRole_CancelDiscovery();

2. Clear white list -> HCI_LE_ClearWhiteListCmd();

3. If whitelist needed then setting the whitelist ->  HCI_LE_AddWhiteListCmd( HCI_PUBLIC_DEVICE_ADDRESS, <DeviceMac> );

4. If whitelist enabled then start scan with whitelist enable option. else whitelist disabled. -> 

 GAPRole_StartDiscovery(SCANM_DEFAULT_DISCOVERY_MODE, SCANM_DEFAULT_DISCOVERY_ACTIVE_SCAN, whiteListfilter);
Also please educate us with better method of whitelisting.
Thanks
Niranjan
  • Hi Niranjan,

    Thank you for reaching out.

    • Could you please confirm the device is detected when it is enabled while already close to the scanner?
    • Could you please specify the advertisement parameters used by the device?
    • Could you please specify the scan filtering used?

    Best regards,

  • Hi Niranjan,

    On top of providing answers for Clement's questions, can you clarify if B is detected by A during any circumstance?

    Best Regards,

    Jan

  • Thank you for your prompt reply.

    1. When the peripheral is brought close to the scanner, the scanner is still not able to find the peripheral

    2. The advertising parameters are as follows:

      1. 24byte packets sent @100ms

      2. GAPROLE_ADVERT_ENABLED set to true for connectable advertisements

    3. In a noisy bluetooth environment, we want to filter out only one of the bluetooth devices (set by the application) and connect to it.

    4. If I stop and restart the scan on the scanner A1, then it will be able to find B provided B is within range.

      Regards,
      Niranjan

  • Hi Niranjan,

    Got it. Is the behavior still present if the environment is not noisy? Can you describe the behavior that occurs if you place B outside of A1s range, turn on both devices, then slowly bring B into the range of A1? Are you able to see an advertisement for B in this case? In this experiment, leave all the other peripheral devices off.

    Can you try increasing the scan  interval and scan window to see if this has an effect? Are all the peripherals in this network running the same firmware and advertising parameters?

    Best Regards,

    Jan

  • Hi Jan,

    Thanks for quick reply. 

    We have also extended our tests with base mutli_role example of SDK simplelink_cc2640r2_sdk_5_30_00_03. 

    Let say we have 2 devices M1(Scanner) and  M2 (Acts as advertiser)

    • Where we have configured M1 with below parameter

    1.   #define DEFAULT_SCAN_DURATION                 0  //Set the continuous scanning.

    // Scan parameters
    #define DEFAULT_SCAN_DURATION                 0
    #define DEFAULT_SCAN_WIND                     80
    #define DEFAULT_SCAN_INT                      80

    2. Make Passive scanning

    #define DEFAULT_DISCOVERY_ACTIVE_SCAN         FALSE
    3. And below are our scan parameters. Extra we have disabled the "
    TGAP_FILTER_ADV_REPORTS" filter.
    static void multi_role_init(void)
    {
       /* Above other configurations as in original multirole project. */
       
        // Set scan duration
        GAP_SetParamValue(TGAP_GEN_DISC_SCAN, DEFAULT_SCAN_DURATION);
    
        // Scan interval and window the same for all scenarios
        GAP_SetParamValue(TGAP_CONN_SCAN_INT, DEFAULT_SCAN_INT);
        GAP_SetParamValue(TGAP_CONN_SCAN_WIND, DEFAULT_SCAN_WIND);
        GAP_SetParamValue(TGAP_CONN_HIGH_SCAN_INT, DEFAULT_SCAN_INT);
        GAP_SetParamValue(TGAP_CONN_HIGH_SCAN_WIND, DEFAULT_SCAN_WIND);
        GAP_SetParamValue(TGAP_GEN_DISC_SCAN_INT, DEFAULT_SCAN_INT);
        GAP_SetParamValue(TGAP_GEN_DISC_SCAN_WIND, DEFAULT_SCAN_WIND);
        GAP_SetParamValue(TGAP_LIM_DISC_SCAN_INT, DEFAULT_SCAN_INT);
        GAP_SetParamValue(TGAP_LIM_DISC_SCAN_WIND, DEFAULT_SCAN_WIND);
        GAP_SetParamValue(TGAP_CONN_EST_SCAN_INT, DEFAULT_SCAN_INT);
        GAP_SetParamValue(TGAP_CONN_EST_SCAN_WIND, DEFAULT_SCAN_WIND);
    
        /* Disable filtering the duplicate advertisement. By default it will be enabled.
        By disabling there will be event for every (repeated) advertisement packet. */
        GAP_SetParamValue(TGAP_FILTER_ADV_REPORTS, FALSE);
        
        /* Below other configurations as in original multirole project. */
        
    }
    4. Starting scanning is same with the buttons.
    5. Once the device is found we are filtering it as per the Bosch Service ID 0xFDE8
        // A discovered device report
        case GAP_DEVICE_INFO_EVENT:
        {
          if(ENABLE_UNLIMITED_SCAN_RES == TRUE)
          {
            multi_role_addDeviceInfo(pEvent->deviceInfo.addr,
                                            pEvent->deviceInfo.addrType);
          }
          
         if(0xFDE8 service present in our advertisement)
         {
            print the device info
         }
        }
    Observations
    1. Same behavior observed as informed in the previous posts.
    2. Even though there is only one device (M2),  M1  didn't find it when it is coming in the range.
    3. After the reset of M1, it found M2  which is in range.
    We have not experimented with scan window or interval.
    We need your support and inputs. Please let us know if you have any questions.
    Thanks
    Niranjan
  • Hi Niranjan,

    Thank you for the additional information. This is very helpful! Is the advertising device also a CC2640R2? Are you observing this behavior on custom boards or on the LAUNCHXL-CC2640R2 evaluation boards? I have a couple of tests/suggestions I would like you to run that may help us get closer to a resolution.

    1. Can you try increasing the scan window and scan interval? To do this, simply update DEFAULT_SCAN_INT and TGAP_CONN_SCAN_WIND to a larger value. Ideally, these constants should be set higher than the advertising interval. So if the advertising interval is 10ms, then the scan interval/window should be atleast 10ms. I would recommend setting it to twice the advertising interval (if advertising interval is 10ms, then set scan interval/window to 20ms) and verifying if you are able to scan the advertisements now.

    2. Can you enable the RF Debug Output to see what is happening on the advertiser side and the scanner side? The process to do this is detailed in the Debugging RF Output section of the debugging guide. After enabling the RF Debug Output, the LEDs on the launchpad will light up whenever the is RF activity. Can you try enabling this on the advertising device  and on the scanning device in order to verify if the devices have RF activity when the scanner is not finding the advertiser?

    3. Are you using multi_role for both M1 and M2? Are you using a LAUNCHXL-CC2640R2 for M1 and for M2?

    4. Does the issue still occur if you turn the advertiser off and on when it is in range?

    5. Can you try doing several small scan sessions instead of infinite scanning to see if the issue still manifests?

    Best Regards,

    Jan

  • Hi Jan,

    Thank for the suggestion.

    1. You have mentioned DEFAULT_SCAN_INT and TGAP_CONN_SCAN_WIND should be set to higher than the advertising interval. And you recommend twice the advertising interval. But I am wondering, in base example multi_role  advertising interval is set to 100ms and scan interval/wind set to 50ms. Why?

    We have tested by updating the scan interval/wind. We see the same issue exist. !! Please see the tabulated observations for details.

    2. As the issue is easily reproducible in the LAUNCHXL, with previously given parameter, could you please verify it from your side? With our project timeline and work pressure I would request your help here.

    3. Yes we are using multirole on both M1 and M2. We are using our custom hardware, But we have also observed  issue with LAUNCHXL.

    4. Normally observed when moving out and in, at the border range. But when it stops finding this device, even though if we put our M2 next it, it will not find, until the cancel discovery and restart the discovery on M1 side.

    5. We have tested with having the both continuous and 5second duration with restarting the scan. See below observation.

    *In the below observation please note on the terminology I have changed here for the ease of explanation.

    Boards : Custom boards (CoMo) CC2640R2

    Project or Software flashed: multi_role

     

    Let say we have devices Multi1 and Multi2 are scanners. And P1 is advertiser with100ms interval. (All are of same type of devices (CC2640R2))

     Scan for the P1 with below configurations. Multi1 and Multi2 are side by side, P1 moving around.

     

    Multi1

    Multi2

    Scan duration

    5Seconds

    // Scan parameters

    #define DEFAULT_SCAN_DURATION 5000

    Continuous

    // Scan parameters

    #define DEFAULT_SCAN_DURATION 0

     

    Starting the scan again, once the Discovery is done

    // End of discovery report

    case GAP_DEVICE_DISCOVERY_EVENT:

    {

     if(pEvent->gap.hdr.status == SUCCESS)

     {

      scanningStarted = FALSE;

     

      mr_doScan(0);

     }

    }

    Continuous scan won't hit discovery done
    as scanning is not stopped

    Scan params

    Set 1 -> WIND and INT are set to 80 * 0.65 = 52.0ms 

    Set 2 -> WIND and INT are set to 160 *0.65  = 104.0ms

    Set 3 -> WIND and INT are set to 320 *0.65  = 208.0ms

    Doing the Passive scan

    Set 1 -> WIND and INT are set to 80 * 0.65 = 52.0ms 

    Set 2 ->WIND and INT are set to 160 *0.65  = 104.0ms

    Set 3 -> WIND and INT are set to 320 *0.65  = 208.0ms

    Doing the Passive scan

    Number of 0XFDE8

    Devices

    1

    1

    Duplicate advertise filtering

    duplication filter disabled -> Should get event for all advertise packet

    GAP_SetParamValue(TGAP_FILTER_ADV_REPORTS, FALSE);

    duplication filter disabled -> Should get event for all advertise packet

    GAP_SetParamValue(TGAP_FILTER_ADV_REPORTS, FALSE);

    Packet sniffing

     

    (Both terminals are parallel and side by side )

    1. Observed missing of advertisement packets from P1 

    Even though captured in Multi2.

    2. It will not stuck like Multi2

     

    All packets are captured P1

    -Stopped finding device with multiple time device  P1 goes out and in.

      

    Please let us know if you need more information. I hope you will find the issue and solution quickly.

    Thanks

    Niranjan.

  • Hi Niranja,

    I made the changes you provided in your previous message but I was still able to see a specific advertiser if it went out of range and back in range. Across multiple tests, I was able to see the advertiser when it came into range and see it again if it left the range and came back in. Could you provide your multi_role.c file in order to ensure we have the same code? I will try to reproduce the behavior with your multi_role.c file.

    However, if I am understanding the test results correctly, then it seems that you were able to scan P1 reliably by repeatedly stopping and starting scanning. Is this correct? If so, then I would suggest using that approach until we can figure out exactly what is causing the strange continuous scanning behavior. Is that possible in your use case?

    Best Regards,

    Jan

  • Hello Jan,

    8611.multi_role_Scanner.c
    I have attached the multi role source code with the changes. Please do have a look.

    Regarding your suggestion, we would prefer not using the method of stopping and starting the scan process since, as mentioned, we are observing advertisement packet losses which may lead to other issues. Hence a solution would be much appreciated, instead.

    Thanks,

    Niranjan.

  • Hi Niranjan,

    Thank you so much for providing the code. It was extremely helpful in doing some further debugging. I had issues reproducing the behavior by taking the advertising device out of and into range of the scanner, but I believe I found an alternative way to reproduce the behavior. I took two LAUNCHXL-CC2640R2, programmed one with your multirole project, and another with a modified multirole (using your UUID). I found that if I followed the following steps I was able to reproduce a behavior similar to what you described.

    1. Press and hold reset on the scanner LP

    2. Press and hold reset on the LP

    3. Release reset button on the scanner LP (wait a second for scanning to start)

    4. Release reset button on advertiser LP

    If I followed the above steps, then I would not be able to see the advertiser even if it was in range. Can you verify if following the above steps leads to the behavior you observed? If so, then I may have found a solution. 

    Can you try setting DEFAULT_SCAN_WIND and DEFAULT_SCAN_INT to 320 (double what the default advertising interval is) and setting ENABLE_UNLIMITED_SCAN_RES to TRUE? By making these changes and commenting out some of the ENABLE_UNLIMITED_SCAN_RES application code I was able to see the advertisements at all times (even after performing the steps shown above). These are the c files I used for the scanning multi_role project and the advertising multi_role project. Can you try copy pasting the code into your projects and verifying if the behavior is eliminated?

    multi_role_advertising.c

    multi_role_scanning.c

    Best Regards,

    Jan

  • Hi Jan,

    We could able to reproduce the issue with above steps. Where Scan wind and interval is 80 (50ms). Also reproducible with 320(200ms). You can check our observation table previously posted.

    You mentioned about the ENABLE_UNLIMITED_SCAN_RES. Can you provide information in detail?

    1. What is GAPROLE_MAX_SCAN_RES ?

    2. Is it a scan response or scan reports?

    3. In the GAP_DeviceInit this value has been used. How exactly this is used in stack?

    4. Let say if we set number of scan responses/reports set to '0' what will happen? And what will happen if we set to another value? 

    5.  Is there any specific memory reserved based on the number of scan responses value? If so what will be reserved in case of value being '0' (zero)?

    6. What is the memory consumed by each scan report? Is it static or dynamic? 

     

    Also can you please provide the solution you have found?

    Thanks. 

    Niranjan

  • Hi Niranjan,

    I am glad to see the procedure works for reproducing the issue! Can you verify if the modification I mentioned with regards to enabling unlimited scan eliminate the missed devices behavior? These changes are present in the multi_role_scanning.c file I attached in my previous message. If you are using launchpads, then you should be able to take two multi_role projects, place the multi_role_advertising.c code in one and the multi_role_scanning.c code in the other. With these modified projects, you should be able to flash them to LaunchPads and test.

    The Unlimited Scan section of the User's Guide provides a lot of information with regards to how Unlimited Scanning works. Here are my answers to your questions:

    1. What is GAPROLE_MAX_SCAN_RES ?

    The GAPROLE_MAX_SCAN_RES  is the maximum number of scan reports to store from GAPCentralRole_StartDiscovery.

    2. Is it a scan response or scan reports?

    The MAX_SCAN_RES define controls the max number of scan reports.

    3. In the GAP_DeviceInit this value has been used. How exactly this is used in stack?

    In the GAP_DeviceInit function, the maxScanRespones is used to configure the maximum number of scan responses the device can receive in discovery. The API documentation linked in this message provides more information into how this  parameter impacts the stack.

    4. Let say if we set number of scan responses/reports set to '0' what will happen? And what will happen if we set to another value? 

    As detailed in the GAP_DeviceInit function documentation, If maxScanResponses is set to 0, then 

    • there will be no limitation of scan responses to receive.
    • payload duplicate filter will not be applied regardless of TGAP_FILTER_ADV_REPORTS although filter by address can still be applied depending on TGAP_FILTER_ADV_REPORTS.
    • the numDevs parameter coming with GAP_DEVICE_DISCOVERY_EVENT will be 0 regardless of how many devices have been actually discovered.
    5.  Is there any specific memory reserved based on the number of scan responses value? If so what will be reserved in case of value being '0' (zero)?

    If maxScanResponses is set to 0, then there will be no limitation on how many scan responses can be received set by the stack.

    6. What is the memory consumed by each scan report? Is it static or dynamic? 

    The memory that each scan report uses depends on the data contained within each scan report. I would recommend referencing the gapDeviceInfoEvent_t Struct Reference in the API documentation.

    The solution I found is contained in the multi_role_scanning.c file. Take your scanning multirole project and replace the multi_role.c code with the code contained in that file. The links for the files are shown below:

    multi_role_advertising.c

    multi_role_scanning.c

    Best Regards,

    Jan