I applied Bonding to the UART example(ble_app_uart).
Bonding combined with the UART example works well, but there is one problem.
1. I did Bonding first.
2. After that I set Notification Enable.
3. Rebooted the device and reconnected to the application using Auto connect.
4. On the NRF Connect, it is marked as Notification Enable, but the device did not send the notification.
I checked the code point where the problem was occurring.
I found that is_notification_enabled is still false after auto-connect.
uint32_t ble_nus_string_send(ble_nus_t * p_nus, uint8_t * p_string, uint16_t length)
{
ble_gatts_hvx_params_t hvx_params;
VERIFY_PARAM_NOT_NULL(p_nus);
if ((p_nus->conn_handle == BLE_CONN_HANDLE_INVALID) || (!p_nus->is_notification_enabled))
{
return NRF_ERROR_INVALID_STATE;
}
if (length > BLE_NUS_MAX_DATA_LEN)
{
return NRF_ERROR_INVALID_PARAM;
}
memset(&hvx_params, 0, sizeof(hvx_params));
hvx_params.handle = p_nus->rx_handles.value_handle;
hvx_params.p_data = p_string;
hvx_params.p_len = &length;
hvx_params.type = BLE_GATT_HVX_NOTIFICATION;
return sd_ble_gatts_hvx(p_nus->conn_handle, &hvx_params);
}
I tried to ignore this part of the conditional statement, but then the device didn't work properly.
If possible, please help resolve the problem.