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

ble_app_template example program - where to find BLE service, characteristics value initialization and definition in code?

Hi I am using the nRF51 DK and I successfully ran the ble_app_template program from examples\ble_peripheral in SDK v10. Using the nRF connect app I am able to do both read and write values.

I want to try creating other services and setting different values for characteristics in the ble_app_template program. For example I want to change the value from '[0] Unknown' to 'Hello' for the Appearance (0x2A01) characteristic. But I cannot find where the default BLE services, characteristics, attributes are initialized and defined in the ble_app_template program. I am using Keil 5 and I tried searching the ble_advdata.c, ble_advertising.c, ble_srv_common.c files, etc from nRF_BLE folder. None of the files I searched had code that mention the Generic Access Service (0x1800) or Generic Attribute (0x1801) services. 

Where should I look to find the code that initializes/defines these services, characteristics, and default values?

2. When I have the NRF 51 DK connected to my PC is there also a way to have Keil terminal/console print the BLE read/write values? 

Thank you!

Parents Reply Children
  • Hi I followed https://devzone.nordicsemi.com/nordic/short-range-guides/b/bluetooth-low-energy/posts/ble-services-a-beginners-tutorial  

    The tutorial used nRFgo studio to create and define a 128-bit base UUID. The tutorial also creates a service UUID, and a pointer to the service UUID is used as a function parameter when initializing & adding the new service. 

    ble_uuid_t        service_uuid;
    ble_uuid128_t     base_uuid = BLE_UUID_OUR_BASE_UUID;
    

    My questions are 1. Is using NRFgo to create the base UUID always necessary?

    2. It seems like we can create a service UUID but we cannot specify the characters of the UUID. Is this correct? Are the service UUID just randomly generated then?

    It also appears that we cannot customize the service handle either. 

    1. No, you can use any other method of your choice for generating a 128 bit base UUID.
    2. Yes. The BLE specification doesn't use names (characters) for identifying services and characteristics but rather UUIDs. In nRF Connect we can identify certain services and characteristic if they use a predefind16 bit UUID (such as the heart rate service) , and certain 128 bit custom UUID (such as NUS). nRF Connect mobile app have the option of displaying a name for a custom service after you've connected to the peripheral. The 16 bit UUID you would add to your custom base UUID can be generated as you chose. 

    Best regards

    Jared 

Related