Tool/software:
Just wondering if anyone can confirm or helps with this.
We've had a design for while which operates as a CENTRAL and can connect up to 3 peripherals.
I been working on this build again recently trying to improve connect / disconnect.
One strange thing I've been looking at, is working through disconnect of all three peripherals. This has always been very strange,
with the third disconnect behaving differently and taking a long time.
Normally three device connected, with connHandle 0, 1, 2 assigned. These I use to reference each device and store in an array at connection time.
If I disconnect each in sequence.
0 -> 1 -> 2, the first two would Terminate with Terminate Req status 0x16
all good :- #define LL_STATUS_ERROR_HOST_TERM 0x16 // Connection Terminated By Local Host
the third would also take a long time and Terminate with Terminate Req 0x22
#define LL_STATUS_ERROR_LL_TIMEOUT 0x22 // Link Layer Response Timeout
#define LL_STATUS_ERROR_LL_TIMEOUT_HOST 0x22 // Link Layer Response Timeout
#define LL_STATUS_ERROR_LL_TIMEOUT_PEER 0x22 // Link Layer Response Timeout
I tried big delays between the sequence (thinking the stack was congested or something) - but even 5 seconds disconnect gaps made no difference.
Then today I tried this:
Disconnect in reverse sequence
2->1->0
This work fine and would run fast, always with Terminate Req 0x16 (Happy days!)
But is made me think, is there by some chance the BLE Stack is re-configuring connHandle's once the first is Disconnected.
This would explain why using connHandle 2 as third in the sequence always did something different?
Hence if I use sequence 0..1..2
When 0 disconnects. The remaining valid connhandles are actually to 0..1
When 1 disconnects. The remaining valid connhandle is 0
So my disconnect 2 now doesn't reference a valid connHandle.
But thus, doing it in the other direction is fine.
I sort of need to understand the workings here so I can manage correctly if one of the peripherals disconnects, do I need to correct all my connHandles which I use
to communicate with each peripheral.
Any support / answers appreciated. Can't find any info on this elsewhere :-(
Rob