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.

LP-CC2652RB: Start Commissioning Request gets stuck in endless loop

Part Number: LP-CC2652RB

Hello. I have removed the UI and UART components of a sample app in order to reduce consumption and achieve uC sleep. In doing so, all the commissioning functionality is removed and am unable to trigger pairing by pressing the side buttons. To overcome this, i have implemented a commissioning routine as a button callback as follows:

static uint16_t bdbCommissioningModes =
BDB_COMMISSIONING_MODE_NWK_STEERING | BDB_COMMISSIONING_MODE_FINDING_BINDING;

static void commissioningBtnCallback(Button_Handle _buttonHandle,
                                     Button_EventMask _buttonEvents)
{

    if ((_buttonEvents & Button_EV_CLICKED) && (_buttonHandle == gLeftButtonHandle))
    {
        zstack_bdbStartCommissioningReq_t zstack_bdbStartCommissioningReq;
        zstack_bdbStartCommissioningReq.commissioning_mode =
                bdbCommissioningModes;
        Zstackapi_bdbStartCommissioningReq(appServiceTaskId,
                                           &zstack_bdbStartCommissioningReq);
    }
}

void configureCommissioningCb()
{
    Button_Params bparams;
    Button_Params_init(&bparams);
    gLeftButtonHandle = Button_open(CONFIG_BTN_LEFT, &bparams);

    Button_setCallback(gLeftButtonHandle, commissioningBtnCallback);
}

The button callback works and is triggered correctly, however i end up stuck in a loop inside sendReqDefaultRsp, namely at:

            while(!gotRsp)
            {
                // Wait for the response message
                OsalPort_blockOnEvent(Task_self());

                pCmdStatus = (zstackmsg_genericReq_t*)OsalPort_msgFindDequeue(appServiceTaskId, pMsg->hdr.event);

                if(pCmdStatus)
                {
                  gotRsp = true;
                }
            }

It seems that the app waits for a response that never arrives. Is there something missing from my configuration of commissioning requests?

  • Hi A V,

    Zstackapi_bdbStartCommissioningReq appears to be fine.  I recommend that you make sure the commissioningBtnCallback is not called until after sampleApp_Init is called and processes the first commissioning mode.  You can also try testing a timer callback which automatically sets the commissioning mode some time (like a second) after device initialization. What are the contents of commissioningBtnCallback and have you made any other changes other than removing the UI?  What is the API which calls sendReqDefaultRsp?  Please show the CCS debug call stack if possible.

    Regards,
    Ryan

  • Hello, Ryan

    The problem was caused by me calling the commissioning from an ISR context. I assume that either the Zstack thread was sleeping or the routine took too long. Setting a flag during the ISR and evaluating it in the main zstack loop solved the issue and functionality is normal now.