In peripheral.c in gapRole_ProcessGAPMsg(), I found the code:
if ( gapRole_AdvEnabled)
{
// End advertising so we can restart advertising in order
// to change to connectable advertising from nonconnectable.
VOID GAP_EndDiscoverable( gapRole_TaskID );
}
else // Turn advertising back on.
{
gapRole_AdvEnabled = TRUE;
VOID osal_set_event( gapRole_TaskID, START_ADVERTISING_EVT);
}
If you disable advertising due to a connection event, the stack turns it back on. Volume 6 of the BLE core spec chapter 1.1 says it perfectly fine to go from a connected to state to a standby state. Why does the stack force us to advertise when a connection ends?