how to read and enable notifications for custom UUIDs

Hi there,

I am developing a central in nrf52840 dk using SDK v2.0.0 in VS code. 

The peripheral uses 128 bit custom UUIDs. The peripheral is working fine with nrf connect. With my central dk,

it is possible me to connect with  peripheral and reading services ,characteristics etc. 

 I need to enable notifications for some of the characteristics.  1. How can I enable notifications for custom 128 bit UUID services?

Referring on google, I found that the CCCD has a 128 bit UUID 00002902-0000-1000-8000-00805f9b34fb. Does it is enough to enable notifications?

It is possible me to use BAS and battery percentage is available in central side.

I am adding a small portion code where I use CCDS...

 else if (!bt_uuid_cmp(discover_params.uuid,&tx_chrc_uuid)) {
		//memcpy(&uuid, &ccc128_uuid, sizeof(uuid));
		memcpy(&uuid3, BT_UUID_GATT_CCC, sizeof(uuid3));
		discover_params.uuid = &uuid3.uuid;
		discover_params.start_handle = attr->handle + 2;
		discover_params.type = BT_GATT_DISCOVER_DESCRIPTOR;
		subscribe_params.value_handle = bt_gatt_attr_value_handle(attr);
		err = bt_gatt_discover(conn, &discover_params);
		if (err) {
			printk("Discover failed (err %d)\n", err);
		}
	}	
		
	else {
		subscribe_params.notify = notify_func;
		subscribe_params.value = BT_GATT_CCC_NOTIFY;
		subscribe_params.ccc_handle = attr->handle;

		err = bt_gatt_subscribe(conn, &subscribe_params);
		if (err && err != -EALREADY) {
			printk("Subscribe failed (err %d)\n", err);
		} else {
			printk("[SUBSCRIBED]\n");
		}

		return BT_GATT_ITER_STOP;
	 }

NB:code snippet from callback discover function

Currently, using this code I don't get any notifications . I think it is not entering the call back notify function.

What should be the reason for this?

2. How can I write values to the peripheral? (write without response)

   What should I do for writing it more than once(like in mobile app:nRF connect)

Thanks in Advance...

Parents Reply
  • yes. I have already tried to build the central based on central_hr example with 16 bit UUIDs. Here I wrote 2 services and enable 3 characteristics with notifying data. It works fine. But the notification function is not working when I use 128 bit UUIDs. the bt_gatt_subscribe () returns 0 but callback function is not triggering

    The issue is resolved. The issue is in the attribute handles. When correct handle used, the problem has solved.

Children
No Data
Related