11 Replies Latest reply on Aug 22, 2015 6:05 AM by rajvirzala

    Is WICED WIFI 3.3.1 supports CCCD in ble peripheral mode ?



      I need to send notifications from WICED device working in ble peripheral mode. However, I can't find any API to enable Client Characteristics Configuration Descriptor(CCCD).


      There is API to send notification wiced_bt_gatt_send_notification(....); but that is not good method to send notifications.


      Can anyone guide me how to enable CCCD ?MichaelF_56

        • 1. Re: Is WICED WIFI 3.3.1 supports CCCD in ble peripheral mode ?

          I believe JayG_26 explains how to enable Client Characteristics Configuration Descriptors within the ble_proximity_reporter application inside of this thread: 128-bit UUID support on WICED SDK 3.3.1


          userc_20416 may also be able to assist.

          • 2. Re: Is WICED WIFI 3.3.1 supports CCCD in ble peripheral mode ?

            I have gone through that link, but didn't find any useful info for the same.

            From "ble_proximity_reporter" project, I can find sample code for write & read characteristics. In the same way can I have sample app  in which there will be source code for notify & indicate( especially for CCCD, how to enable & disable)


            Also, how to define "characteristics user description" using API "CHAR_DESCRIPTOR_UUID16(handle, uuid, permission)". In this API,I can't find any parameter to define string for "characteristics user description"MichaelF_56

            • 4. Re: Is WICED WIFI 3.3.1 supports CCCD in ble peripheral mode ?

              I do not know the answer to your question.

              Perhaps there is someone on the wifi AE team that can help.

              • 5. Re: Is WICED WIFI 3.3.1 supports CCCD in ble peripheral mode ?

                Can u ask someone from that team to help me ?

                • 6. Re: Is WICED WIFI 3.3.1 supports CCCD in ble peripheral mode ?

                  can anybody help me ? I need answer to this question ASAP.


                  • 7. Re: Is WICED WIFI 3.3.1 supports CCCD in ble peripheral mode ?

                    I will work with the Manager of the AE/FAE team to come up with a path for support on this issue.



                    • 8. Re: Is WICED WIFI 3.3.1 supports CCCD in ble peripheral mode ?

                      Hi Rajvirsinh,


                      In order to use notifications in BLE peripheral mode, you will need to define the CCCD in the GATT database and send the notifications or indications according to the value the client sets it. I attached a zip file that has addition of code using a CCCD for notifications in the ble_proximity_reporter. Please look at the following for a description of changes made (in red).


                      ** This was verified on a BCM943341WCD1 board with the iPhone LightBlue app.


                      1. First you will need to define the characteristic descriptor in wiced_bt_gatt_db.c, and also add properties to the characteristic that you want to receive notifications.













                                            LEGATTDB_PERM_READABLE | LEGATTDB_PERM_WRITE_REQ ),




                      2. In wiced_bt_gatt_db.h, add a handle for HDLC_TX_POWER_LEVEL_DESCRIPTOR,



                          // ***** Primary service 'TX Power'








                      3. In ble_proximity_reporter.c, add a global descriptor value and add a clause to function ble_proximity_gatt_write_request() to enable the client writing to the descriptor.



                      static int8_t  proximity_tx_power_level_descriptor;


                      case HDLC_TX_POWER_LEVEL_DESCRIPTOR:

                            proximity_tx_power_level_descriptor = attribute_value;

                            WPRINT_APP_INFO( ("POWER_LEVEL_DESCRIPTOR written as 0x%x\n", attribute_value));




                      4. Once the descriptor is defined, we are going to use the function wiced_bt_gatt_send_notification() to send notifications every 2 seconds. We shall set the value to decrease from 20 to 1. The following code should be added in application_start() after wiced_bt_stack_init() in ble_proximity_reporter.c.



                      void application_start( void )


                          /* Initialize WICED platform */

                          wiced_init( );


                          /* Initialize Bluetooth controller and host stack */

                          wiced_bt_stack_init( ble_proximity_management_callback, &wiced_bt_cfg_settings, wiced_bt_cfg_buf_pools );



                          for (uint8_t i = 20; i > 0; i-- )


                              // If notification is set

                              if ( proximity_tx_power_level_descriptor == 0x1 )


                                  proximity_tx_power_level = i;

                                  wiced_bt_gatt_send_notification (proximity_connection_handle, HDLC_TX_POWER_LEVEL_VALUE, sizeof(proximity_tx_power_level), &proximity_tx_power_level );







                      **For indications, use the function wiced_bt_gatt_send_indication() when the proximity_tx_power_level_descriptor == 0x2


                      5. For the first parameter in the function, proximity_connection_handle, this should be defined as a global variable and maintained in ble_proximity_gatt_cback(). Whenever a new connection is established it should store the connection handle, and when connection is lost it should reset it to 0. ( Add red code in ble_proximity_reporter.c )



                      static uint16_t proximity_connection_handle = 0;


                      /* GATT event handler */

                      static wiced_bt_gatt_status_t ble_proximity_gatt_cback( wiced_bt_gatt_evt_t event, wiced_bt_gatt_event_data_t *p_event_data )


                          wiced_bt_gatt_status_t status = WICED_BT_GATT_SUCCESS;

                          uint8_t *bda;


                          switch ( event )


                              case GATT_CONNECTION_STATUS_EVT:

                                  /* GATT connection status change */

                                  bda = p_event_data->connection_status.bd_addr;

                                  WPRINT_BT_APP_INFO( ("GATT connection to [%02X:%02X:%02X:%02X:%02X:%02X] %s.\n", bda[0], bda[1], bda[2], bda[3], bda[4], bda[5], (p_event_data->connection_status.connected ? "established" : "released")) );


                                  if ( p_event_data->connection_status.connected )


                                      /* Connection established. Get current TX power  (required for setting TX power attribute in GATT database) */

                                      wiced_bt_dev_read_tx_power( p_event_data->connection_status.bd_addr, p_event_data->connection_status.transport, (wiced_bt_dev_cmpl_cback_t *) ble_proximity_tx_power_callback );


                                      /* Store information  */

                                      proximity_connection_handle = p_event_data->connection_status.conn_id;


                                      /* Disable connectability. */

                                      wiced_bt_start_advertisements( BTM_BLE_ADVERT_OFF, 0, NULL );




                                      /* Connection released. Re-enable BLE connectability. */

                                      wiced_bt_start_advertisements( BTM_BLE_ADVERT_UNDIRECTED_HIGH, 0, NULL );

                                      /* test code for directed adv */

                                      /* wiced_bt_start_advertisements (BTM_BLE_ADVERT_DIRECTED_HIGH, 0, p_event_data->connection_status.bd_addr); */


                                      proximity_connection_handle = 0;


                                      WPRINT_BT_APP_INFO( ("Waiting for proximity monitor to connect...\n") );







                      6. That's it! Now compile the code and download it to your WICED board. When you connect to "WICED Proximity" and select "Tx Power Level" from the LightBlue app of your iPhone (below) or the WICED Smart Explorer app in your Android device.


                      You should see the notifications arriving once you set "Listen to notifications". This app only counts down from 20 to 1 every 2 seconds after it resets, so if you don't see it counting down on your client try resetting the WICED board and connecting to it faster.




                      I hope this helped in getting you started with notifications. Please let us know if this works for you!




                      1 of 1 people found this helpful
                      • 9. Re: Is WICED WIFI 3.3.1 supports CCCD in ble peripheral mode ?


                        JaeyoungY_71 MichaelF_56

                        Thanks for the help. I tested the given code for both notification & indication, working fine.

                        However, I have another question which I mentioned above regarding "Characteristic User Description Descriptor".

                        I can see API for the same "CHAR_DESCRIPTOR_UUID16(handle, uuid, permission)", in which I can't find any parameter to write user defined string, e.g. "Temperature in the room".

                        So, how to write user defined string in "Characteristic User Description Descriptor" ?

                        • 10. Re: Is WICED WIFI 3.3.1 supports CCCD in ble peripheral mode ?

                          Hi Rajvirsinh,


                          To write a user defined string for CHAR_DESCRIPTOR_UUID16, you need to do the following.


                          1. Add a char description and make the permission readable in wiced_bt_gatt_db.c



                          2. Add USER_DESCRIPTOR in enum in wiced_bt_gatt_db.h


                          3. In ble_proximity_reporter.c, define a global user_defined_str

                          static char user_defined_str[] = "Temperature in the room";


                          4. Add the following switch clause to ble_proximity_gatt_read_request() in ble_proximity_reporter.c

                             case USER_DESCRIPTOR:

                                 p_attribute_value_source = user_defined_str;

                                 attribute_value_length = sizeof( user_defined_str );



                          5. In your LightBlue you should now see the string attached to the characteristic



                          1 of 1 people found this helpful
                          • 11. Re: Is WICED WIFI 3.3.1 supports CCCD in ble peripheral mode ?

                            Hi jaeyoung,


                            Thanks for the reply. Tested  by adding code you asked to do, working fine.


                            Again. Thanks for the help.