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/CC2642R: Automatic connection establishment

Part Number: CC2642R

Tool/software: Code Composer Studio

Hi,

Currently I am working on a cc2642 based multirole project. I want to modify the existing example multirole project in such a way that it will establish the connection automatically after device discovery in case MR_EVT_ADV_REPORT:.

So how to arrange the  GapInit_connect() function in case MR_EVT_SCAN_DISABLED:.Please give a code snippet for this.

sdk - simplelink_cc13x2_26x2_sdk_4_20_01_04

Thanks & Regards

Satyabrata Senapati

  • Hi Satyabrata Senapati,

    In your case, the easiest solution seems to call the function multi_role_doConnect() with the index of the index of the scan you want to use.

    Best regards,

  • Hi you can see the implementation.

    case MR_EVT_SCAN_DISABLED:
    {
    scanningStarted = FALSE;
    uint8_t numReport;
    uint8_t i;
    static uint8_t* pAddrs = NULL;
    uint8_t* pAddrTemp;
    //uint16_t itemsToEnable = MR_ITEM_STARTDISC | MR_ITEM_ADVERTISE | MR_ITEM_PHY;
    #if (DEFAULT_DEV_DISC_BY_SVC_UUID == TRUE)
    numReport = numScanRes;
    #else // !DEFAULT_DEV_DISC_BY_SVC_UUID
    GapScan_Evt_AdvRpt_t advRpt;

    numReport = ((GapScan_Evt_End_t*) (pMsg->pData))->numReport;
    #endif // DEFAULT_DEV_DISC_BY_SVC_UUID

    //Display_printf(dispHandle, MR_ROW_NON_CONN, 0,
    // "%d devices discovered", numReport);

    if (numReport > 0)
    {
    // Also enable "Connect to"
    // itemsToEnable |= MR_ITEM_CONNECT;
    }

    if (numConn > 0)
    {
    // Also enable "Work with"
    //itemsToEnable |= MR_ITEM_SELECTCONN;
    }

    // Enable "Discover Devices", "Set Scanning PHY", and possibly
    // "Connect to" and/or "Work with".
    // Disable "Stop Discovering".
    // tbm_setItemStatus(&mrMenuMain, itemsToEnable, MR_ITEM_STOPDISC);

    // Allocate buffer to display addresses
    pAddrs = ICall_malloc(numReport * MR_ADDR_STR_SIZE);
    if (pAddrs == NULL)
    {
    numReport = 0;
    }


    // TBM_SET_NUM_ITEM(&mrMenuConnect, numReport);

    if (pAddrs != NULL)
    {
    pAddrTemp = pAddrs;
    for (i = 0; i < numReport; i++, pAddrTemp += MR_ADDR_STR_SIZE)
    {
    #if (DEFAULT_DEV_DISC_BY_SVC_UUID == TRUE)
    // Get the address from the list, convert it to string, and
    // copy the string to the address buffer
    memcpy(pAddrTemp, Util_convertBdAddr2Str(scanList[i].addr),
    MR_ADDR_STR_SIZE);
    // GapInit_connect(scanList[i].addrType & MASK_ADDRTYPE_ID,
    // scanList[i].addr, mrInitPhy, 0);


    multi_role_doConnect(i);   //Here i have coded like this 

    #else // !DEFAULT_DEV_DISC_BY_SVC_UUID
    // Get the address from the report, convert it to string, and
    // copy the string to the address buffer
    GapScan_getAdvReport(i, &advRpt);
    memcpy(pAddrTemp, Util_convertBdAddr2Str(advRpt.addr),
    MR_ADDR_STR_SIZE);
    #endif // DEFAULT_DEV_DISC_BY_SVC_UUID

    // Assign the string to the corresponding action description of the menu
    //TBM_SET_ACTION_DESC(&mrMenuConnect, i, pAddrTemp);
    //tbm_setItemStatus(&mrMenuConnect, (1 << i) , TBM_ITEM_NONE);
    }

    // Disable any non-active scan results
    for(; i < DEFAULT_MAX_SCAN_RES; i++)
    {
    //tbm_setItemStatus(&mrMenuConnect, TBM_ITEM_NONE, (1 << i));
    }
    }


    turn_on_advt();
    break;
    }

    By implementing the code Its actually connecting.But in this case one problem is arising, that the advertising device continously blinking the advertisement as seen in the ble scanner app.

    Am I doing any mistake here ?

    Please suggest. 

  • Hi,

    Good to see it is now working.

    Regarding the advertisement while being connected, I assume this could be removed by removing the calls to turn_on_advt();

    Best regards,