Connect/Disconnect callback for BLE events on peripheral

I am designing a BLE peripheral (i.e. that advertises and connects to host) using the BluetoothServices app as a model. It works fine but I want to add callbacks for connection and disconnection events, I have been unable to find any examples. Does anyone know any? Thanks.