Hi,
I'm using nrf52840 with softdevice s140_nrf52_7.2.0 and I'm adding new characteristics to the ble_nus service. I've added the new handles for the new characteristics as follows:
ble_nus.h
struct ble_nus_s
{
uint8_t uuid_type;
uint16_t service_handle;
ble_gatts_char_handles_t rx_handles;
ble_gatts_char_handles_t tx_handles;
ble_nus_data_handler_t data_handler;
ble_gatts_char_handles_t datetime_handles;
ble_gatts_char_handles_t dataflash_handles;
ble_gatts_char_handles_t username_handles;
ble_gatts_char_handles_t autorecoding_handles;
blcm_link_ctx_storage_t * const p_link_ctx_storage;
};
I have initialized the new characteristics in the "ble_nus_init" function. The code seems to be working and I was able to see the new characteristics populated in nrfConnect App when I connect to the device. However, the problem is I could not write the value of one of the characteristics when I write the value from the App. After debugging this I found the following:
1. when the firmware starts and calls ble_nus_init, I checked the handle value assigned at the end of the function for the new characteristics

2. When the connection is established, I checked these values again and I found that the handle value gets changed for the characteristic that has the issue (autorecording_handles):

This is changed from 0x0030 to 0x2565
3. When I try to write the value of the autorecording_handles from the App, I checked on_write function and I saw that the input "p_evt_write->handle" has the original value in step 1 (i.e. 0x0030). However, because the characteristic handle value inside the firmware got changed after connection, then the condition to update the characteristic value inside the on_write function does not get triggered.
So I'm not sure why the characteristic handle value gets changed after connection in the first place!