This post is older than 2 years and might not be relevant anymore
More Info: Consider searching for newer posts

Can't connect to nrf52840 after a few days of advertising

I have a NRF52840 device which advertises connectable every 2 seconds for unlimited time.

I'm running a custom service (based mostly on this code https://github.com/NordicPlayground/nRF5x-custom-ble-service-tutorial).

After a day or two some of the devices keep on advertising but fail to connect (previous to get into this bad state I can connect just fine). I have tried to connect using nrf connect from multiple android and ios phones, as well as the Bluetooth Low Energy app in the NRF connect desktop app .

In the BLE Test in NRF connect desktop app I get the following error when trying to connect:

Failed to get services (BLE_ERROR_INVALID_CONN_HANDLE)

Connection was lost during service discovery

Failed to call gattsExchangeMtuReply (BLE_ERROR_INVALID_CONN_HANDLE)

Failed to call gattsExchangeMtuReply

Failed to update data length (BLE_ERROR_INVALID_CONN_HANDLE)

Failed to update data length

I'm attaching a sniffer trace with the device "dd:49:a2:a8:1b:cf" and a andriod phone trying to connect to it.

3286.connectionfailed.pcapng

I'm using soft device 140 v6.0.0 and SDK 15.0.0. The device is mostly not doing anything else other than the 2second advertising.

Any ideas what might be going on?

Parents
  • Hi Rataman,

    The tutorial is pretty old. I would suggest to have a look at our ble_app_uart example as the reference code for developing custom service. 

    What I can find in the sniffer trace is that the nrf52840 device request a connection termination right after a few packets after the connection established with the code: Remote user terminated connection (0x13).

    I don't know why it did that. Could be that in your code you have a call to softdevice API to disconnect the connection. 

    Please try testing on the ble_app_uart and check if you get the same issue. 

  • I tracked this down to the following:

    I had a inactivity app_timer that started at 15 minutes when someone connected to the device. I tracked the issue to this timer triggering immediately on start (on connection) .

    I found a bunch of people with the same problem on this forum and I fixed it by having a repeated timer constantly running to work around this app_timer bug.

Reply Children
No Data
Related