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 Reply
  • If you get L6218E errors, you either have not included the correct source file, or have not enabled the module in the SDK configuation header file. I looked through you code and see that you are calling nus_c_init() before ble_stack_init(). nus_c_init() contains calls to softdevice functions, so calling this before enabling the softdevice/bluetooth stack will lead to an error. I'm not sure if you have enabled the NRF_LOG module in the SDK configuration header, but if you have, you should not call uart_init(). This will lead to the hardware UART interface being initialized two times. I recommend to use the NRF_LOG module. I attached a working Keil project containing your code and my fixes: ble_app_hrs_nus.zip

Children
No Data
Related