Including "app_uart.h" in main program of 'simple_coap_server' example

HI All,

I wonder if someone can help me out. I would like to send serial data by modifying the 'simple_coap_server' main program. I added the following header 'app_uart.h' to make use of the functions but when I compile the program using GCC ('make' command in Windows), I get No such file or directory #include "app_uart.h". What I don't understand is that the file is in the directory and that I can compile the 'UART' example using GCC successfully without any problems. Any thoughts please, maybe I'm missing something?

Roger

edit retag close delete

Sort by » oldest newest most voted

Do you mean the simple_coap_server example in the Thread SDK? Have you added the path to the header file to INC_FOLDER in the Makefile?

$(SDK_ROOT)/components/libraries/uart \  more Comments I'm such a noob, thank you very much Jørgen, it worked. Learned something new today. ( 2017-05-18 16:16:44 +0200 )editconvert to answer Happy to help! ( 2017-05-18 16:25:59 +0200 )editconvert to answer answered 2017-05-19 14:30:14 +0200 Hello Jørgen, Seems like there is something still missing which I don't fully understand. The 'simple_coap_server' compiles with no error after including$(SDK_ROOT)/components/libraries/uart \ in the INC_FOLDER of the Makefile. However, after including the following code from the 'UART' example to the main of 'simple_coap_server' example':

int main(void) {

uint32_t err_code;

const app_uart_comm_params_t comm_params =
{
RX_PIN_NUMBER,
TX_PIN_NUMBER,
RTS_PIN_NUMBER,
CTS_PIN_NUMBER,
APP_UART_FLOW_CONTROL_ENABLED,
false,
UART_BAUDRATE_BAUDRATE_Baud115200
};

APP_UART_FIFO_INIT(&comm_params,
UART_RX_BUF_SIZE,
UART_TX_BUF_SIZE,
uart_error_handle,
APP_IRQ_PRIORITY_LOWEST,
err_code);

APP_ERROR_CHECK(err_code);

printf("\r\nStart: \r\n");

while (true)
{
uint8_t cr;
while (app_uart_get(&cr) != NRF_SUCCESS);
while (app_uart_put(cr) != NRF_SUCCESS);

if (cr == 'q' || cr == 'Q')
{
printf(" \r\nExit!\r\n");

while (true)
{
// Do nothing.
}

}

}


I get the following error:

It seems that the functions of "app_uart.h" used in main are still undefined. In the 'UART' example, I also checked that the headers and source files in the Makefile, are also included in the 'simple_coap_server' Makefile, but I still get an undefined reference to the functions.

Are there perhaps any other files that need to be included? Any thoughts?

Roger

more

There are a few things needed to get UART working. In addition to adding the path to the header files, you need to include the source files app_uart_fifo.c, app_fifo.c, and nrf_drv_uart.c in your project/Makefile. You will also have to add the paths to the header files of these additional libraries. Then, you need to enable all the modules in sdk_config.h by setting the correct defines. Finally, if you also want to use printf() functionality for the UART interface, you need to incude the source file retarget.c, and enable this module in sdk_config.h as well. I see that these are not included in the config file for the Thread examples, so I created Makefile and sdk_config.h file that should work for you. Note that UART0 peripheral is owned by OpenThread stack and cannot be used by the application. You are therefore required to ...(more)

( 2017-05-19 15:41:49 +0200 )editconvert to answer

[hide preview]

Recent blog posts

• The complete tutorial for developing and debugging nRF52 applications on a Mac

Posted 2017-05-11 04:13:06 by Mohammad Afaneh
• Bluetooth 5 2Mbps Demo with nRF52 Series and Samsung Galaxy S8

Posted 2017-05-09 14:20:22 by John Leonard
• Setting up Segger on a mac or pc and debug - step by step for humans

Posted 2017-05-05 14:03:35 by Lola

Posted 2017-04-11 11:49:17 by Radosław Koppel
• Taking a deeper dive into Bluetooth 5

Posted 2017-04-07 14:53:51 by John Leonard

Recent questions

• nrf52 sdk12 custom service full example

Posted 2017-05-28 19:34:43 by Remi
• Antenna for the beacon

Posted 2017-05-28 18:06:06 by Usman
• Gazell nRF51822

Posted 2017-05-28 00:40:13 by Andrew Kohlsmith
• Is Zephyr I2c Master Supported pca10040

Posted 2017-05-27 23:21:37 by gidjit
• Throughput of ble_app_uart

Posted 2017-05-27 19:14:00 by mansfield