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

how to change DIS char value after ble service initialized

Hi,

I want to change value of  serial number after dis init, I want to use sd_ble_gatts_value_set to set the new value, but I dnot know what is the right connection handle for BLE_UUID_SERIAL_NUMBER_STRING_CHAR, how to find it or there is another why to do it?

thanks!

Brian Qin

Parents
  • The handles for the characteristics are stored in structs inside ble_dis.c. Serial number handles are stored in:

    ble_gatts_char_handles_t serial_num_handles;

    A reference to this struct is passed to char_add in ble_dis_init, which again pass this to sd_ble_gatts_characteristic_add where it is filled with the assigned handle.

    Best regards,
    Jørgen

  • I understand what you are asking, I was just telling you where the handle is stored. You will have to modify the service implementation to expose the handle to the application. Note the comment in the service header file about changing the service implementation:

     * @note Attention!
     *  To maintain compliance with Nordic Semiconductor ASA Bluetooth profile
     *  qualification listings, this section of source code must not be modified.
     */

  • Hello Jorgen,

        I tried to change the DIS's char. as you mentioned. And referred the example as the following web link (https://devzone.nordicsemi.com/f/nordic-q-a/41257/dis-update-serial-number).  Unfortunately, it doesn't work at all. Have anything I missed at the process what I implemented. I post the implement what I tried for your reference. Could you take a time to see for me?

    uint32_t ble_dis_update(char * serial_num)
    //uint32_t ble_dis_update(uint8_t length, uint8_t * buff)
    {
    ble_gatts_value_t gatts_value;
    uint32_t err_code = NRF_SUCCESS;
    ble_srv_utf8_str_t serial_num_str;

    ble_srv_ascii_to_utf8(&serial_num_str, serial_num);

    memset(&gatts_value, 0, sizeof(gatts_value));

    gatts_value.len = serial_num_str.length; //sizeof(uint8_t);
    gatts_value.offset = 0;
    gatts_value.p_value = serial_num_str.p_str;

    // Update database.
    err_code = sd_ble_gatts_value_set(service_handle, fw_rev_handles.value_handle, &gatts_value);

    return err_code;
    }

    ble_dis_update("1.1.0");

Reply
  • Hello Jorgen,

        I tried to change the DIS's char. as you mentioned. And referred the example as the following web link (https://devzone.nordicsemi.com/f/nordic-q-a/41257/dis-update-serial-number).  Unfortunately, it doesn't work at all. Have anything I missed at the process what I implemented. I post the implement what I tried for your reference. Could you take a time to see for me?

    uint32_t ble_dis_update(char * serial_num)
    //uint32_t ble_dis_update(uint8_t length, uint8_t * buff)
    {
    ble_gatts_value_t gatts_value;
    uint32_t err_code = NRF_SUCCESS;
    ble_srv_utf8_str_t serial_num_str;

    ble_srv_ascii_to_utf8(&serial_num_str, serial_num);

    memset(&gatts_value, 0, sizeof(gatts_value));

    gatts_value.len = serial_num_str.length; //sizeof(uint8_t);
    gatts_value.offset = 0;
    gatts_value.p_value = serial_num_str.p_str;

    // Update database.
    err_code = sd_ble_gatts_value_set(service_handle, fw_rev_handles.value_handle, &gatts_value);

    return err_code;
    }

    ble_dis_update("1.1.0");

Children
No Data
Related