I'm developing a device that uses an nRF52832 as a central device to connect to up to 4 other peripherals to send coordinated commands. The device must wake up, establish connections route commands and then disconnect and wait for input to do it all over again. I started with the central multi-link example and have been growing it to fit my needs. I've decided to develop in Zephyr rather than NCS to try and take advantage of the portability and the Bluetooth stack is a Nordic contribution to the Zephyr system.
I can find my devices and connect to them. I have it able to maintain multiple connections, but I have an issue with disconnecting and reconnecting. Upon connecting in the device found callback I use bt_conn_le_create(). Upon a disconnect I call bt_conn_unref(). But after the first connection to a device if I try to reconnect, bt_conn_le_create() fails with the message "Found valid connection in disconnected state" and code -22. At that point I am never able to reestablish a connection until I power cycle the device. I have logging to see that it goes through the correct code to unref it on disconnect. I have implemented a way that upon failure to reconnect I can search for the connection and try to unref it again every time it fails. After several iterations it will unref and successfully remake the connection to the device. It can happen in 1 minutes, or take 3 or 4 minutes of cycling through the process of trying to make a new connection, failing, canning bt_conn_unref() and then trying again.
I was surprised that it worked at all, but I cannot reconcile why it takes time to release the connection after calling that function many times. I do need better performance by disconnecting immediately. What can I do to fix this?
I am still a little confused with how to determine what version of Zephyr I am on. I think it's 2.something but I cannot figure out how to query that. I know west is v0.14.0 and I've been using SDK v0.15.2. How to get the zephyr version number from my installation?