Our Peripheral application has registered callbacks with GAP and GATT (GAPRole_StartDevice and GATTServApp_RegisterService respectively). We have encountered a situation where these callbacks are called out of order.
This is triggered by a Central device which uses unacknowledged GATT writes and the problem occurs when the Central device sends a write command followed by a disconnect command in the same connection interval. We're seeing the Peripheral callback indicating a disconnect and sometime later the GATT write callback is called; from the application's view, the write occurs after disconnect.
This issue exacerbates the problem of not being able to write to NV RAM while connected because we're using the disconnect indication to trigger the committing data to NV RAM.
Here's the sequence we see:
GAP callback - GAPROLE_STARTED
GAP callback - GAPROLE_ADVERTISING
GAP callback - GAPROLE_CONNECTED
GAP callback - GAPROLE_WAITING (indicates disconnect)
GAP callback - GAPROLE_ADVERTISING
GATT callback - Write attribute callback