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

Read uart data while advertising beacon

I want to use UART to read GPS data while advertising. After I add uart function to ble_beacon_example, UART API app_uart_get() always return NRF_ERROR_NOT_FOUND.What can I do? Board is nRF52-DK. SDK is nRF5_SDK_11.0.0_89a8197. This is my codemain.c

  • Hi,

    When app_uart_get return NRF_ERROR_NOT_FOUND it means that no byte is available in the RX buffer of the app_uart module. Make sure that you are actually sending data to the nRF52832 and that both the GPS module and the nRF52832 is configured with the same settings (Baud-rate, parity, flow-control) and connected correctly(RX_PIN_NUMBER/ TX_PIN_NUMBER). Regarding your code you should configure the uart event handler, uart_error_handle(), with the APP_UART_DATA_READY event, and call the app_uart_get() function every time you receive the APP_UART_DATA_READY event from the uart module. Take a look at e.g. the ble_app_uart example code to see how this is done.

  • Hi Sigurd,

    I had already comfirmed that the nRF52832,the GPS and the nRF52832 PIN are corrent.I don't know why use UART_DATA_READY,beacuse peripheral UART example can read GPS data. I'm glad U answer my question.

  • The peripheral\uart example is continuously calling the app_uart_get() function in order to check if there have been received any data in UART FIFO. But, when you also want to do BLE advertising or connection (as done in e.g. ble_app_uart), you don't have time to check the FIFO all the time. You only want to call app_uart_get() when you know that there is some data available. So for BLE, you want an interrupt/event(APP_UART_DATA_READY ) telling you when the UART have available data in the FIFO. You should therefore use the APP_UART_DATA_READY event when using BLE+UART.

Related