This discussion has been locked.
You can no longer post new replies to this discussion. If you have a question you can start a new discussion

BLE automatic connection to other BLE device

Hello

I'm using multiple nRF52840-dk (SDK17.1.0, Windows, Segger, S140).  

I'm trying to make BLE device(nRF52840-dk) that automatically connects to specific BLE device(nRF52840-dk) whenever it turns on without connecting to other devices.

Is there any great example/tutorial for this case?

After some search, in ble_app_hrs example I discovered that peer_manager_init() provides pairing and bonding, but I don't know how to utilize it. Can you tell me how to use it?

PS, Does pairing/bonding save anything else beside encryption key? Where/ which variable is the key saved at?

PSS I did found filter, but the central device will connect to any other peripheral

  • Thanks, I managed to build successfully built hrs example on nRF52833-DK. (Just in case for other readers, RAM_START is a little different, error message will tell you where it starts)

    Problem is that I got stuck at peer_manager_init>pm_init>sm_init> nrf_ble_lesc_init>memset((void *) m_peer_keys, 0, sizeof(m_peer_keys));. (error does not display, I end up in HardFault_Handler.).

    One of our coworker managed to make it run, but eventually get into error during ble connection.(sorry for lack of error message, will try his code later)

    My question is: is LESC necessary for bonding?

    I came across cryptp CC310 in sdk_config.h and it says this crypto is only supported in nRF52840. Is CC310 necessary for LESC or bonding?

    Is PM_LESC_ENABLED and NRF_BLE_LESC_ENABLED related?

    Thanks

  • Hello,

    Yes. The RAM start and size depends on your BLE setup (number of services/characteristics, number of connections, MTU size, etc.) so you may need to change this in the future as well. Just monitor the log to see what it should be set to. 

    June20 said:
    My question is: is LESC necessary for bonding?

    No. You can use e.g. Just works.If you like. 

    June20 said:
    I came across cryptp CC310 in sdk_config.h and it says this crypto is only supported in nRF52840. Is CC310 necessary for LESC or bonding?

    No, you should disable it in sdk_config if you are using the nRF52833. You can use NRF_CRYPTO_BACKEND_MICRO_ECC_ENABLED instead of NRF_CRYPTO_BACKEND_CC310_ENABLED.

    June20 said:
    Is PM_LESC_ENABLED and NRF_BLE_LESC_ENABLED related?

    I believe that NRF_BLE_LESC_ENABLED needs to be set if you want to set PM_LESC_ENABLED. I haven't tested. Try to search for PM_LESC_ENABLED and NRF_BLE_LESC_ENABLED in the unmodified pca10056 example to see where it is used.

    Best regards,

    Edvin

  • Hello! Sorry for taking so long, I finally ported HRS into nRF52833 and successfully connected with HRS_C.

    We're trying to use bonding so that only one central(nRF52840 DK) and one peripheral(nRF52833 DK) connects to each other. 

    For example: we have many centrals (nRF52840 DK) and many peripherals (nRF5833 DK). Once Central_1 and Peripheral_1 is bonded, Central_1 cannot connect with Peripheral_2 or Central_2 cannot connect with Peripheral_1.

    What configuration should I touch/modify?

    I came across Central_Link_Count and Peripheral_Link_Count in sdk_config.h. Do they just mean how many central/peripheral they can connect/store or are there more? Should I put 1 each for both central and peripheral?

    Thanks

  • June20 said:
    I came across Central_Link_Count and Peripheral_Link_Count in sdk_config.h

    No, they refer to how many simultaneous connections youn can maintain (be connected to at once). It has nothing to do with bonding.

    I remembered wrong. It is the peripheral (ble_app_hrs) example that requests the bonding in these two examples. But it should be perfectly fine to do so from the central as well. Just call pm_conn_secure() from the BLE_GAP_EVT_CONNECTED event in main.c.

    These examples show you how they will add the bonded device to their whitelist, so that the next time they advertise/scan, then they will only accept connections to eachother, unless you temporary disables the whitelist, or deletes the bonding information.

    Best regards,

    Edvin

  • Thanks for the info.

    Sorry for asking the same question again, what I really wanted ask was how to make device have only one bonding (or have 1 whitelist) so that it will reject other connection attempt.

    What should I modify for central(nRF52840 DK) so that it will accept only one peripheral(nRF52833 DK)?

    Also to peripheral(nRF52833 DK) so that it will reject other centrals(nRF52840 DK) after bonding?

    Will  setting one whitelist do the trick? And how?

Related