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

How to add more than one custom service.

Hi! 

I'm trying to implement my own service, which is based on Thingy TCS and another one I implemented by following this tutorial. https://github.com/bjornspockeli/custom_ble_service_example.

I'm new to developing BLE solutions.

I do these things:

  • Create a new Custom Service
  • Add new Characteristics
  • Add the new CUSTOM_SERV_UUID to advertising array in main.c
  • Set NRF_SDH_BLE_VS_UUID_COUNT to 2 inside the sdk_config.h
  • Initialize service.
  • Set NRD_SDH_BLE_GATTS_ATTR_TAB_SIZE to 2000, instead of 1408, inside the sdk_config.h.

But when I try to run, my application stops to do advertising. My application crashes when executing this code, inside the ble_wcs_init function, which is inside  in ble_wcs.c:

err_code = sd_ble_uuid_vs_add(&wcs_base_uuid, &p_wcs->uuid_type);

And after this, the error 4 is returned from sd_ble_uuid_vs_add() function.

I think I have two possible errors:
1 - I need to set the RAM_START and RAM_SIZE values. But how can I find a correct value from RAM_SIZE?
2 - When I created my new service, I put this in an advertising package and this made it exceed the allowed 31-byte value of advertising, one option is to configure advertising packet to scan response packet. But I do not want to do this, because my own "TCS" service does not need to be inside the ad packet.

Could anyone help me to solve this issue?

Ps: Sorry for my English and my question. 

Parents
  • Make sure to adjust the number of vendor specific UUID during the ble stack initialization:

    static void ble_stack_init(void)
    {
    [...]
    // Configure number of custom UUIDS.
    memset(&ble_cfg, 0, sizeof(ble_cfg));
    ble_cfg.common_cfg.vs_uuid_cfg.vs_uuid_count = 2;
    err_code = sd_ble_cfg_set(BLE_COMMON_CFG_VS_UUID, &ble_cfg, ram_start);
    APP_ERROR_CHECK(err_code);
    [...]

    // Enable BLE stack.
    err_code = softdevice_enable(&ram_start);
    APP_ERROR_CHECK(err_code);

    // Register with the SoftDevice handler module for BLE events.
    err_code = softdevice_ble_evt_handler_set(ble_evt_dispatch);
    APP_ERROR_CHECK(err_code);

    // Register with the SoftDevice handler module for BLE events.
    err_code = softdevice_sys_evt_handler_set(sys_evt_dispatch);
    APP_ERROR_CHECK(err_code);
    }

  • Hi, I really need to do this "ble_cfg.common_cfg.vs_uuid_cfg.vs_uuid_count = 2;" ?

    Even if I set this value in sdk_config.h?

    Thank you for your reply.

Reply Children
Related