Beware that this post is related to an SDK in maintenance mode
More Info: Consider nRF Connect SDK for new designs

Alternating between Central + Peripheral and Peripheral + Peripheral in a memory constrained environment

I have an existing application that leverages a permanent Central and Peripheral role on the same device to communicate with other devices.

The application is quite memory constrained (I've been optimizing for dozens of bytes here and there for a little while), and I'm wondering if it's possible to configure the s332 soft device as 2 peripheral links (P1 + P2) until commanded to switch, disable P2 and replace it with a Central (P1 + C).

Ideally I would like to keep P1 active the entire time (possibly in a connection when switching P2 for C).

I know I can do something like this by allocating P1, P2, and C (i.e. NRF_SDH_BLE_PERIPHERAL_LINK_COUNT = 2, NRF_SDH_BLE_CENTRAL_LINK_COUNT = 1, and NRF_SDH_BLE_TOTAL_LINK_COUNT = 3), but is it possible to reuse the memory between P2 and C due to my constrained environment?

I'm working on a version of the nRF52 SDK, not the nRF Connect SDK.

Parents Reply Children
  • As the device has the control in exposing what capability it has, you can simply implement some logic to let it advertise and not scan when it is to serve as P2, or let it scan and not advertise when it is to serve as C.

    You can also reconfigure the SoftDevice with sd_ble_cfg_set(). However, because you are using so few connections, that isn't required. It also doesn't bring any benefit in your use case. Furthermore, its usage is wrapped in the SoftDevice handler library, so you need to understand how it is used there and make sure there is no conflicts. Overall, just very little benefit, so I don't recommend this approach.

Related