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

nrf52 central_blueart_multi: condition for BLE device connected but no data received

I'm using a central (Adafruit Bluefruit Feather nrf52) and peripheral (Adafruit Bluefruit 32u4) device for BLE communication.
Peripheral is acting as remote, to turn on relays (wired to central).
Peripheral has 8 buttons, each button press sends out a different string from peripheral to central. eg: When I send "1" from peripheral, relay 1 turns on. Similarly I send "2", "3"..."8" for 8 relays.

I want my switches on the remote to act as momentary switches (that is, relays should be ON as long as button is pressed). So I want my relays to turn off when no data is received. Right now, all of my code logic is written inside the function bleuart_rx_callback(BLEClientUart& uart_svc), refer example code central_bleuart_multi (github.com/.../central_bleuart_multi.ino)
This function is activated only when UART data is received.

To solve this problem, I'm sending default "0" from peripheral if no button is pressed. On central side, receiving "0" turns all relays off. This works with a single remote, but I want to have 3 such remotes (peripherals) connected to central for my applications.

The solution has to be a way to write "shut down all relays if no data is being received" in the code.
Has anyone faced this problem? Any possible solutions? Thanks in advance!

Related