BLE Device disconnection when calling via Handsfree profile on iOS with reason 722

We develop our own BLE device and connect to iPhone. We discover an issue that it will disconnect after 2~3 minutes when making calls via Handsfree profile. (ex: Using car audio system, infotainment HUD or so). Please refer to the raw log below.

Does anyone know what status 722 stands for?
How do we resolve this?
Thanks.

Code Block
default 2021-02-09 17:04:57.813774 +0800 bluetoothd Server.LE.Connection LE ConnManager disconnection complete reason 722 address=<private> localRole=Master
default 2021-02-09 17:04:57.816296 +0800 bluetoothd Stack.GATT _GATT_LE_DisconnectedCB on handle 0x000000014C804720 with reason STATUS 722
default 2021-02-09 17:04:57.816977 +0800 bluetoothd Server.LE Device "E2278A91-B7B6-2122-696C-BE887487C8D7" set last connected time to 1612890297
default 2021-02-09 17:04:57.820707 +0800 bluetoothd Stack.CL Removing peer ID 0 for handle 0x000000014C804720
default 2021-02-09 17:04:57.820869 +0800 bluetoothd Stack.HCI Releasing LE connection 0x0041
default 2021-02-09 17:04:57.822551 +0800 bluetoothd Server.LE.Connection Device "E2278A91-B7B6-2122-696C-BE887487C8D7" does not require low latency
default 2021-02-09 17:04:57.822580 +0800 bluetoothd Server.LE.Connection Found link-ready device calling disconnection notification
default 2021-02-09 17:04:57.822582 +0800 bluetoothd Server.LE.Connection Disconnected from device "E2278A91-B7B6-2122-696C-BE887487C8D7" successfully (locally-initiated)
default 2021-02-09 17:04:57.822585 +0800 bluetoothd Server.LE.Connection linkReady:1 disconnectDevice:0 localRole:0 reason:722 result:0
default 2021-02-09 17:04:57.824928 +0800 bluetoothd Server.LE.Security Removing temporary security keys for device <private>



Replies

722 means the disconnection was locally-initiated (it also says so on the line just above).
"locally" in this context means iPhone side.

It could be caused by many things, from the iPhone not liking something the device is doing and terminating the connection, to something in your app which is closing the connection, perhaps a code path that is doing so, or perhaps you are somehow releasing or overwriting your CBManager or CBPeripheral objects by mistake.

The causes are many, but hard to make a guess from a log snippet here.
Hi Gualtier,

Thanks for your reply.
After further inspect, we summarize logs from logarchive file.


Here is the predicate we use to filter logs
Code Block
--predicate '(subsystem == "com.apple.bluetooth") AND (category IN { "Stack.ATT", "Server.Audio", "Server.Handsfree", "Server.GATT", "Server.LE", "Server.LE.Connection", "Stack.HCI" })'

Our app reads values from our BLE beacon device every 60 seconds in the background once connected.
As you can see, at 2021-02-09 17:04:23.995037
Code Block
bluetoothd: [com.apple.bluetooth:Server.GATT] Reading value for characteristic value handle 0x001b, char handle 0x001a on device "<private>"

The read command never got responded until 2021-02-09 17:04:53.971431
Code Block
bluetoothd: [com.apple.bluetooth:Stack.ATT] Timeout waiting for ATT response, forcing a disconnect. (status=65535)

After that, a sequence of disconnecting logs popped out as we post previously.
Other read value logs would be almost immediately followed by statedump logs
We suspect this is the root cause of disconnection but we still need more hints to solve this.

It only happens along with active HFP.
Other than that our beacon is able to maintain stable connection with iPhone until battery dies out.

Any advice would be appreciated :)