Hi Daniel,

On Mon, Jan 13, 2020 at 10:09 PM Daniel Mastain <dmast...@calamp.com> wrote:

> Hello,
>
> I'm experiencing an issue when using the btshell app on a linux machine.
> I'm attempting to pair two devices both running nimBLE in a just works
> scenario where both initiator and responder are set to have bonding
> disabled but the desc.sec_state.bonded values are being set to 1 on both
> devices. My set up is as follows.
>
> Device
> Initiator
> Resonder
> io_cap
> 4
> 0
> mitim_flag
> 0
> 0
> bonding_flag
> 0
> 0
> sc_flag
> 0
> 0
> oob_flag
> 0
> 0
>
> btshell log:
>
> 223873 btshell> connect peer_addr=01:02:03:04:05:06
> 225189 [ts=2251890000us, mod=4 level=1] GAP procedure initiated: connect;
> peer_addr_type=0 peer_addr=
> 01:02:03:04:05:06 scan_itvl=16 scan_window=16 itvl_min=24 itvl_max=40
> latency=0 supervision_timeout=2
> 56 min_ce_len=16 max_ce_len=768 own_addr_ty
> 225200 btshell> connection established; status=0 handle=72
> our_ota_addr_type=0 our_ota_addr=00:1a:7d:
> da:71:08 our_id_addr_type=0 our_id_addr=00:1a:7d:da:71:08
> peer_ota_addr_type=0 peer_ota_addr=01:02:03
> :04:05:06 peer_id_addr_type=0 peer_id_addr=01:02:03:04:05:06 conn_itvl=40
> conn_latency=0 supervision_
> timeout=256 key_size=0 encrypted=0 authenticated=0 bonded=0
>
> 225445 btshell>
> 225462 btshell> security-set-data mitm_flag=0 our_key_dist=0
> their_key_dist=0 bonding=0 sc=0 oob_flag
> =0 io_capabilities=4
> 226883 btshell>
> 227016 btshell> security-pair conn=72
> 228082 btshell> encryption change event; status=0 handle=72
> our_ota_addr_type=0 our_ota_addr=00:1a:7d
> :da:71:08 our_id_addr_type=0 our_id_addr=00:1a:7d:da:71:08
> peer_ota_addr_type=0 peer_ota_addr=01:02:0
> 3:04:05:06 peer_id_addr_type=0 peer_id_addr=01:02:03:04:05:06 conn_itvl=40
> conn_latency=0 supervision
> _timeout=256 key_size=16 encrypted=1 authenticated=0 bonded=1
>
> 229827 btshell> keystore-show type=msec
> 231814 btshell>
>
> Wireshark SMP exchange verification:
>
>
> My observations indicate the while the device is performing as expected it
> is reporting incorrect values. I'm not experienced enough with this stack
> to know where the change needs to be implemented to correct this issue but
> the root cause looks like it may be in the function
> ble_sm_key_exh_success() when called by ble_sm_key_exch_exec() wherein the
> bonded value is hard coded to be written to 1. Let me know your thoughts.
>
>
Seems like you're right, we should not force bonding=1 in
ble_sm_key_exch_success() but use calculated value (we do this when pairing
is started). I think this is the proper way to update conn state:
https://github.com/apache/mynewt-nimble/pull/730. Could you please try it
and see if it fixes your issue? Before merging we'll need to run this
through qualification test cases to verify that it does not break something
else anyway.

Best,
Andrzej

Reply via email to