This discussion has been locked.
You can no longer post new replies to this discussion. If you have a question you can start a new discussion

How to add custom service to the Ble_app_template example

Hello i am using nrf52810 with SDK version 17.0.2 , i want to add custom service to the ble_app_template example and i followed this tutorial link https://github.com/edvinand/custom_ble_service_example so at first debug i got this error as expected 

next i have change the RAM_START AND RAM_SIZE as per the memory size mentioned in the error then i DEBUG it again so the i got 

so i don't know what's happening please help me to resolve this . 

thank you.

Parents
  • Hello,

    Please make sure to have DEBUG defined in your preprocessor defines, like shown in the included image:

    This will make your logger output a detailed error message whenever a non-NRF_SUCCESS error code is passed to an APP_ERROR_CHECK.
    Please do this, and let me know what the error message reads, along with which function that returned the error code pointed to in the error message.

    Best regards,
    Karl

  • Hello,

    mr Karl i am very happy to communicate with you and thank you so much for your reply, i tried as you said  and i got this error,

    thank you,

  • sagarnayakm said:
    mr Karl i am very happy to communicate with you and thank you so much for your reply

    No problem at all, I am happy to help!

    sagarnayakm said:
    i tried as you said  and i got this error,

    Which function returns this error code? Please check the end of the error message to see where the APP_ERROR_CHECK was triggered.

    Best regards,
    Karl

Reply
  • sagarnayakm said:
    mr Karl i am very happy to communicate with you and thank you so much for your reply

    No problem at all, I am happy to help!

    sagarnayakm said:
    i tried as you said  and i got this error,

    Which function returns this error code? Please check the end of the error message to see where the APP_ERROR_CHECK was triggered.

    Best regards,
    Karl

Children
  • Hello,

    yes, i got where exactly its the function service_init()  in that ble_cus_init() it returns err_code 7 please

    have a look at this ,

    thank you,

  • So it seems your ble_cus_init function is returning the NRF_ERROR_INVALID_PARAM error.
    How does this function look? Under what conditions will it return this error code?
    Likely it is just forwarding the error code generated by a SDK function it itself is calling.

    Best regards,
    Karl

  • Hello,

    How does this function look?

    the service_init() function is look this.

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

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

    err_code = nrf_ble_qwr_init(&m_qwr, &qwr_init);
    APP_ERROR_CHECK(err_code);

    /* YOUR_JOB: Add code to initialize the services used by the application.
    ble_xxs_init_t xxs_init;
    ble_yys_init_t yys_init;

    // Initialize XXX Service.
    memset(&xxs_init, 0, sizeof(xxs_init));

    xxs_init.evt_handler = NULL;
    xxs_init.is_xxx_notify_supported = true;
    xxs_init.ble_xx_initial_value.level = 100;

    err_code = ble_bas_init(&m_xxs, &xxs_init);
    APP_ERROR_CHECK(err_code);

    // Initialize YYY Service.
    memset(&yys_init, 0, sizeof(yys_init));
    yys_init.evt_handler = on_yys_evt;
    yys_init.ble_yy_initial_value.counter = 0;

    err_code = ble_yy_service_init(&yys_init, &yy_init);
    APP_ERROR_CHECK(err_code);
    */

    ble_cus_init_t cus_init;


    // Initialize CUS Service.
    memset(&cus_init, 0, sizeof(cus_init));

    err_code = ble_cus_init(&m_cus, &cus_init);
    printf("err_code:%d",err_code);
    APP_ERROR_CHECK(err_code);
    }

    next, like i want to send some data from

    aa-ble_app_template - Custom_service1.zip

    nrf_connect mobile app to the device. If i am not wrong i need to add custom_service to my code right.?? so for this i used this code please have look at the zip.file

    thank you.

  • sagarnayakm said:
    the service_init() function is look this.

    The error seems to be returned by the ble_cus_init not services_init, please show ble_cus_init instead so I may take a look.
    Please also try to find out for yourself why it would return the INVALID_PARAM by checking its API reference - or the API reference of any function which error code is forwarded - and let me know what you think.

    Best regards,
    Karl

  • Hello,

    please show ble_cus_init instead so I may take a look.

    uint32_t ble_cus_init(ble_cus_t * p_cus, const ble_cus_init_t * p_cus_init)
    {
    if (p_cus == NULL || p_cus_init == NULL)
    {
    return NRF_ERROR_NULL;
    }

    uint32_t err_code;
    ble_uuid_t ble_uuid;

    // Initialize service structure
    p_cus->evt_handler = p_cus_init->evt_handler;
    p_cus->conn_handle = BLE_CONN_HANDLE_INVALID;

    // Add Custom Service UUID
    ble_uuid128_t base_uuid = {CUSTOM_SERVICE_UUID_BASE};
    err_code = sd_ble_uuid_vs_add(&base_uuid, &p_cus->uuid_type);
    VERIFY_SUCCESS(err_code);

    ble_uuid.type = p_cus->uuid_type;
    ble_uuid.uuid = CUSTOM_SERVICE_UUID;

    // Add the Custom Service
    err_code = sd_ble_gatts_service_add(BLE_GATTS_SRVC_TYPE_PRIMARY, &ble_uuid, &p_cus->service_handle);
    if (err_code != NRF_SUCCESS)
    {
    return err_code;
    }

    // Add Custom Value characteristic
    return custom_value_char_add(p_cus, p_cus_init);
    }

    let me know what you think.

    i think the UUID which we are passing to the function is wrong.

Related