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

How do I wait until a response come after data sent through UART module of nRF51822?

On a BLE_GAP_EVT_CONNECTED, I'll send some data to an attached microcontroller via UART. The code will expect a response of that data, all while being inside that BLE_GAP_EVT_CONNECTED switch block. Can anybody please share a code snippet to do that? Your help is greatly appreciated. Thanks in advance.

Parents
  • As I pointed out in the first comment, blocking during the processing of the connect event does absolutely nothing for your use case. The softdevice is merely notifying you that a connection has been made, blocking during the processing of that notification does not stop the softdevice servicing the central on the other side which can continue to query the chip, scan for services, perform discovery and attempt to read characteristics. You will of course get the usual callbacks when the thing actually tries to read, if you have the flags set, and not replying to those until you've determined that the original connection was ok, will prevent it actually getting any data.

    Blocking in the event handler, vs waiting for the async reply, will have exactly the same effect in terms of when you get to close the connection.

Reply
  • As I pointed out in the first comment, blocking during the processing of the connect event does absolutely nothing for your use case. The softdevice is merely notifying you that a connection has been made, blocking during the processing of that notification does not stop the softdevice servicing the central on the other side which can continue to query the chip, scan for services, perform discovery and attempt to read characteristics. You will of course get the usual callbacks when the thing actually tries to read, if you have the flags set, and not replying to those until you've determined that the original connection was ok, will prevent it actually getting any data.

    Blocking in the event handler, vs waiting for the async reply, will have exactly the same effect in terms of when you get to close the connection.

Children
No Data
Related