以修改产品序列号为例:基于16.0.0版本的SDK:
1. 将ble_dis_service.c内的Serial number句柄暴露出来:
ble_gatts_char_handles_t* Ble_Dis_Get_Serial_Num_Handles(void)
{
return (ble_gatts_char_handles_t*)&serial_num_handles;
}
2. 在外部进行修改:
void Ble_Dis_Service_Set_SerialNumber(unsigned char *pStr)
{
ble_gatts_char_handles_t *pHandles;
ble_gatts_value_t gatts_value;
ble_srv_utf8_str_t serial_num_str;
ble_srv_ascii_to_utf8(&serial_num_str, pStr);
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;
pHandles = Ble_Dis_Get_Serial_Num_Handles();
sd_ble_gatts_value_set(m_conn_handle, pHandles->value_handle, &gatts_value);
}
测试下来,是可以更新的。由于接触Nordic的芯片不久,暂时不知道是不是稳定或则方法有没错误。。