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.

The callback happen in bluez_signal_device_changed() in primary.c. For example:

    g_variant_get(params, "(&sa{sv}as)", &iface, &properties, &unknown);
    while(g_variant_iter_next(properties, "{&sv}", &key, &value)) {
        LE_INFO("key = %s", key);
        if(!g_strcmp0(key, "Connected")) {
            // this is a connection callback....