This post is older than 2 years and might not be relevant anymore
More Info: Consider searching for newer posts

fter executing "ble_advertising_init"Error 4 occurs. Please tell me the cause

OS in development environment :Windows10
HARD :(Taiyo Yuden)EBSHSN Series Evaluation Board : Central / Peripherals
CPU :(Nordic) nRF52832 / ARMR Cortex-M4F 32 bit processor 28-pin Land Grid Array / 15GPIOs / SWD
builder :SEGGER Embedded Studio for ARM Release 3.34a Build 2018022300.35192 Windows x64
Copyright 2014-2018 SEGGER Microcontroller GmbH & Co. KG
Copyright 1997-2018 Rowley Associates Ltd.
GCC/BINUTILS: Built using the GNU ARM Embedded Toolchain version 6-2017-q2-update source distribution
Clang/LLVM: Built using the version 5.0.0 source distribution
Soft Ver:nRF5_SDK_15.3.0_59ac345

I changed the source to include the ServiceUUID in the AdvertisingPacket, but I get a 0x04 error. Please tell me the cause.
Where the error occurred:
After executing "ble_advertising_init" with "Advertising_init ()" Error 4 occurs.
The source is attached below

---------< Source code >----------------------------------------------------------------

static void advertising_init(void)
{
    ret_code_t err_code;
    ble_advdata_t advdata;
    ble_advdata_t srdata;

/*-< 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(m_adv_uuids) / sizeof(m_adv_uuids[0]);
    srdata.uuids_complete.p_uuids = m_adv_uuids;

/*-< Data encoding (Input:advdata, Output:p_data, In/Output:len) >-*/
    err_code = ble_advdata_encode(&advdata, m_adv_data.adv_data.p_data, &m_adv_data.adv_data.len);
    APP_ERROR_CHECK(err_code);

/*-< Data encoding (Input:srdata, Output:p_data, In/Output:len) >-*/
    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);

/*-< Set advertising parameters. >-*/
    ble_gap_adv_params_t adv_params;

    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);


----------< An error occurred when adding the following sources. >-----------

/*-< initial Build and set advertising data. >-*/
    ble_advertising_init_t init; /* iniitial data */

    memset(&init, 0, sizeof(init));
    init.advdata.name_type = BLE_ADVDATA_SHORT_NAME;
    init.advdata.short_name_len = 4;
    init.advdata.include_appearance = false; /* non Appearance */
    init.advdata.flags = BLE_GAP_ADV_FLAGS_LE_ONLY_GENERAL_DISC_MODE;
    init.advdata.uuids_complete.uuid_cnt = sizeof(m_adv_uuids) / sizeof(m_adv_uuids[0]);
    init.advdata.uuids_complete.p_uuids = m_adv_uuids;
    init.config.ble_adv_fast_enabled = true;
    init.config.ble_adv_fast_interval = APP_ADV_INTERVAL;
    init.config.ble_adv_fast_timeout = APP_ADV_DURATION;
    init.evt_handler = on_adv_evt;

    err_code = ble_advertising_init(&m_advertising, &init);              <-------------------------------------------------- The line where the error
    APP_ERROR_CHECK(err_code);

    ble_advertising_conn_cfg_tag_set(&m_advertising, APP_BLE_CONN_CFG_TAG);
}
---------< Source end >--------------------------

---------< Error message >-----------------------------------------------------------------------------

<error> app: ERROR 4 [NRF_ERROR_NO_MEM] at C:\Nordic52SDK\nRF5_SDK_15.3.0_59ac345\examples\VS-AP01_P2 --\VS-AP01_P_210208a\main.c:1476
PC at: 0x00033F33
<error> app: End of error report
---------< Message end >--------------------------

Thank you

Parents Reply
  • yokokawa said:
    Error 4 has occurred in "err_code = ble_advertising_init (& m_advertising, & init);".

     => So have you stepped into the code of ble_advertising_init() function and check which exact function that return the error 4 ? 
    Please get familiar to how to debug the code. 

    It's most likely because your change in adding the Service UUID to the advertising packet making the size of the packet is too big for a normal advertising packet (max 31 bytes including all the headers. flags). 

Children
No Data
Related