I am using SoftDevice s140v6.1.1. The behavior is I was able to program nRF52840 through JTAG without any issue. I am checking out the OTA firmware update feature and nRFConnect got this "Failed to authenticate (NRF_ERROR_INVALID_STATE)" error after I programmed the BLE app and connect from nRFConnect to nRF52840. I am trying to log and break where NRF_ERROR_INVALID_STATE returned unsuccessfully.
I am using NRF_LOG_DEBUG("*** NRF_ERROR_INVALID_STATE %s:", __func__);
After I did OTA of BLE app, I use Segger Embedded Studio (SES) to attach debugger. I used SES "Debug Terminal" and Segger RTT client to capture the trace.
Please take a look at the below trace and let me know if you can point me to a specific area of BLE app to diagnose.
Debug Terminal:
<info> peer_manager_handler: Connection secured: role: Peripheral, conn_handle: 0, procedure: Encryption
<info> app: prvAppPMEvtHandler() -> PM_EVT_CONN_SEC_SUCCEEDED
<info> app: prvAppPMEvtHandler() -> Already bonded? 1
<debug> app: BLE_GAP_EVT_AUTH_STATUS: Peer to Erase: 0
<debug> nrf_ble_gatt: Data length updated to 251 on connection 0x0.
<debug> nrf_ble_gatt: max_rx_octets: 251
<debug> nrf_ble_gatt: max_tx_octets: 251
<debug> nrf_ble_gatt: max_rx_time: 2120
<debug> nrf_ble_gatt: max_tx_time: 2120
<debug> app: GATT data length on connection 0x0 changed to 251.
<debug> app: prvOnConnParamsEvt() -> BLE_CONN_PARAMS_EVT_SUCCEEDED
<debug> app: prvDeferredSecReqTimeoutHandler - encrypted: true
Segger J-Link RTT Client:
SEGGER J-Link V6.34g - Real time terminal output
SEGGER J-Link Ultra V4.0, SN=504300423
Process: emStudio.exe
<info> pwr_mgmt: Init
<debug> app: xBslDrvInit() - ENTER
<info> BSL_drv: xBslDrvInit():20017100
<debug> app: xBslDrvInit() - EXIT - 0x0
<info> ctrlproc_drv: xCtrlProcInit: 2002A6DC
<info> comm_rtr: xCommProcInit():2000E520
<info> file_mgr: xFileSystemMgrInit: 20016640
<info> disp_dia: xCmdDiagInit: 2000EE2C
<info> app: vRsetComm - Reset reason:0000000c
<info> neuro_dev: vRsetComm: 20025490
<info> neuro_dev: xNeuroDeviceInit: 200253E4
<info> app: xMagnetInit: 2002DCB4
ertificate State: One or
<debug> nrf_ble_gatt: Requesting to update ATT MTU to 247 bytes on connection 0x0.
<debug> nrf_ble_gatt: Updating data length to 251 on connection 0x0.
<warning> app: xBleNMSBeaconCharUpdate() - Early EXIT: xErrCode {0x0010}
<info> app: prvAppBleEvtHandler() -> Connected
<debug> app: conn_handle: 0x0
<info> app: vSessionManagerAuthCompleteSuccess()[CERT] AUTHENTICATION COMPLETED SUCCESSF
<debug> app: xNrmConn(): Conn'd BndAlw.Pndg[0.0] State[2] RetVal[1]
[1]
g> app: xNrmConn(): Conn'd BndAlw.Pndg[0.0] State[2] RetVal[1]
<debug> nrf_ble_gatt: ATT MTU updated to 247 bytes on connection 0x0 (response).
<debug> app: GATT ATT MTU on connection 0x0 changed to 247.
<debug> app: prvAppBleEvtHandler() -> BLE_GATTC_EVT_EXCHANGE_MTU_RSP
<debug> app: ---> server_rx_mtu: 247
Thanks,
Dennis