NCS 3.0.1 : How to Initialize/deinitialize (BAS) service Dynamically?

Hi,

Testing Hardware: nrf52832 Module in a Custom board OR nrf52DK possbile

-> We would like to change the order of the BLE service as shown in this thread: https://devzone.nordicsemi.com/f/nordic-q-a/115493/change-the-order-of-services-in-nrf-connect-mobile

OR

->We want to turn on/off the BAS service dynamically at runtime. (A system Reboot scenario is acceptable if it's possible.)

In a static scenario, "CONFIG_BT_BAS=y" works, but how to do it in the dynamic scenario? 


Please let us know. Thanks for the support

  • Hello,

    What is the reason you want to deinitialize the BAS service? If a connected device is not interested in it, it can just ignore it. Alternatively, if you only want some specific devices to have access to it, you can limit the access by saying that you need to be paired in order to read it. You can, for example say that it needs to be paired with at least MITM level security, meaning you would need access to a 6 digit code to pair. Then only certain devices can have access to this code (e.g. the owners). 

    Best regards,

    Edvin

  • Thanks for the reply.

    Unfortunately, our use case is like this. We are unable to touch the other side and only have control over how our device responds. 

    Please let us know the above possibilities regarding the BAS in the dynamic scenario or the change of the initialisation service order. 

    Thanks

  • The initialization order doesn't matter. When a central does a service discovery, it will discover the services in numerical order of their UUID, not the order that they were initialized before you started advertising. 

    I don't think we have any samples that demonstrates how to do this, dynamically adding and removing services. All our samples uses BT_GATT_SERVICE_DEFINE() to set up their services and characteristics, but according to my colleague, it should be possible to call bt_gatt_service_register(), and possibly bt_gatt_service_unregister() to remove them.

     Changing Characteristic Handle Value NRF52840 based on Tutorial  

Related