Helo, i'm working on firmware for a device, which should be able to scan for other devices, advertise data and be connectable. Scanning and advertising works. Problems come up when i tried to add code to make device connectable as well. This configuration fails in app_error_handler with error_code 0x00000008, which i can see means NRF_ERROR_INVALID_STATE. Could you guys can help me figure out what is causing this? Im posting my main.c code also.
static void conn_params_init(void)
{
uint32_t err_code;
ble_conn_params_init_t cp_init;
memset(&cp_init, 0, sizeof(cp_init));
cp_init.p_conn_params = NULL;
cp_init.first_conn_params_update_delay = FIRST_CONN_PARAMS_UPDATE_DELAY;
cp_init.next_conn_params_update_delay = NEXT_CONN_PARAMS_UPDATE_DELAY;
cp_init.max_conn_params_update_count = MAX_CONN_PARAMS_UPDATE_COUNT;
cp_init.start_on_notify_cccd_handle = BLE_GATT_HANDLE_INVALID;
cp_init.disconnect_on_fail = false;
cp_init.evt_handler = on_conn_params_evt;
cp_init.error_handler = conn_params_error_handler;
err_code = ble_conn_params_init(&cp_init);
APP_ERROR_CHECK(err_code);
}
and my main looks like this:
bool erase_bonds;
ble_stack_init();
application_data_flash_manager_init();
/* Get identifier of block of flash which is used for R/W operations */
pstorage_block_identifier_get(&handle, 0, &block_0_handle);
pstorage_load(flash_block0_data, &block_0_handle, 16, 0);
application_adc_init();
/* Measure battery level */
battery_adc_value = measure_battery_level();
/* Putting data in advertisement buffer here */
// .....
client_handling_init();
device_manager_init(erase_bonds);
gap_params_init();
services_init();
advertising_init();
conn_params_init();
/* Start atvertising */
advertising_start();