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.

RTOS/CC2640R2F: Failed to call linkDB_NumActive in a custom task?

Part Number: CC2640R2F

Tool/software: TI-RTOS

Hi,

Some background first: My project is based on the official Multi_Role example. I added two custom tasks which are used for UART read and write respectively. I try to control the launchpad through UART. So if I send a "scan start" command through UART, then the added read task will receive the command and call the mr_doScan function provided in multi_role.c to start scanning.

It turns out that the command is correctly received, but the program gets stuck at linkDB_NumActive during performing mr_doScan. Does anybody have any idea about why did this happen and how can it be resolved?

I also tried to make my program send indication to a phone(connected, of cause) through UART, when I called GATT_Indication, and I succeeded. So I think maybe the reason of my problem is not about ICall configuration. Does the linkDB api need some special configuration or something? I didn't find much information about linkDB except the api documentation.

I'm using CCS 7.2, and SDK 1.40.00.45.

Any help will be appreciated. Thanks.

  • Hi,

    Are you calling the linkDB API after the GAPROLE_CONNECTED state:

    case GAPROLE_CONNECTED:
    {
    linkDBInfo_t linkInfo;
    uint8_t numActive = 0;

    numActive = linkDB_NumActive();


    Best wishes
  • Hi,

    Thanks for your reply.

    I'm sorry, but I don't know where does the GAPROLE_CONNECTED state happen. I searched the whole project, and found nothing. Anyway, linkDB_NumActive is called in mr_doScan, and mr_doScan is called in my UART read task. The following shows first several lines of mr_doScan:

    -------------------------------------------------------

    bool mr_doScan(uint8_t index)
    
    {
    
     (void) index;
    
     // If we can connect to another device
    
     if (linkDB_NumActive() < maxNumBleConns)
    
     {
    
       // If we're not already scanning
    
       if (!scanningStarted)
    
       {
    
         // Set scannin started flag
    
         scanningStarted = TRUE;
    
         // Start scanning
    
         GAPRole_StartDiscovery(DEFAULT_DISCOVERY_MODE,
    
                                DEFAULT_DISCOVERY_ACTIVE_SCAN, DEFAULT_DISCOVERY_WHITE_LIST);

    -------------------------------------------------------

    It seems that linkDB_NumActive is called to make sure we haven't reached the maximum connections before triggering the scan.

    By the way, when I tried the "scan start" test, the launchpad wasn't connected with any other device through BLE.

  • Some updates:

    I tried to directly call GAPRole APIs in my task instead of mr_doScan:

    ---------------------------------- 
       case SCAN_START:
          // Start scanning
          GAPRole_StartDiscovery(DEVDISC_MODE_ALL, FALSE, FALSE);
          break;
        case SCAN_STOP:
          // Stop scanning
          GAPRole_CancelDiscovery();
          break;
    ---------------------------------- 

    But still no luck. The program fell into a while loop in BLE stack:

    And the calling stack:

    I also tried to increase ICALL_MAX_NUM_ENTITIES, ICALL_MAX_NUM_TASKS, and OSAL_MAX_NUM_PROXY_TASKS, didn't work either.

    Just don't understand, I call GATT_Indication in my task, and it works. I call GAPRole_StartDiscovery in my task, and it refuses to work! Any ideas or possible reasons for this?

  • Fortunately, I find this thread helps. I tried like that, triggered the scan in GapRole task, and it worked.

    But I still don't understand, what is the principle behind it? Does anyone knows any information about this?