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.

CCS/SIMPLELINK-CC2640R2-SDK: Code Composer Studio™ forum

Part Number: SIMPLELINK-CC2640R2-SDK


Tool/software: Code Composer Studio

This question is with regard to the CC2640R2 Scanning and Advertising Tutorial, which worked perfectly upto Scanning Task 2 - Printing scanning results. Below is the output after implementing solutions for Scanning Task 2. 

But after implementing Scanning Task 3 - Scan Indefinitely 

    // === SOLUTION [Scan Indefinitely]===  (Scanning Task 3)
     #define DEFAULT_SCAN_DURATION                   0
    // === END SOLUTION [Scan Indefinitely]===  (Scanning Task 3)

the following error was observed.

The respective code 

    case GAP_DEVICE_DISCOVERY_EVENT:
      {
        if(pEvent->gap.hdr.status == SUCCESS)
        {
            // discovery complete
            scanningStarted = FALSE;

            // if not filtering device discovery results based on service UUID
            if ((DEFAULT_DEV_DISC_BY_SVC_UUID == FALSE) && (ENABLE_UNLIMITED_SCAN_RES == FALSE))
            {
              // Copy results
              scanRes = pEvent->discCmpl.numDevs;
              memcpy(devList, pEvent->discCmpl.pDevList,
                     (sizeof(gapDevRec_t) * scanRes));
            }

            Display_print1(dispHandle, 2, 0, "Devices Found %d", scanRes);

            if (scanRes > 0)
            {
#ifndef FPGA_AUTO_CONNECT
              Display_print0(dispHandle, 3, 0, "<- To Select");
            }

            // Initialize scan index.
            scanIdx = -1;

            // Prompt user that re-performing scanning at this state is possible.
            Display_print0(dispHandle, 5, 0, "Discover ->");

#else // FPGA_AUTO_CONNECT
              SimpleCentral_connectToFirstDevice();
            }
#endif // FPGA_AUTO_CONNECT
          }
        else
        {
            if(pEvent->gap.hdr.status == GAP_LLERROR_INVALID_PARAMETERS)
            {
                Display_print0(dispHandle, 3, 0, "INVALID PARAMETERS");
            }
            else if(pEvent->gap.hdr.status == GAP_LLERROR_COMMAND_DISALLOWED)
            {
                Display_print0(dispHandle, 3, 0, "COMMAND DISALLOWED");
            }
            // === SOLUTION [Add case for canceling operation] === (Scanning Task 1)
            else if (pEvent->gap.hdr.status == bleGAPUserCanceled){
                Display_print0(dispHandle, 3,0, "USER CANCELLED OPERATION");
                scanningStarted = 0;
            }
            // === END SOLUTION === (Scanning Task 1)
            else
            {
                Display_print0(dispHandle, 3, 0, "ERROR");
            }
        }
      }
      break;

Two CC2640R2 Launchpads are use with Simplelink_CC2640r2_sdk_4_10_01_02

References

.

  • Hello Mahendra,

    What specific error/behavior are you referring to? 

  • The Error is "Invalid Parameter" shown by the following.

    Per the code this error occur due to failure the following statement

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

    and due to the validity of 

    if(pEvent->gap.hdr.status == GAP_LLERROR_INVALID_PARAMETERS)
                {
                    Display_print0(dispHandle, 3, 0, "INVALID PARAMETERS");
                }

    This occurs when DEFAULT_SCAN_DURATION is set to 0

    // === SOLUTION [Scan Indefinitely]===  (Scanning Task 3)
     #define DEFAULT_SCAN_DURATION                   0
    // === END SOLUTION [Scan Indefinitely]===  (Scanning Task 3)

    When DEFAULT_SCAN_DURATION is set to 4000, I don't see any error. I am unable to figure out the relation. Any help the point out the relationship is appreciated. 

  • Mahendra,

    I myself followed all the steps on the Scanning and Advertising Lab from the Bluetooth 4.2 SimpleLink Academy, and found no issues.

    Can you please review all your code changes from the advertising section tasks, and then from the scanning section tasks?

    I would recommend starting "fresh" with a new workspace. Re-import the examples using the Resource Explorer (from the View menu).

    A couple of things I noticed: 

    - You referred to SDK 4.10.01.02, but the latest published is 4.10.00.10

    - Be careful of not re-defining DEFAULT_DISCOVERY_ACTIVE_SCAN. In Scanning Task 1 you're instructed to set it to false, but there may be a later re-definition to true. Just make sure only one #define for it.

    I tested with both DEFAULT_DISCOVERY_ACTIVE_SCAN set to TRUE and to FALSE, and the example worked fine in both cases. That is, I got:

    BLE Central
    0x546C0EA0582D
    Discovering...
    
    

    ... as a result on the terminal. I didn't get the "invalid parameters" message you got. Can you please double check your code? Notice that Scanning Task 1 has multiple code changes required.

    Thanks,

    Luis

  • Luis M

    Thank you for taking the time to develop a detail response. I will take a close look at the software.  

    I will take a closer look at DEFAULT_DISCOVERY_ACTIVE_SCAN

    Regards

    Mahendra