Hello together,
here are some infos about my project:
SoftDevice: S140
Hardware: nRF52840 DK
Software: Segger Studio
Memory settings: FLASH_PH_START=0x0
FLASH_PH_SIZE=0x100000
RAM_PH_START=0x20000000
RAM_PH_SIZE=0x40000
FLASH_START=0x27000
FLASH_SIZE=0xda000
RAM_START=0x20002300
RAM_SIZE=0x3dd00
I am trying to connect to a second nRF board via Bluetooth and then use it to turn LED's on the first board on and off.
I tried to combine my advertising program (which works by itself) with the Blinky example program. So far this also worked, however I always get a memory error when initializing the following function: sd_ble_gap_adv_set_configure().
I have already tried on the memory configuration but without success.
Maybe someone can tell me if what I have in mind is even possible or if I can expand the memory somehow.
Error message via UART:
<error> app: ERROR 4 [NRF_ERROR_NO_MEM] at C:\...\main.c:646
PC at: 0x000321E3
<error> app: End of error report
Here is my complete function in which sd_ble_gap_adv_set_configure() is called:
static void advertising_initialisierung(void)
{
ret_code_t err_code;
ble_advertising_init_t advertising_parameter;
memset(&advertising_parameter, 0, sizeof(advertising_parameter));
advertising_parameter.advdata.name_type = BLE_ADVDATA_FULL_NAME;
advertising_parameter.advdata.include_appearance = true;
advertising_parameter.advdata.flags = BLE_GAP_ADV_FLAGS_LE_ONLY_GENERAL_DISC_MODE;
advertising_parameter.config.ble_adv_fast_enabled = true;
advertising_parameter.config.ble_adv_fast_interval = ADVERTISING_INTERVAL_BEI_FAST_ADVERTISING;
advertising_parameter.config.ble_adv_fast_timeout = ZEITSPANNE_NACH_DER_ADVERTISING_GESTOPPT_WIRD;
advertising_parameter.evt_handler = advertisement_ereignis_verarbeitung;
err_code = ble_advertising_init(&instanz_von_advertising, &advertising_parameter);
APP_ERROR_CHECK(err_code);
ble_advertising_conn_cfg_tag_set(&instanz_von_advertising, DEFAULT_KONFIGURATIONS_KONSTANTE);
ble_advdata_t advdata;
ble_advdata_t srdata;
ble_uuid_t adv_uuids[] = {{LBS_UUID_SERVICE, m_lbs.uuid_type}};
// Build and set advertising data.
memset(&advdata, 0, sizeof(advdata));
advdata.name_type = BLE_ADVDATA_FULL_NAME;
advdata.include_appearance = true;
advdata.flags = BLE_GAP_ADV_FLAGS_LE_ONLY_GENERAL_DISC_MODE;
memset(&srdata, 0, sizeof(srdata));
srdata.uuids_complete.uuid_cnt = sizeof(adv_uuids) / sizeof(adv_uuids[0]);
srdata.uuids_complete.p_uuids = adv_uuids;
err_code = ble_advdata_encode(&advdata, m_adv_data.adv_data.p_data, &m_adv_data.adv_data.len);
APP_ERROR_CHECK(err_code);
err_code = ble_advdata_encode(&srdata, m_adv_data.scan_rsp_data.p_data, &m_adv_data.scan_rsp_data.len);
APP_ERROR_CHECK(err_code);
ble_gap_adv_params_t adv_params;
// Set advertising parameters.
memset(&adv_params, 0, sizeof(adv_params));
adv_params.primary_phy = BLE_GAP_PHY_1MBPS;
adv_params.duration = APP_ADV_DURATION;
adv_params.properties.type = BLE_GAP_ADV_TYPE_CONNECTABLE_SCANNABLE_UNDIRECTED;
adv_params.p_peer_addr = NULL;
adv_params.filter_policy = BLE_GAP_ADV_FP_ANY;
adv_params.interval = APP_ADV_INTERVAL;
err_code = sd_ble_gap_adv_set_configure(&m_adv_handle, &m_adv_data, &adv_params);
APP_ERROR_CHECK(err_code);
}