X-Nucleo-BNRG2A1 BLE Central disconnects right after connection.
I am trying to use X-Nucleo-BNRG2A1 as a BLE Central Device. My BLE peripheral is based on STM32WB15CC (Which is working fine). On the central code, I am using the central example from CubeIDE. I can scan and see my peripheral. I managed to connect to it. However, as soon as it connects, it disconnects giving me "GATT Procedure completed with error 0x41 0x0806". Here, 0x41 = error code (referring to Failed). And 0x0806 is the connection handle.
I tried to modify the example by adding a primary service discovery inside the connection complete event callback. It fails to discover service. The debug message I get is "aci_gatt_disc_all_primary_services() failed: 0x46". No idea what 0x46 refers to.
FYI, the connection code (in the central) is: aci_gap_create_connection(SCAN_P, SCAN_L,
saved_devices.dev_info[dev_index].addr_type,
saved_devices.dev_info[dev_index].bdaddr,
PUBLIC_ADDR, 6, 80, 1, 60, 2000 , 2000);)
and the advertising code in the peripheral is: aci_gap_set_discoverable(
ADV_TYPE,
CFG_FAST_CONN_ADV_INTERVAL_MIN,
CFG_FAST_CONN_ADV_INTERVAL_MAX,
CFG_BLE_ADDRESS_TYPE,
ADV_FILTER,
0,
0,
0,
0,
6,
80);
I tried changing the min max intervals. No luck either. Btw, I can connect to the peripheral using any BLE app and it works fine. Any idea what I'm doing wrong in the central code?