why do we need cccd ?

what is the purpose of using the cccd with a characteristics? in between, for confirmation, server is the device that provide the data/attributes/characteristic value and client is the one that trying to read/write etc. that data. Also cccd is be configured on the client side or server side?

  • The CCCD is called the Client Characteristic Configuration Descriptor (i.e., CCCD). The CCCD is about a server allowing a client to opt-in to "push" style data updates from the server rather than just reads coming from the client.

    If the client needs to know when data changes it could repeatedly read the data (polling). But a read when the data hasn't changed wastes time, bandwidth, and power. Characteristics (data) that properly support the CCCD also support "push" style notifications (if the client opts in). Rather than the client continually reading the value, it just configures the server to send updates when they happen. This is where the name comes from --- the Client Configures the data (Characteristic) to be pushed)

    If the client wants to have data pushed to it when the data changes, the client will write a value to the CCCD. The value depends on the style of update. There are two styles of push update, one is called "Notification" and the other is called "Indication". With Indication the server gets a confirmation that the client did get the update. With Notification there isn't a confirmation.

    Summary: it's about allowing clients to get updates to data immediately when the data changes rather than wasting time and power polling. For it to work the server needs to support the CCCD on the data and the client needs to opt-in to the "push" updates by writing to the CCCD.

    The Bluetooth SIG description of the CCCD is available at: developer.bluetooth.org/.../DescriptorViewer.aspx

    There are also several intro-to-ble resources that are quite helpful. I like Getting Started with Bluetooth Low Energy: Tools and Techniques for Low-Power Networking by Townsend, et. al (www.amazon.com/.../)