Timeout when I try to read the descriptor

I tried to create a descriptor for a characteristic. I modified the app_blinky and added a ble_add_descr_params_t variable. After The Initialisation and definition of the ble_add_descr_params_t the descriptor is added with the descriptor_add funktion. Then the descriptor is added to the add_char_params.p_user_descr. The characteristic_add function is called after this.

When I run the code I don't ge an error report or anything else. The NRF_LOG just says :

<info> app: Blinky example started

<info> app: Connected

When I connet with an other nRF Board via the nRF Connect Bluetooth Low Energy App, I can see that the characteristic has something "attatched". But if I want to read the descriptor of the characteristic I get a timeout. It's the same of a Phone.

I'm not sure if I called the function right.

	err_code =descriptor_add(p_lbs->service_handle, & char_params, &p_lbs->service_handle);

Parents
No Data
Reply
  • Hi Moritz, 

    You need to give the descriptor a UUID, a own handle and initialize it with the correct parameters

        // Add descriptor UUID to top off ble_lbs.h
        #define LBS_UUID_LED_DESC    0x1526
        
        // Modify ble_lbs_s struct in ble_lbs.h
        struct ble_lbs_s
        {
        uint16_t                    service_handle;      /**< Handle of LED Button Service (as provided by the BLE stack). */
        ble_gatts_char_handles_t    led_char_handles;    /**< Handles related to the LED Characteristic. */
        ble_gatts_char_handles_t    button_char_handles; /**< Handles related to the Button Characteristic. */
        uint8_t                     uuid_type;           /**< UUID type for the LED Button Service. */
        ble_lbs_led_write_handler_t led_write_handler;   /**< Event handler to be called when the LED Characteristic is written. */
        // Add handle for descriptor in the LBS struct
        uint16_t                    desc_handle;         
        };
    
        
        // Add this code below the led_char_add in ble_lbs_init()
        static uint8_t desc[] = "Hello";
        ble_add_descr_params_t desc_params ={0};
        desc_params.uuid = LBS_UUID_LED_DESC;
        desc_params.uuid_type = p_lbs->uuid_type;
        desc_params.is_value_user = false;
        desc_params.read_access = 1;
        desc_params.init_len = 0;
        desc_params.max_len = sizeof(desc);
        desc_params.p_value = desc;
    
        err_code= descriptor_add(p_lbs->led_char_handles.value_handle, &desc_params, &p_lbs->desc_handle);
        VERIFY_SUCCESS(err_code);
    

Children