Error 13313 [Unknown error code] BLE cannot re-connect after disconnection

Hi, I'm using nRF52805. 

My BLE code could connect & communicate data perfectly for the first time. After the disconnection, I can still see the signal. However, when I try to reconnect it, the following error pops up. And I can never see the BLE signal again. I think the entire code stops running. 

// In the debugging mode: 

<info> app: BLE_GAP_EVT_CONNECTED
<error> app: ERROR 13313 [Unknown error code] at D:\StevenW\SDK_Code\example\Steven\20210922 eBTR_BLE_BPM_TV Btn v1\main.c:2075
PC at: 0x0001E849
<error> app: End of error report

This are my codes at line 2075

ret_code_t err_code_ble_nus;
err_code_ble_nus = ble_nus_data_send(&m_nus, nus_string, &bytes_to_send, m_conn_handle);
if ((err_code_ble_nus != NRF_ERROR_INVALID_STATE) && (err_code_ble_nus != NRF_ERROR_NOT_FOUND))
{
APP_ERROR_CHECK(err_code_ble_nus); // Line 2075
}


After Googleing, many people mentioned the same reason & solution (see link 1, link 2, link 3), and their solution is to add the following codes: 

case BLE_GATTS_EVT_SYS_ATTR_MISSING:
    err_code = sd_ble_gatts_sys_attr_set(m_conn_handle, NULL, 0);
    APP_ERROR_CHECK(err_code);
    break;

However, this solution doesn't work for me. Any other ideas, please?

Thanks in advance! 

Related