nRF52840, Connection fail

Hi,
my device is central device( Central UART ) and I couldn't get stable pairing with peripheral device with display which provides passkey code. 

The scenario: 
1. From the start, I get a successful pairing (34931_pairing_OK_212.txt 34931_pairing_OK_212.txt).8168.34931_pairing_OK_212.txt

2. If I reboot my device and try to reconnect, I get a 
pairing error (34931_pairing_fail2_212.txt)

[00:01:43.048,736] <inf> UartTerminal: Uart frame
                                       7e 0a 00 01 03 00 06 73  58 53 4f ee 34 ed 7c 7e |~......s XSO.4.|~
[00:01:43.100,555] <inf> ble: Provisioning mac
                              34 ee 4f 53 58 73                                |4.OSXs           
[00:01:43.100,585] <inf> App: Callback result, true
[00:01:43.313,690] <inf> ble: [DEVICE]: 73:58:53:4F:EE:34 (random), AD evt type 0, AD data len 28, RSSI -57

[00:01:43.314,300] <inf> ble: [DEVICE]: 73:58:53:4F:EE:34 (random), AD evt type 4, AD data len 6, RSSI -57

[00:01:43.455,230] <inf> UartTerminal: Uart frame
                                       7e 0d 00 01 04 00 08 34  ee 4f 53 58 73 05 01 05 |~......4 .OSXs...
                                       52 77 7e                                         |Rw~              
[00:01:43.504,791] <inf> ble: Process command to 'Start process', mac: 7358534fee34, type: eSurgeGuard

[00:01:43.504,852] <inf> App: Callback result, true
[00:01:43.567,718] <inf> ble: Attempt connection
[00:01:43.568,054] <inf> bt_conn: 
[00:01:43.568,145] <inf> bt_conn: disconnected -> connecting
[00:01:43.568,145] <inf> bt_conn: handle 0 ref 1 -> 2
[00:01:43.568,389] <inf> bt_conn: 
[00:01:43.568,878] <inf> bt_conn: 
[00:01:43.568,908] <inf> bt_conn: handle 0 ref 2 -> 3
[00:01:43.569,000] <inf> ble: Create process for mac: 7358534fee34
[00:01:43.569,030] <inf> bt_conn: handle 0 ref 3 -> 4
[00:01:43.569,122] <inf> registry: OnPaired set flag, false
[00:01:43.569,152] <inf> ble: Process was created
[00:01:43.569,183] <inf> bt_conn: handle 0 ref 4 -> 5
[00:01:43.569,366] <inf> ble: [DEVICE]: 73:58:53:4F:EE:34 (random), AD evt type 0, AD data len 28, RSSI -54

[00:01:43.569,458] <inf> bt_conn: handle 0 ref 5 -> 6
[00:01:43.569,458] <inf> bt_conn: handle 0 ref 6 -> 5
[00:01:44.080,963] <inf> bt_conn: conn handle 0 buf len 11 cb (nil) user_data (nil)
--- 15 messages dropped ---
Security level is setted

[00:01:44.081,146] <inf> bt_conn: handle 0 ref 6 -> 7
[00:01:44.081,207] <inf> ble: Connected: 7358534fee34

[00:01:44.081,329] <inf> bt_conn: conn 0x20002ba8
[00:01:44.081,359] <inf> bt_conn: conn 0x20002ba8 buf 0x20012028 len 11
[00:01:44.081,359] <inf> bt_conn: conn 0x20002ba8 buf 0x20012028 len 11 flags 0x02
[00:01:44.081,787] <inf> bt_conn: handle 0 ref 7 -> 8
[00:01:44.081,817] <inf> bt_conn: handle 0 ref 8 -> 7
[00:01:44.082,000] <inf> bt_conn: 
[00:01:44.082,000] <inf> bt_conn: Adding conn 0x20002ba8 to poll list
[00:01:44.082,305] <inf> bt_conn: 
[00:01:44.082,305] li<inf> bt_conn: Adding conn 0x20002ba8 to poll list
[00:01:44.082,672] <inf> bt_conn: 
[00:01:44.082,702] <inf> bt_conn: Adding conn 0x20002ba8 to poll list
[00:01:44.082,977] <inf> bt_conn: 
[00:01:44.083,007] <inf> bt_conn: Adding conn 0x20002ba8 to poll list
[00:01:44.083,038] <inf> bt_conn: handle 0 ref 7 -> 6
[00:01:44.083,099] <inf> bt_conn: handle 0 ref 6 -> 7
[00:01:44.083,099] <inf> bt_conn: conn 0x20002ba8
[00:01:44.083,129] <inf> bt_conn: tx 0x200040d8 cb 0x52261 user_data 0x200042e4
[00:01:44.083,160] <inf> bt_conn: handle 0 len 6 flags 02
[00:01:44.083,190] <inf> bt_conn: First, len 6 final 2
[00:01:44.083,190] <inf> bt_conn: Successfully parsed 6 byte L2CAP packet
[00:01:44.083,221] <inf> bt_smp: Received SMP code 0x0b len 1
[00:01:44.083,221] <inf> bt_smp: 
[00:01:44.083,251] <inf> bt_conn: handle 0 ref 7 -> 6
[00:01:44.083,312] <inf> bt_conn: conn 0x20002ba8
[00:01:44.083,312] <inf> bt_conn: conn 0x20002ba8
[00:01:44.108,001] <inf> registry: OnConnected set flag
[00:01:44.108,032] <inf> bt_conn: handle 0 ref 6 -> 5
[00:01:44.141,815] <inf> bt_conn: handle 0 ref 5 -> 6
[00:01:44.141,845] <inf> bt_conn: handle 0 ref 6 -> 5
[00:01:44.201,965] <inf> bt_conn: handle 0 ref 5 -> 6
[00:01:44.201,965] <inf> ble: le_data_len_updated
[00:01:44.201,965] <inf> bt_conn: handle 0 ref 6 -> 5
[00:01:44.202,026] <inf> bt_conn: handle 0 ref 5 -> 6
[00:01:44.202,056] <inf> bt_conn: conn 0x20002ba8
[00:01:44.202,056] <inf> bt_conn: handle 0 len 7 flags 02
[00:01:44.202,056] <inf> bt_conn: First, len 7 final 3
[00:01:44.202,087] <inf> bt_conn: Successfully parsed 7 byte L2CAP packet
MTU exchange successful

Current MTU: 64

[00:01:44.202,178] <inf> bt_conn: handle 0 ref 6 -> 5
[00:01:44.321,411] <inf> bt_conn: handle 0 ref 5 -> 6
[00:01:44.321,441] <inf> bt_conn: connected -> disconnect-complete
[00:01:44.321,441] <inf> bt_conn: handle 0 ref 6 -> 5
[00:01:44.321,655] <inf> bt_conn: handle 0 ref 5 -> 6
[00:01:44.321,655] <inf> bt_conn: disconnect-complete -> disconnected
[00:01:44.321,685] <inf> bt_conn: conn 0x20002ba8
[00:01:44.321,685] <inf> bt_conn: handle 0 ref 6 -> 5
[00:01:44.321,746] <inf> bt_conn: 
[00:01:44.321,807] <inf> bt_conn: conn 0x20002ba8
[00:01:44.321,807] <inf> bt_smp: chan 0x20002fc4 cid 0x0006
[00:01:44.321,838] <inf> bt_smp: status 0x8
[00:01:44.321,868] <inf> bt_smp: chan 0x20002fc4 conn 0x20002ba8 handle 0 encrypt 0x00 hci status 0x1f
Security is failed: 73:58:53:4F:EE:34 (random) level 1 err 9

[00:01:44.322,052] <inf> ble: Pairing is failed, reason code: (9). Disconnecting.
[00:01:44.322,052] <inf> bt_conn: handle 0 ref 5 -> 6
[00:01:44.322,082] <inf> bt_conn: handle 0 ref 6 -> 5
[00:01:44.322,174] <inf> ble: Disconnected: 7358534fee34 (reason 0x05)

[00:01:44.322,204] <inf> bt_conn: handle 0 ref 5 -> 6
[00:01:44.322,204] <inf> bt_conn: handle 0 ref 6 -> 5
[00:01:44.322,235] <inf> bt_conn: handle 0 ref 5 -> 4
[00:01:44.408,416] <inf> App: Push to output queue, size: 11
[00:01:44.408,569] <inf> ble: Process is finished,  addr: 7358534fee34, result: failed

[00:01:44.408,599] <inf> bt_conn: handle 0 ref 4 -> 3
[00:01:44.408,630] <inf> ble: Process is removed
[00:01:44.408,660] <inf> bt_conn: handle 0 ref 3 -> 2
[00:01:44.408,691] <inf> bt_conn: handle 0 ref 2 -> 1


So, I get event 'BT_HCI_EVT_DISCONN_COMPLETE' for some reason. 
I get the handler there from the function 'bt_recv' (hci_core.c). 
And I couldn't understand the reason. Could you please help with that issue?

Related