This post is older than 2 years and might not be relevant anymore
More Info: Consider searching for newer posts

look for sample code for reconnect to bonded devices and share the encryption keys.

Hi, I am looking for sample code that can reconnect to bonded devices and share the encryption keys with DFU-OTA. 

I have worked using DFU-OTA (JUST_WORKS option); I question is:

1. My device does not have a keyboard to inter passkey; is there any other way that I can do?

2. After I connect and bounded the device; how do I share the encryption key to DFU; and restart without rebound this device?

I am using nRF52840-DK; Windows 10; Embedded Studio SD: s140_nrf52_6.0.0_softdevice SDK 15.0.0

Please help.

Donald

  • Hi Donald,

    our Secure Bootloader supports bond sharing, i.e. the application will share the bonding information about the peer that initiated DFU through the DFU service that the application has in its GATT table. So there is no need to share any encryption keys, this is handled automatically by the application and bootloader if you have configured them to support bond sharing, i.e. 

    Set NRF_DFU_BLE_BUTTONLESS_SUPPORTS_BONDS to 1 in the applicaiton's sdk_config.h file.

    Set NRF_DFU_BLE_REQUIRES_BONDS to 1 in the bootloader's sdk_config.h file.

    The DFU process itself uses a private-public key pair for ECDSA validation. First, you as the developer will generate a private key that you keep secret, then you generate a public key from the private key. The public key is compiled into the bootloader and the private key is used to sign a hash of the firmware image intended for the device. Using the public key it is possible to verify if the hash was signed by the private key it self was derived from. 

    The private key can not be derived from the public key, so there is no harm in the public key being known. 

    Best regards

    Bjørn

  • Hi Bjørn, 

    Before I try what you told below, I have one question for you:

    I tried to test C:\Nordic_Semi\Gen4_BLE0106\examples\ble_peripheral\ble_app_gls

    using nRF Connect v3.3.0

    1. Buit project and downloaed to nRF52840 -DK

    2. Using nRF Connect to connect the device

    3. Pair and bonded the device

    4. Disconnected the device

    5. It can NOT connect the device again.

    6. Power cycled device; I can see the device; but got error to connect with it.

    I am using SDK 15.0.0; nRF52840 -DK; I can't reply you answer below.

    Please see my screenshots attached with this reply.

  • Hi Donald, 

    Apologies for the late reply.

    You need to set the Security Parameters for nRF Connect to support Bonding. Click the gear wheel and select Security Parameters

    Then tick off Perform Bonding and click Apply.

    Then connect to the Nordic Glucose app and enter the passkey and you should see the devices bonding. You should also be able to disconnect and reconnect without re-entering the passkey. 

    Best regards

    Bjørn

  • Hi, Bjorn:

    Thanks for your response.

    I tried a couple; but got different response with you:

    1. Set the Security Parameters for nRF Connect to support Bonding:

    2. Tried to connect Glucose; got error:

    3. No Pop-up window to entry passkey; no message in Putty window.

    Question: Which SDK do you use? I am using SDK 15.0.0?

    Donald

  • More information for you:

    If I do not set Security parameter to bond; then I can connect device with pop-up window like below:

Related