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

example ble_app_hrs_rscs_relay with custom ble_cus

Hello,

I need to have a nrf52932 working as central and peripheral. So I started from the ble_app_hrs_rscs_relay example. It works fine, I can connect to my iPhone and get te data from another board program with the ble_app_hrs example.

As next step, I would like to have a custom service for peripheral side instead of the hrs and rscs services (and still scanning and being central for hrs and rscs external peripheral devices). I have start to implement the ble_cus (I was able to make it working on another project). when the function services_init() is called:

static void services_init(void)
{
        ret_code_t          err_code;
        nrf_ble_qwr_init_t  qwr_init = {0};
        ble_cus_init_t      cus_init = {0};

        // Initialize Queued Write Module.
        qwr_init.error_handler = nrf_qwr_error_handler;


        for (uint32_t i = 0; i < NRF_SDH_BLE_TOTAL_LINK_COUNT; i++)
        {
            err_code = nrf_ble_qwr_init(&m_qwr[i], &qwr_init);
            APP_ERROR_CHECK(err_code);
        }
//        err_code = nrf_ble_qwr_init(&m_qwr, &qwr_init);
//        APP_ERROR_CHECK(err_code);

        //memset(&cus_init, 0, sizeof(cus_init));

         // Initialize CUS Service init structure to zero.
        cus_init.evt_handler                = on_cus_evt;
    
        BLE_GAP_CONN_SEC_MODE_SET_OPEN(&cus_init.custom_value_char_attr_md.cccd_write_perm);
        BLE_GAP_CONN_SEC_MODE_SET_OPEN(&cus_init.custom_value_char_attr_md.read_perm);
        BLE_GAP_CONN_SEC_MODE_SET_OPEN(&cus_init.custom_value_char_attr_md.write_perm);

        //NRF_LOG_INFO("test 0x%x.", rien);
    
        err_code = ble_cus_init(&m_cus, &cus_init);
        NRF_LOG_INFO("error 5 0x%x.", err_code);

        APP_ERROR_CHECK(err_code);
}

I get the error 0x000000004 which is for memory allocation.

but I don't get any warning or error in the nrf_sdh_ble_enable(uint32_t * const p_app_ram_start) function. I have modify the function to have:
uint32_t const app_ram_start_link = *p_app_ram_start;

ret_code_t ret_code = sd_ble_enable(p_app_ram_start);

NRF_LOG_WARNING("Change the RAM start location from 0x%x to 0x%x.",
                        app_ram_start_link, *p_app_ram_start);
NRF_LOG_WARNING("Maximum RAM size for application is 0x%x.",
                        ram_end_address_get() - (*p_app_ram_start));

the value I get for the RAM start is 0x20002D50 (instead of 0x20002D58 originally) and RAM size 0xD2B0 (instead of 0xD2A8). If I use this new value, I still get the error 4.

could it come from another part of the memory?

thank you

best regards
Related