Hi,
My project consists of 2 devices, both using the nrf52840 on sdk 17.1. One I will call the hub, the other the sensor. The hub serves as the central in a connection with the sensor, and the hub can simultaneously act as a peripheral in a connection to an iOS app. The hub can receive an OTA update from the iOS app. However, depending on if the hub established its connection with the sensor, or its connection with the phone first, the DFU can fail to initiate.
If the hub first connects to the sensor (with the hub acting as central), and then connects to the phone (with the hub as peripheral) the DFU process works just fine.
If the hub first connects to the phone, then to the sensor, then the DFU will fail to start. When it fails it is because the hub doesn't respond to an indication from the phone on the DFU service. From the phone, I see
Message: peripheral .writeValue (0x02084466753835353330, for: 8EC90003-F315-4F60-9FB8-838830DAEA50, type: .withResponse)
and then exactly 30s later, the phone disconnects, meaning the connection was terminated because the hub didn't respond to the write with response.
On the hub in this case, I see the following:
<debug> ble_scan: Filter set on address 0x <debug> ble_scan: 70 15 91 8B 73 E7 |p...s. <debug> ble_scan: Scanning <debug> nrf_ble_gq: Adding item to the request queue <debug> nrf_ble_gq: Purging request queue with id: 1 <debug> nrf_ble_gq: GATTS Notification or Indication <debug> nrf_ble_gq: SD GATT procedure (5) succeeded on connection handle: 3. <debug> nrf_ble_gq: Processing the request queue... <debug> nrf_ble_gq: Processing the request queue... <debug> nrf_ble_gq: Processing the request queue... PERIPHERAL: Disconnected, handle 3, reason 0x13.
In this case (failure) the line "Purging request queue with id: 1" refers to the sensors disconnecting themselves which is a process I trigger. So purging their request queues makes sense (connection handle 1 since the sensor connected after the phone).
Is there some strange interplay of the peripheral and central modules with the DFU service that makes connection handle matter? Does the hub's connection with the phone need to be the last in some internal array due to some flawed logic somewhere? I am at a bit of a loss for where to even start investigating so any guidance would be appreciated. Unfortunately I can't really work around this issue because as the hub/sensor network expands I won't be able to control what order everything connects in