How to deal with GATT TIMEOUT

I'm develping application on nrf52832 with nrf5SDK v17.0.

The connection interval is set to 12  to 16.And the conn_sup_timeout is set to 1000.

The condition happened frequently in my application that the connection is still display connected but the nus service is not avaliable.

And when I check the log in my phone,there always show gatt conn timeout or gatt conn lmp timeout etc.

I hope if the connection is still connected and gatt timeout happened, the application can try to reconnect gatt automatically.

Below is the source code.

1202蓝牙程序v0.0.6.rar

  • Hello,

    The condition happened frequently in my application that the connection is still display connected but the nus service is not avaliable.

    Can you please share some screenshots of what this looks like?

    Have you tried connecting to the device using another DK running nRF Connect for Desktop -> Bluetooth Low Energy?

    I tried to build your project, but I got these errors:

    (I also fixed a bunch of missing header files before this). 

    I could fix these errors, but I suspect that if I do, I will not be running the same application that you are. Are you able to build and run the application that you uploaded on a clean machine?

    Best regards,

    Edvin

  • Hello, 

    I'm sorry that I not save any screenshots.So I cannot provide.

    I try to send data to my board but the log is not happened just like the nus service not be connected.I add log out in nus callback function,if data send by central,the log will output some informations about it.

    I do not use the DK board,So I also not try another DK.

    About the project,first I build it for nrf52832 but I get information from screenshot that you build it in nrf52840.

    Then,these errors seem that the include paths did not work which included in my package.

    I don't know how the machine can be called a clean mechine.Can you tell me what should I do to get a clean machine to build and run my application?

  • Hello,

    By "clean machine" I meant "another machine". But you don't need another machine. Just unzip the folder that you uploaded to me in a new location, and see if you can build it from there. 

    Chaoyue Ying said:

    About the project,first I build it for nrf52832 but I get information from screenshot that you build it in nrf52840.

    Oh, sorry. My mistake. Yes. The pca10040 project builds fine. 

    So the connection that you are having issues with, is that when the nRF is the peripheral or central? (I see that it both advertises and scans). And what is it connected to? Your mobile phone? I was able to program it, and connect to it using nRF Connect for Desktop -> Bluetooth Low Energy

    And I can send data from the central to the peripheral. 

  • Hi, 你好,

    I have issues when the nRF is the peripheral.It connect with my mobile phone and check log with nRF Connect.The log as follow.
    我错了

    Sometimes,the error code is 0x22(LMP Response Timeout).

    Either 0x08 or 0x22 happened,the data will not be send to periphral until the next Connection parameters updated…… occured.(The screenshot is return to nrmal quickly).

    But I still want to repair the question automatically in peripheral when it happened.Otherwise,the data maybe losed.

    How can I change the code to arrive it?

  • Have you tried running the application on a DK yet, to see if you get the same issue?

    On your custom board, do you have an LFXTAL, or do you use the RC Oscillator?

    If you are using an XTAL, do you have the datasheet for that crystal?

    And whether you are using an XTAL or RC Oscillator, what are your LFCLK settings in sdk_config:

    NRF_SDH_CLOCK_LF_SRC
    NRF_SDH_CLOCK_LF_RC_CTIV
    NRF_SDH_CLOCK_LF_RC_TEMP_CTIV
    NRF_SDH_CLOCK_LF_ACCURACY

    And finally, can you, for debugging purposes, try to use the LF_SRC_SYNTH by setting:

    NRF_SDH_CLOCK_LF_SRC 2

    Don't use this for production, because it will significantly increase the current consumption, but it will let us know whether the clock may be the issue right now.

    Best regards,

    Edvin

Related