On a keyfob based off the CC2541MINI-DK reference design + v1.4.0 of the TI BLE stack (with GAP_BONDINGS_MAX=1) I'm seeing an encryption failure issue that's really hard to cause. But once the issue happens, I can reproduce it over and over again.
Here's how a keyfob that's now in the 'bad' state behaves with BTool:
1. Establish link.
2. Pair + Bond.
3. Save LTK.
4. Encrypt link using saved LTK. This is successful.
5. Terminate link.
6. Re-establish link.
7. Re-encrypt the link using saved LTK (from step 4). This fails with status 0x06 ("Invalid Event Id").
The screen logs from an example Btool session is attached.
Under normal conditions, steps 1-7 are always successful no matter how many times I run the sequence. But once the keyfob is in a bad state, step 7 fails consistently; yet step 4 is always successful.
Power cycling the keyfob does not fix the issue. But I've discovered that triggering "ERASE_ALL_BONDS" (using a UI hook I had put in earlier) causes the issue to go away. This suggests that the BondManager is getting into a state where it's unable to store the LTK onto flash, yet correctly uses it for re-encryption initially. Somehow ERASE_ALL_BONDS seems to restore the BondManagar back to working state.
Can anyone help with ideas on what might be causing this problem and how we could fix it?
I have a couple of keyfobs in this 'bad' state if more logs are needed.
Thanks in advance
[Update, 11-SEP-2014] There is indeed another post in this forum with symptoms/behaviours that identically map to mine above, but which appeared after mine. No resolution on it yet.