Bluetooth pairing fails when running sample peripheral_cts_client

I am trying to run the sample using NCS v2.5.0. This is what happens on the console when I try to connect from the dongle, when running the Test Procedure:

The discovery procedure succeeded
Security failed: E3:FE:4E:E0:6D:C5 (random) level 1 err 4
Pairing failed conn: E3:FE:4E:E0:6D:C5 (random), reason 4
Disconnected from E3:FE:4E:E0:6D:C5 (random) (reason 0x16)

Please advise. I don't have much BLE experience. Thank you.

Burt Silverman

  • It seemed to connect once after a "west flash --erase" rather than a "west flash". But it only paired once and then failed. And I never saw any time data, and it only paired once so it's impossible to experiment and see what is going on. I know nothing much about Bluetooth other than I have used devices that pair, and as a user I would have no access to reflashing let alone with a --erase, and it's not like I have to discard the device after one usage. So, what the heck is going on here???

  • Pairing failed because the dongle still had old bonding keys after you erased and re-flashed the board. Delete the bond on the dongle as well, then pairs again. The CTS example is a client and it only prints time when it connects to a device that provides CTS service, such as a phone or some other device that is broadcasting CTS service.

    Did you make sure that you have Settings enabled in your prj.conf for persistence key storage?

    CONFIG_BT_SETTINGS=y
    CONFIG_SETTINGS=y

  • Thank you, Susheel. I do have the Settings as you described in prj.conf. How do I delete the bond on the dongle?

    About Step 7 in the test instructions, it says to Perform Bonding. It appears that one should never try that more than once, or he will need to "west flash --erase" the kit (or custom equivalent). Do you think that this is why I have had such difficulty? The instructions do not give any warning. Or is something else going on? Thanks.

    Burt

    ps

    Connected E3:FE:4E:E0:6D:C5 (random)
    The discovery procedure succeeded
    Pairing completed: E3:FE:4E:E0:6D:C5 (random), bonded: 0
    Security changed: E3:FE:4E:E0:6D:C5 (random) level 2

    Is this good or bad--I don't know about bonded: 0 -- that looks bad to me.

  • Oh, oops, I guess settings are set in flash, and we have flash but it's undoubtedly connected to different SPI pins and I did not fix up the dts file for that prior to testing. I didn't realize how complex this "simple" sample was.

    Just for curiosity, is there a way to do a sample CTS like this but without the security aspect?

  • Ah, interesting. Glad that you figured the dts porting need to make this work.

    Burt said:
    Just for curiosity, is there a way to do a sample CTS like this but without the security aspect?

    You can definitely disable the security aspect of the CTS by doing CONFIG_BT_SMP=n but then you wont be able to test it with phones and PC that required an encrypted link from the peer to share its CTS data. You could design another Central with CTS server that does not need encrypted link to connect and share its CTS data. But phones and PCs by default seems to need an encrypted link.

Related