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: receiving status code 0x31 in pPkt->hdr.status

Part Number: CC2640R2F

Hi

I'm programming cc2640r2f (simplelink_cc2640r2_sdk_3_10_00_15 using ble5_project_zero_cc2640r2lp_app) .

My problem is that sometimes I get 0x31 error while GAP_LINK_ESTABLISHED_EVENT happens and it says that i have 1 device connected and it disables advertising. I know that status code 0x31 doesn't mean SUCCESS but I don't know why sometimes this errors happens. it occurs while advertising while no device going to connect. I receive "Link establish event, status 0x31. Num Conns: 1  Max Number of Connection reach: 1, Adv. will not be enable again" message in Logs . After that I must reset the launchpad hoping this time not going to get this message and error. I have to say that I get this error randomly and 10-15 % of times that I test my scenario. Status code reference is in pPkt->hdr.status  and number of active connections is linkDB_NumActive() .and I also tried to remove this  failed connection "ProjectZero_removeConn(pPkt->connectionHandle)" but it didn't work.

My questions are:

1- What does this error mean. and why happens?

2- Why this error occurs randomly. sometimes occurs sometimes not?

3- how can I remove that fake connection to continue advertising?

I will be appreciated if you can solve my problem.

Best regards,

Alireza

  • Hi Ali,

    Have you modified the code or is this out of box behaviour? How long does it take to reproduce?

  • Hi Joakim

    I've modified ble5_project_zero_cc2640r2lp_app. I've added some phases to project which are controlled by clock object to start/stop advertising on specific times. I've also added POWER_SAVING to predefined symbols. There is no certainty about when this error occurs. it occurs randomly. sometimes it doesn't occur. sometimes it occurs few seconds after resetting launchpad and sometimes occurs few minutes after resetting launchpad. I have to note that most of the times it doesn't occur. But I have to find the reason to handle this error because it disables advertising and it ruins my scenario. Is there a way to get rid of this type of fake connections. what is 0x31 error ? how can I handle connection failure scenarios? 

    Here I attach screenshot of putty :

    Regards, Alireza

  • Hi Alireza,

    This status is defined in the bcomdef.h file: 

    #define bleGAPConnNotAcceptable         0x31  //!< The connection was not accepted

    Normally, reasons for this happening can be: 

    - connection creation has been canceled.

    - directed advertising ended without a connection being formed

    - Slave received a connection request with an invalid combination of connection parameters.

    Does any of them ring a bell? If you can take a sniffer log of this happening w can try to figure out why.

    Also, you can work-around this in the application by only stopping advertising if the gap_link_established event has an error status.

  • Hi Marie,

    As you mentioned above, all those reasons shouldn't cause establishing a successful connection. The problem here is after getting this error , the number of BLE connections shouldn't increase. but it increases as you see in below picture

    linkDB_NumActive()

    The above function will return 1 after this error so

    if(linkDB_NumActive() < MAX_NUM_BLE_CONNS)
            {
                Log_info1("Continue to Advertise, %d possible connection remain", MAX_NUM_BLE_CONNS - linkDB_NumActive());
                // Start advertising since there is room for more connections
                GapAdv_enable(advHandleLegacy, GAP_ADV_ENABLE_OPTIONS_USE_MAX, 0);
            }
            else
            {
                Log_info1("Max Number of Connection reach: %d, Adv. will not be enable again", linkDB_NumActive());
            }

    above condition in GAP_LINK_ESTABLISHED_EVENT will be FALSE while we don't have a successful connection and it will disable advertising. But I think we should expect linkDB_NumActive() return 0 after canceled connection to continue advertising.

    Also the following API is not available in icall_ble_api.h

    #define linkDB_Remove(...)                       (AssertHandler(0,0))
    

    and the following function didn't help us too:

    static uint8_t ProjectZero_removeConn(uint16_t connHandle)
    

    Is there a way to remove this link from linkDB in order to have linkDB_NumActive() return 0?

    I want to continue advertising after getting bleGAPConnNotAcceptable.

    Cheers, 
    Alireza.

  • Hi Alireza,

    I see what you mean, I agree this is a bug. I have submitted a ticket.

    In the mean while, you will have to work around this on the application level, e.g. remove the linkDB_NumActive() check.

  • Hi Marie,

    Thank you.

    At the moment I restart my scenario when it happens. I hope this bug get fixed soon.

    Cheers, 
    Alireza.

  • Hi Marie,

    Today I checked new SDK's  changelog (http://software-dl.ti.com/simplelink/esd/simplelink_cc2640r2_sdk/3.20.00.21/exports/changelog.html) but I couldn't find anything about this issue. neither in fixed issues nor in known issues of ble5stack. 

    will this get fixed in next version of SDK?

    Cheers, 
    Alireza.

  • Hi Alireza,

    This bug was not fixed for the SimpleLink CC2640R2 3.20 SDK. We will try to fix it for the nest release.