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

Creating 2 characteristics with a custom value base UUID

Hi,

I have read through this tutorials on how to develop custom UUID, and I have implemented it successfully.

But I need to have 2 characteristics. I have basically duplicated the codes for the custom UUID in order to have 2 characteristics.

I am not sure that is the way to do it.

When I compile, there is no error but I am not able to see the second characteristics on the nRF Connect.

Below is snippet of the code for ble_cus.h


  I also tried to change the NRF_SDH_BLE_VS_UUID_COUNT from 1 to 2 but instead the DK does not advertise.

I appreciate any guide to resolving this. Thanks.

Parents
  • Hi, 

    You don't need to increase NRF_SDH_BLE_VS_UUID_COUNT  if you use the same UUID base for 2 characteristics. 

    Please try to debug and find where you get an error. You may want to follow this guide on how to do debugging. 

  • As I stated earlier, I do not get any error. I created two characteristics: 0xADCA and 0xADCB.
    The code compiles successfully, and it advertises..
    The only issue is that I do not see the second characteristics (0xADCB) on the nrF Connect when I connect.

  • You mentioned that the DK didn't advertise in your post. 


    Could you post the code you setup your characteristics (in your .c file) ? 

    Also make sure you check the return code of every softdevice API you call. 

  • For the main.c I have this:



    For the ble_cus.c I have this:

  • You are calling this:  return custom_value_char_add(p_cus, p_cus_init);

    You know the effect of return statement right ? It will end the execution of current function and return. So the second call to custom_value2_char_add() would never work. You should use "err_code = cu.."  instead. 

Reply
  • You are calling this:  return custom_value_char_add(p_cus, p_cus_init);

    You know the effect of return statement right ? It will end the execution of current function and return. So the second call to custom_value2_char_add() would never work. You should use "err_code = cu.."  instead. 

Children
  • Thanks Hung. Using err_code = custom_value_char_add(p_cus, p_cus_init) resolved the issue.
    The way i implemented this seems lengthy. Is there a better approach to creating 2/more characteristics other than the way I did it?

  • Hi Chukwuemeka,

    Did find an alternative way to add more than two characteristics? as the earlier one is very lengthy.