Hi,
I would like to update the Device Information Service's (DIS) serial number characteristic to reflect the actual serial number assigned by our production equipment. I understand that ble_dis.c (as supplied by Nordic) cannot do this.
Now I wonder how this is done best and surely other people wanted to do the same.
What I have done so far:
- Added function
ble_dis_update_serial
(see below) - The function actually does something (!) but the serial number string shown in nRF Connect is not correct. To be more specific: it is too long or too short
- I have modified
attr_char_value.init_len
(to the actual string length) andattr_char_value.max_len
(to 16) as suggested in several posts. Unfortunately this does not help.
Please advise how I can modify DIS "serial number" to accept variable length serial number strings.
Thank you
Matthias
My function to update the Serial Number characteristic:
void ble_dis_update_serial (uint16_t conn_handle, ble_srv_utf8_str_t serial_num_str)
{
uint32_t err_code;
ble_gatts_value_t gatts_value;
memset (&gatts_value, 0, sizeof (gatts_value));
gatts_value.len = serial_num_str.length;
gatts_value.offset = 0;
gatts_value.p_value = serial_num_str.p_str;
// Update database.
err_code = sd_ble_gatts_value_set (conn_handle, serial_num_handles.value_handle, &gatts_value);
}