This discussion has been locked.
You can no longer post new replies to this discussion. If you have a question you can start a new discussion

nRF52840 random disconnection

Good morning,

We have a new equipment based on the nRF52840 and s140.

                Just now, a new problem has appeared and it is very strange, as it seems to be a ‘random’ error:

 

                We have already assembled tens of equipment, and most of them are perfectly working with any smartphone (using both your ‘nRF Connect’ application or our own application).

                But, we have a few smartphones that show a strange behavior: they are able to perfectly connect to some of our nRF52840-based equipment, and in a few ones, they are able to connect but they get disconnected after a few seconds. Same equipment is connecting to other smartphones without problems (without disconnecting).

                This is (step by step) what it is happening a few times:

  • Equipment (nRF52840) is advertising.
  • Smartphone stablish connection with equipment using pin number
  • First time, the connection is perfectly working.
  • If smartphone is disconnected and connected back again with same equipment (Already bonded), then connection is stablished but smartphone disconnects after 30”, approximately. Same behavior is happening with both nRF connect application and our own application. Looking at log in nRF application we see: ‘Connection terminated by peer (status 19)’or ‘GATT_CONN_TIMEOUT’

 

Why is it happening?

Which is the reason?

How can we solve this?

 

 Could you help us? (For your information, we have set MIN_CONN_INTERVAL to 7.5m and MAX_CONN_INTERVAL to 100ms)

Thank you

  • Hi Hung,

    I've tried many times, and no good results.

    Look at the attached screenshot: it shows debug values (LTK is seen) and Wireshark tool (LTK is introduced).

    I have proceeded in the way you have told me:

    - Device already bonded to my smartphone

    - I disconnect device from smartphone

    - I set Wireshark to save trace, introduce LTK and push the right arrow

    - I connect device to smartphone

    But not expected results are seen: "bad MIC" is also shown. I have also tried with LTK upside down, but same result...

    Maybe we can talk and meet using remote connection with my computer? Any other idea?

    Dani

  • Hi Daniel, 

    I tested again here and facing the same problem as you. I couldn't decrypt the connection even with the LTK. It's really strange that just a few days ago it worked for me. 

    I'm checking with the team if I'm missing something. 
    In the mean time I would suggest to try testing with the nRF Connect app on the phone, make sure it's only re-bonding happens and no other activity just to check if the disconnection still happen. 

    Also please try to print out in the log any BLE event when you connect.

    Do you store any information in flash ? If you do I would suggest to skip them, just in case they cause issue with the bond information. 

    One approach to debug is to step by step removing the functionalities of the application. Until it's get very similar to one of our example in the SDK.  I assume that when you test with the example in the SDK with LESC you didn't have the issue ? Have you tried with the ble_app_gls example ? 

  • Hi Hung,

    I have already checked with nRF Connect: as I told you at the beginning, the same is happening --> I get '‘Connection terminated by peer (status 19)’' after about 30". I have proceed as follows: having the device bonded, I go to bonded tab, and I select my device to connect again. I have even tried to reset the device, but once bonded, it is always happening same situation when reconnecting (only the first time -when introducing pin number- the device remains connected). Please, look at attached screenshot.

    I store application information in flash (many time ago I managed it with your support in order to be sure it was correctly set: https://devzone.nordicsemi.com/f/nordic-q-a/56766/buttonless-dfu-with-bonding).

    I have following setup:

    - FDS_VIRTUAL_PAGES 6 (For bondings & garbage)

    #define FLASH_ADR_FINAL_FLASH (u32) 0x000f2000 //Bootloader initial adress
    #define FLASH_ADR_INI_PAGE_1 (u32)(FLASH_ADR_FINAL_FLASH-0x1000) //Page1(app)
    #define FLASH_ADR_INI_PAGE_2 (u32)(FLASH_ADR_INI_PAGE_1-0x1000) //Page2(app)
    #define FLASH_ADR_INI_PAGE_3 (u32)(FLASH_ADR_INI_PAGE_2-0x1000) //Page3(app)
    #define FLASH_ADR_INI_PAGE_4 (u32)(FLASH_ADR_INI_PAGE_3-0x1000) //Page4(app=
    #define FLASH_ADR_INICI_FLASH FLASH_ADR_INI_PAGE_4 //To use for NRF_FSTORAGE_DEF

    NRF_FSTORAGE_DEF(nrf_fstorage_t fstorage) =
    {
        /* Set a handler for fstorage events. */
        .evt_handler = fstorage_evt_handler,
    
        /* These below are the boundaries of the flash space assigned to this instance of fstorage.
         * You must set these manually, even at runtime, before nrf_fstorage_init() is called.
         * The function nrf5_flash_end_addr_get() can be used to retrieve the last address on the
         * last page of flash available to write data. */
        .start_addr = FLASH_ADR_INICI_FLASH,
        .end_addr   = FLASH_ADR_FINAL_FLASH,
    };

    Also note than in Bootloader I set :

    NRF_DFU_APP_DATA_AREA_SIZE   40960 (10 pages: 6 VIRTUAL + 4 data)

    I will try with other applications: But as I said, it is very strange, as with the same smartphone, some of my devices are correctly working. Some other, as described here, disconnect after 30".

    Thank you again for your efficient and fast support: it is very important for us. But, do you think we could get with the solution soon? This equipment is in production, and similar problem is appearing in some customers!!

    Dani.

  • Hi Dani, 

    It's hard to say how long it would take to get a solution. I think it's the best if we can narrow down the issue. 


    You mentioned earlier that if you comment out the sd_ble_gap_disconnect() inside BLE_GATTC_EVT_TIMEOUT and BLE_GATTS_EVT_TIMEOUT you don't experience the disconnection. 


    Please try to narrow down if it's BLE_GATTS_EVT_TIMEOUT  or BLE_GATTC_EVT_TIMEOUT event causing the issue ? The GATT timeout happens when a write/read request or indication doesn't get a reply form the peer. 

    I think the approach to debug this is : 

    - Make sure you can print out log from the nRF52 either by UART or by RTT 

    - Try to strip down the functionality of the application until you don't see the error 

    - If you test with legacy pairing just work the issue never happen ? It's pretty strange that the bonding process would be related to the GATT timeout.

    - How many phones have you experienced the issue ?  Could you give the model number of the phones ? 

  • Hi Hung,

    It's always BLE_GATTS_EVT_TIMEOUT the event that causes the issue --> In my application, we send a notification (we never send indication) once every 62.5ms. Which reply must it receive from the peer when sending notifications?? Which can be the reason to not receive that reply?

    Furthermore, does it has sens to implement a counter in this event, and just disconnect when it is received a few times? In this case, which will be the most suitable event to implement the reset of this counter?

    To print out log by RTT (I guess this is info to be observed using nRFConnect), I guess I should use NRF_LOG_DEBUG calls, right?

    And yes, without bonding, the problem does not appear.

    I'm working on it, trying to find out the solution. We will also test example applications.

    In what regards phones experiencing this issue:

    - Xiaomi Mi8

    - Huawei 20 Pro

    - Oppo A74

    - Tablet Galaxy Tab A SM-T580

    Dani

    PD: The problem with the BLE_GATTS_EVT_TIMEOUT event seems to be related to anything set to the limit. Now, I'm debugging my application (Without having modified nothing) being connected to a Xiaomi Mi8, and now is working fine most of the times (no disconnections): still disconnects some of them. 

Related