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

Discovering and connecting to BLE devices with custom 128 bit UUIDs using Zephyr

I have created a couple of custom BLE services and characteristics in a peripheral application.  It shows up in the nRF Connect app and can read the values from sensors connected to the characteristics of these services.  I am struggling to discover and connect to these custom 128 bit UUID services with a central application using another Nordic device.  I can only find samples on how to discover and connect to 16 bit UUID services.  Are there any central application examples or tutorials for custom 128 bit UUID BLE services?  I am using the latest Zephyr to develop applications on nRF52840 MCUs.

  • There's no difference between 16-bit and 128-bit UUIDs with regards to the Discovery Manager's API: 

    You declare the custom UUID with:

    #define MY_SERVICE_UUID 0xd4, 0x86, 0x48, 0x24, 0x54, 0xB3, 0x43, 0xA1, \
    			            0xBC, 0x20, 0x97, 0x8F, 0xC3, 0x76, 0xC2, 0x75
    			            
    #define BT_UUID_MY_SERVICE      BT_UUID_DECLARE_128(MY_SERVICE_UUID)


    And call:
    bt_gatt_dm_start(conn, BT_UUID_MY_SERVICE, &discovery_cb, NULL);


    The second parameter of bt_gatt_dm_start is of type bt_uuid: 
    /** @brief This is a 'tentative' type and should be used as a pointer only */
    struct bt_uuid {
    	u8_t type;
    };


    You are however supposed to pass any of the following types:
    struct bt_uuid_16 {
    	struct bt_uuid uuid;
    	u16_t val;
    };
    
    struct bt_uuid_32 {
    	struct bt_uuid uuid;
    	u32_t val;
    };
    
    struct bt_uuid_128 {
    	struct bt_uuid uuid;
    	u8_t val[16];
    };

  • Thank you  I was not sure if the Discovery Manager differentiates between different sizes of UUIDs.  I will see if I can get it up and running.  Your help is much appreciated.

Related