I am trying to bond a central nordic board to another nordic board acting as a peripheral, however somewhere along the way the bonding fails. I started on the peripheral side with my debugging and found that every time bonding was attempted it would give me the error PM_CONN_SEC_ERROR_DISCONNECT. I couldn't find anything causing an unexpected disconnect on the peripheral side so I turned to the central side. Here I believe I've tracked the problem down the function ble_conn_state_role(). It always returns BLE_GAP_ROLE_INVALID instead of BLE_GAP_ROLE_CENTRAL. As a result pm_conn_secure() fails when it is called. My issue is I have no idea why the role of the device is wrong. If I remove the bonding code the two devices connect and function as expected, connecting and sending ble data. So I guess my question is how does the device role get set and what causes the device role to be invalid?
I based my code for setting up the peer manager off the code in the example ble_app_rscs_c.