Re-establish BT after Central closes connection

I have some working BT code with a GATT server, testing with LightBlue and Mac OSX Bluetooth Explorer.

Both LightBlue and Explorer can make a connection and do some GATT read/write transactions. But when either Central disconnects I am no longer able to make new connections - either with the same Central or one of the previously-unconnected Centrals.

The “bt.onconnect” close method is triggering when the Central disconnects so I know the connection is gone, and advertisements are still going out. But when I try to connect again “onconnect” doesn’t get called for the new connection (and the Centrals time out).

For the connection/onconnect/other bt code I’ve cut/pasted from the sample code.

Why do subsequent connections fail after a Central disconnect?

Thanks!

Scott

Are you changing anything between connections? iOS and, I presume, macOS cache peripheral service details so will not see changes until you restart BT. Are you using GATT security?

Certainly, my own work with Core Bluetooth doesn’t show what you’re seeing, and I connect/disconnect quite aggressively to mimimise radio use, eg. connect to get device info, disconnect, re-connect to get a list of local WLANs, disconnect, re-connect to write new WiFi credentials.

Some (pre-release) sample code here.

No, I’m not changing anything between connect attempts and I’m using bt.setsecurity at ‘1’ and it’s behaving as expected. Is there a different security setting for the GATT server?

Thanks for the sample code - I’m going to dig into that and see what I can learn. If I figure out what the issue was I’ll post again with any insights.

Scott

So the plot thickens…I downloaded the sample code, fired up Xcode and got the demo app running. Sure enough, it connects/disconnects pretty aggressively and without a hitch. I also fired up LightBlue on the same device and can connect/disconnect on both apps without a hitch.

However, when I use the Bluetooth Explorer tool (part of “More developer tools” with Xcode), it’s a one-shot deal. I can connect and retrieve the GATT server info. But when I disconnect (initiated from the Mac), I can’t make any more connections to the Imp (from either the iPhone or the Mac).

Now, given my target use case is from an iPhone, this almost doesn’t make the cut as a minor annoyance. But I thought you might want to know given this is beta code.

Thanks again for the help.

Scott