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

How to change from BLE central to peripheral mode by buttons

Hi, I was wondering how to change from central mode of the NRF52 board to peripheral mode and from peripheral mode to central mode by pressing the input buttons on the board. For example, button 1 would enable the central mode which is when the NRF52 board is acting as the client and wants to send data and then button 2 would enable the peripheral mode when the NRF52 board is advertising to be connected to another BLE device, but then disable the central mode which is button 1.

Are there any examples related to this? Any help would be appreciated.

Parents
  • If you are not planning to connect any devices that is running the heart rate service, it would just be waste of space and resources to have code that handles this on the device, but if you are planning to connect such devices in the future, this should be OK. You can call uart_init(), just not if you have NRF_LOG with UART backend enabled. If you disable the logging module (set NRF_LOG_ENABLED 0 in sdk_config.h) and adds #define RETARGET_ENABLED 1 in the same file, you can call uart_init() and use printf() in place of NRF_LOG_INFO() for UART logging.

Reply
  • If you are not planning to connect any devices that is running the heart rate service, it would just be waste of space and resources to have code that handles this on the device, but if you are planning to connect such devices in the future, this should be OK. You can call uart_init(), just not if you have NRF_LOG with UART backend enabled. If you disable the logging module (set NRF_LOG_ENABLED 0 in sdk_config.h) and adds #define RETARGET_ENABLED 1 in the same file, you can call uart_init() and use printf() in place of NRF_LOG_INFO() for UART logging.

Children
Related