BLE Connection Issues with nRF52832 Multi-Device Setup

We are currently developing a project using the nRF52832 as the microcontroller, Segger Embedded Studio version 5.42a as the IDE, and the nRF5 SDK 17.0.2. We began by creating a concurrent central and peripheral switching example project. Subsequently, we integrated the NUS (Nordic UART Service) client and peripheral functionalities into the nRF Relay example project.

Our setup involves three device types:

  1. Response Device: This device operates as both a central and a peripheral. In its central role, it scans for advertising packets from BLE beacon sensors. In its peripheral role, it awaits BLE connections from a central device. We have four response devices.
  2. Submaster Gateway Device: This device facilitates data transfer between the connected response devices and the supermaster device. It acts as both a central and a peripheral. In its central role, it establishes connections with the peripheral role of the response devices. In its peripheral role, it waits for connections from the supermaster gateway.
  3. Supermaster Gateway Device: This device is the final destination for data relayed through the submaster gateway. We have one supermaster device.

The code for these three devices is based on the nus_c and nus integrated nrf_relay example project

Initially, when we power on the four response devices, followed by the submaster device, all four response devices successfully connect to the submaster device. Then, when we power on the three additional response devices and the supermaster device, these three response devices and the submaster device successfully connect to the supermaster device. Data transmission and reception between any of the response devices and the supermaster device function correctly in this scenario.

However, if we power on the devices in a random order, connection issues arise. Devices frequently connect and then disconnect, exhibiting unstable behavior. This leads us to suspect potential timeout issues.

The following BLE macro definitions are used across all devices (response, submaster, and supermaster):

Does having the same advertising and connection parameter delays on all three devices affect the issue? Or, is it possible that a connection problem occurs when one device tries to connect via BLE but another device is not ready?

Parents
  • Hi, 
    I would suggest to use a sniffer to try debugging. You can find why the connection is terminated. 


    You can also find the termination reason on the device when it's disconnected. 

    Please focus on this: 
    <error> nrf_ble_gatt: sd_ble_gatts_exchange_mtu_reply() returned NRF_ERROR_INVALID_STATE.


    Where do you call sd_ble_gatts_exchange_mtu_reply() ? 

    Was the log from the Super master or the Sub master ?

  • The given log is from the super master, and I could not find sd_ble_gatts_exchange_mtu_reply() within my super master code.

  • Hi, 
    If you want such feature, you would need to implement that. The submaster gateway shouldn't connect to the supermaster gateway as the central. This mean when the submaster scan for advertising packet, it would need a way to detect that it only connect to response node, not the supermaster. I think it's quite straight forward to do so. Just need to scan for either address, or the advertising name/data. 

  •  Okay, I will proceed as you suggested. I also have a question: are there any issues with scanning for or connecting to a central device while maintaining a peripheral connection? Additionally, what are the standard minimum delays required for a response device, sub-gateway, or super-master gateway to perform scanning and connection?

  • Hi, 
    I don't see a problem having a connection and then scan and establish another connection. It's our fundamental operation for multilink application. So, shouldn't be a problem. 
    There is no requirement on the timing. Of course two connection can't be established at the same time (like exactly the same time) they should be established based on when the scanner catch the advertising packet and send the connect request. 

  • When the submaster gateway initially starts advertising, and when Iam initiates a connection from the APK, it sometimes disconnects and shows:

    Peripheral disconnected. conn_handle: 0x5, reason: 0x28

    The APK then shows: Connection failed: write descriptor failed.

    One more thing: I am not using any kind of bonding here. So, what are the possible causes of this issue?

    This issue happens only sometimes  .

  • Hi Siltvm, 

    Error 0x28 is a bit strange because it's indicate an issue in the BLE stack timing ( BT_HCI_ERR_INSTANT_PASSED) either on the nRF52 or on the phone. Which phone did you use ? 

    I would need to see your sniffer trace to be to check what happens there. 
    You can find the guide on how to use the sniffer here: https://academy.nordicsemi.com/courses/bluetooth-low-energy-fundamentals/lessons/lesson-6-bluetooth-le-sniffer/

Reply Children
No Data