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
  • why on earth would you want to block during the processing of an event most likely in an interrupt handler while waiting for a peripheral to talk to you? It's not like the connect event has a return of any sort you have to send back synchronously, nor does blocking there stop the device on the other side sending data and doing things with the connection, it's just a notification of one event.

    Should you really want to do that then send your data, poll the UART until you get what you want and then continue .. but don't do it like that .. use the UART driver Nordic provides and do the whole thing asynchronously when you get the data back

Reply
  • why on earth would you want to block during the processing of an event most likely in an interrupt handler while waiting for a peripheral to talk to you? It's not like the connect event has a return of any sort you have to send back synchronously, nor does blocking there stop the device on the other side sending data and doing things with the connection, it's just a notification of one event.

    Should you really want to do that then send your data, poll the UART until you get what you want and then continue .. but don't do it like that .. use the UART driver Nordic provides and do the whole thing asynchronously when you get the data back

Children
No Data
Related