Hello,
i asked this quastion once in this thread: https://devzone.nordicsemi.com/f/nordic-q-a/32444/reset-on_ble_connect-when-button-event
I accepted the given answer but later i found out that the solution does not work. I rejected the answer, but i am afraid that nobody can see it anymore.
This is not intended as spamming and i apologize for the duplicate. I sum up the results of thread:
My problem is reproducable with this setup:
- nRF5-DK with ble_blinky_example (central)
- nRF5-DK with ble_blinky_example (peripheral)
- Press Button1 immediately on the peripheral after connecting (LED2 lights up).
- watch how the peripheral goes back to Advertising (resets)
- Press Button1 after the Connection is established a while, everything works fine.
- SDK 12.3 and Softdevice S130 2.0.1/ Softdevice S132 3.0.0
The problem is that pressing a button on the peripheral after connection setup causes a reset. It is shown in the video attached:
- Peripheral left, central right.
- First: in connection, everything fine. (Button press is indicated with a led).
- Second: Switch off and on the peripheral (same with resetting via IF BOOT/RESET). Press Button1 directly after connecting (LED2 lights up). Board goes back to advertising/resets.
- Third: Wait after connection. Everything works fine. (Button press is indicated with a led)
If the button_event_handler() is empty, the devices stay connected. APP_ERROR_CHECK(err_code) causes the reset. NRF_LOG_INFO shows err_code = 13313 --> ERROR: fatal. If i comment the APP_ERROR_CHECK out, the connection stays (at least the led is still on). The first button presses are not detected, but the later ones.
In my application, i want to show that the device is in a connection so that the customer can start interacting. Therefore, i want to be sure that there is a valid connection when a led lights up.
Tried Solutions:
I tried to check if there is a valid connection-handle but that does not help. I dont know how to check for the other err_codes (13313).
I used a timer to delay the indication of the connection state. But that is kind of sloppy.
In on_ble_evt() a timer is started:
And in the timer_handler, the state is indicated and the app_button module enabled:
Thank you very much in advance and kind regards
DanKa