Wake on button press, connect with master and transmit button state

Development Software: Segger Embedded Studio, nRF5_SDK_17.0.2_d674dde

Project consists of an nRF52DK-based peripheral (remote control) and a custom nRF52832-based central (carries out the desired operations). These units are separated by a few meters.

Primary Objective: The time from a button press at the peripheral until the operation is initiated at the central must be minimal; Less than 200msec. Max battery power conservation.

Peripheral Objective: Always in deep sleep until the user presses a button. When the user presses a button the device wakes up, advertises and connects to the central.  One byte of data is then transmitted for the button press followed by a 2nd byte of data when the button is released. Finally, disconnect and return to deep sleep.

Central Objective: Scans, connects, receives the button press and release commands and performs the user-specified actions.

For a short connection time I set the following: Scan interval of 20ms. Scan window of 12.5ms. Advertisement interval of 20ms

Not using pairing or bonding

What works so far:

1. Peripheral goes to deep sleep

2. Peripheral wakes up on button press, advertises and connects to the central unit

3. Central only receives the button release byte (if the button is released greater than 1.0 sec after its pressed)

What doesn't work:

1. Central doesn't receive the button press byte

2. Central doesn't receive the button release byte if the user releases it less than 1.0 sec after it's pressed

My observations / thoughts:

Central doesn't receive the button press byte because the press occurs before connection.

Central doesn't receive the button release byte because if it released before the "connection time + central/peripheral negotiation time", the peripheral won't send it.

When looking at Sniffer data, the time delta between connection indicate (CONNECT_IND) and the end of negotiation is consistently 512 msec.

At the function: ble-evt_handler,  p_ble_evt->header.evt_id = BLE_GAP_EVT_CONNECTED I tried manually transmitting the button pressed byte, but the Sniffer viewer never displayed the transmitted byte. I suspect because negotiation was in progress.

1. Is there anyway to get around the negotiation time? Does connecting to a previously paired device cut down on the negotiation time? Current negotiation time is too long to meet my requirements.

2. I searched examples, nothing. Do you know of any example code?

3. Any suggestions on how to transmit the button press event byte to the central?

Related