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

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
  • 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);
    

  • Hi bjorn,

    Thank you for the fast response. When I implement your code the descriptor_add function returns a 8 as error code and the Program stops. The Log doesn't says anything unusual. While Compiling I only get a warning for mixing types in your line 23 (desc_params.read_access = 1;) but this can be fixed with SEC_OPEN (what is the same).

  • Are you able to see on the call stack where in descriptor_add the 0x08 error originates from?

  • The error is comming from the function sd_ble_gatts_descriptor_add. Unfortunately I'm not able to specify it more, because I can't see in this function.

  • HI Moe, 

    NRF_ERROR_INVALID_STATE(0x08) is Invalid state to perform operation, a characteristic context is required. So I suspect that you're not passing the right handle to the descriptor_add() function. 

    Please post the entire ble_lbs_init() function so that I can check that you're using the correct handle. 

    Best regards

    Bjørn

Reply Children
Related