<?xml version="1.0" encoding="UTF-8" ?>
<?xml-stylesheet type="text/xsl" href="https://devzone.nordicsemi.com/cfs-file/__key/system/syndication/rss.xsl" media="screen"?><rss version="2.0" xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:slash="http://purl.org/rss/1.0/modules/slash/" xmlns:wfw="http://wellformedweb.org/CommentAPI/" xmlns:atom="http://www.w3.org/2005/Atom"><channel><title>Sending messages to PC</title><link>https://devzone.nordicsemi.com/f/nordic-q-a/58929/sending-messages-to-pc</link><description>Hi 
 I am using the SDK_16.0.0 and SDK_for_mesh_4.0. 
 Board: PCA10056, nRF52840. 
 
 1) I try to send strings to from the nRF to PC and then, using a python script, poll messages from the COM-Port. 
 I tried the UART example from the SDK16 and it worked</description><dc:language>en-US</dc:language><generator>Telligent Community 13</generator><lastBuildDate>Sat, 14 Mar 2020 08:42:40 GMT</lastBuildDate><atom:link rel="self" type="application/rss+xml" href="https://devzone.nordicsemi.com/f/nordic-q-a/58929/sending-messages-to-pc" /><item><title>RE: Sending messages to PC</title><link>https://devzone.nordicsemi.com/thread/239823?ContentTypeID=1</link><pubDate>Sat, 14 Mar 2020 08:42:40 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:42fedd48-a2d0-46fa-b161-ba7bd1877b77</guid><dc:creator>BroccLee</dc:creator><description>&lt;p&gt;I got everything working, I now have UART support on my mesh light_switch example and can use the printf(). I will quickly describe what I did if anyone else comes across this post:&lt;/p&gt;
&lt;p&gt;1) open the UART example from the SDK16\examples\peripheral\uart\pca10056\blank\ses.&lt;/p&gt;
&lt;p&gt;Also open the lightswitch example from&amp;nbsp;nRF5_SDK_Mesh_4\examples\light_switch\server.&lt;/p&gt;
&lt;p&gt;2) From UART example, right click on Project &amp;#39;uart_pca10056&amp;#39; and got to options. On the Dropdown window, select Common.&amp;nbsp;On the left side, select &amp;#39;Preprocessor&amp;#39;. From &amp;#39;Preprocessor Definitions&amp;#39; and &amp;#39;User include Directories&amp;#39;, copy everything and paste them in the corresponding lightswitch example. You will have to adjust the paths for the &amp;#39;User Include Directories&amp;#39; in the light_switch example. It will look something like this:&lt;/p&gt;
&lt;p&gt;&lt;pre class="ui-code" data-mode="text"&gt;include
../include
../../common/include
../../../external/rtt/include
../../../../nRF5_SDK_16/components/libraries/uart
../../../../nRF5_SDK_16/components/libraries/bsp
../../../../nRF5_SDK_16/components/ble/common
../../../../nRF5_SDK_16/components/softdevice/common
../../../../nRF5_SDK_16/components/libraries/strerror
../../../../nRF5_SDK_16/components/libraries/atomic
../../../models/foundation/config/include
../../../models/foundation/health/include
../../../models/model_spec/generic_onoff/include
../../../models/model_spec/common/include
../../../mesh/friend/api
../../../mesh/friend/include
../../../mesh/bearer/api
../../../mesh/bearer/include
../../../mesh/stack/api
../../../mesh/core/api
../../../mesh/core/include
../../../mesh/access/api
../../../mesh/access/include
../../../mesh/dfu/api
../../../mesh/dfu/include
../../../mesh/prov/api
../../../mesh/prov/include
../../../mesh/gatt/api
../../../mesh/gatt/include
../../../../nRF5_SDK_16/components/softdevice/s140/headers/
../../../../nRF5_SDK_16/components/softdevice/s140/headers/nrf52/
../../../../nRF5_SDK_16/modules/nrfx
../../../../nRF5_SDK_16/modules/nrfx/mdk
../../../../nRF5_SDK_16/modules/nrfx/hal
../../../../nRF5_SDK_16/components/toolchain/cmsis/include
../../../../nRF5_SDK_16/components/toolchain/gcc
../../../../nRF5_SDK_16/components/toolchain/cmsis/dsp/GCC
../../../../nRF5_SDK_16/components/boards
../../../../nRF5_SDK_16/integration/nrfx
../../../../nRF5_SDK_16/components/libraries/util
../../../../nRF5_SDK_16/components/libraries/timer
../../../../nRF5_SDK_16/components/libraries/log
../../../../nRF5_SDK_16/components/libraries/log/src
../../../../nRF5_SDK_16/components/libraries/experimental_section_vars
../../../../nRF5_SDK_16/components/libraries/delay
../../../external/micro-ecc
../../../mesh/core/include
../../../../nRF5_SDK_16/components
../../../../nRF5_SDK_16/components/boards
../../../../nRF5_SDK_16/components/drivers_nrf/nrf_soc_nosd
../../../../nRF5_SDK_16/components/libraries/atomic
../../../../nRF5_SDK_16/components/libraries/balloc
../../../../nRF5_SDK_16/components/libraries/delay
../../../../nRF5_SDK_16/components/libraries/experimental_section_vars
../../../../nRF5_SDK_16/components/libraries/fifo
../../../../nRF5_SDK_16/components/libraries/log
../../../../nRF5_SDK_16/components/libraries/log/src
../../../../nRF5_SDK_16/components/libraries/memobj
../../../../nRF5_SDK_16/components/libraries/ringbuf
../../../../nRF5_SDK_16/components/libraries/strerror
../../../../nRF5_SDK_16/components/libraries/uart
../../../../nRF5_SDK_16/components/libraries/util
../../../../nRF5_SDK_16/components/toolchain/cmsis/include
../../../../nRF5_SDK_16/external/fprintf
../../../../nRF5_SDK_16/integration/nrfx
../../../../nRF5_SDK_16/integration/nrfx/legacy
./../../../nRF5_SDK_16/modules/nrfx
../../../../nRF5_SDK_16/modules/nrfx/drivers/include
../../../../nRF5_SDK_16/modules/nrfx/hal
../../../../nRF5_SDK_16/modules/nrfx/mdk&lt;/pre&gt;&lt;/p&gt;
&lt;p&gt;The &amp;#39;Preprocessor Definitions&amp;#39; of my light_switch example looks like this:&lt;/p&gt;
&lt;p&gt;&lt;pre class="ui-code" data-mode="text"&gt;NO_VTOR_CONFIG
USE_APP_CONFIG
CONFIG_APP_IN_CORE
NRF52_SERIES
NRF52840
NRF52840_XXAA
S140
SOFTDEVICE_PRESENT
NRF_SD_BLE_API_VERSION=7
BOARD_PCA10056
CONFIG_GPIO_AS_PINRESET
BOARD_PCA10056
BSP_DEFINES_ONLY
CONFIG_GPIO_AS_PINRESET
FLOAT_ABI_HARD
INITIALIZE_USER_SECTIONS
NO_VTOR_CONFIG
NRF52840_XXAA&lt;/pre&gt;&lt;/p&gt;
&lt;p&gt;&lt;/p&gt;
&lt;p&gt;3) in the UART project, there are alot of .c files that are not included in the light_switch example. I&amp;#39;m not sure if you do have to manually include them into you light_switch example, but here is what I did:&lt;/p&gt;
&lt;p&gt;On the UART project, I right-click the .c file, e.g. the nrf_drv_uart.c, and press &amp;#39;select in Folder explorer&amp;#39;. I then drag-and-drop this file in my light_switch project (you might want to create a new Folder in the Project to drop your Files in). I did this with almost all files, but make sure to not copy anything that is already in your light_switch example.&lt;/p&gt;
&lt;p&gt;4) Most important part: configure the sdk_config.h file in&amp;nbsp;nRF5_SDK_Mesh_4\examples\light_switch\server\include.&lt;/p&gt;
&lt;p&gt;this is the tricky part. What I did first is to compare the sdk_config.h from the UART example with the sdk_config.h from the light_switch example. user the Website&amp;nbsp;&lt;a href="https://www.diffchecker.com/"&gt;https://www.diffchecker.com/&lt;/a&gt;&amp;nbsp;for this. I then&amp;nbsp;copied the #defines from the UART config that are not in the light_switch config and pasted them at the bottom (before the #dif)&amp;nbsp;&amp;nbsp;of the light_switch config:&amp;nbsp;&lt;/p&gt;
&lt;p&gt;&lt;pre class="ui-code" data-mode="text"&gt;//==========================================================
// START Changes from USER - enable UART
//==========================================================

// &amp;lt;e&amp;gt; NRFX_PRS_ENABLED - nrfx_prs - Peripheral Resource Sharing module
//==========================================================
#ifndef NRFX_PRS_ENABLED
#define NRFX_PRS_ENABLED 1
#endif
// &amp;lt;q&amp;gt; NRFX_PRS_BOX_0_ENABLED  - Enables box 0 in the module.
 
#ifndef NRFX_PRS_BOX_0_ENABLED
#define NRFX_PRS_BOX_0_ENABLED 0
#endif
// &amp;lt;q&amp;gt; NRFX_PRS_BOX_1_ENABLED  - Enables box 1 in the module.
 
#ifndef NRFX_PRS_BOX_1_ENABLED
#define NRFX_PRS_BOX_1_ENABLED 0
#endif
// &amp;lt;q&amp;gt; NRFX_PRS_BOX_2_ENABLED  - Enables box 2 in the module.
 
#ifndef NRFX_PRS_BOX_2_ENABLED
#define NRFX_PRS_BOX_2_ENABLED 0
#endif
// &amp;lt;q&amp;gt; NRFX_PRS_BOX_3_ENABLED  - Enables box 3 in the module.
 
#ifndef NRFX_PRS_BOX_3_ENABLED
#define NRFX_PRS_BOX_3_ENABLED 0
#endif
// &amp;lt;q&amp;gt; NRFX_PRS_BOX_4_ENABLED  - Enables box 4 in the module.
 
#ifndef NRFX_PRS_BOX_4_ENABLED
#define NRFX_PRS_BOX_4_ENABLED 1
#endif
// &amp;lt;e&amp;gt; NRFX_PRS_CONFIG_LOG_ENABLED - Enables logging in the module.
//==========================================================
#ifndef NRFX_PRS_CONFIG_LOG_ENABLED
#define NRFX_PRS_CONFIG_LOG_ENABLED 0
#endif
// &amp;lt;o&amp;gt; NRFX_PRS_CONFIG_LOG_LEVEL  - Default Severity level
 
// &amp;lt;0=&amp;gt; Off 
// &amp;lt;1=&amp;gt; Error 
// &amp;lt;2=&amp;gt; Warning 
// &amp;lt;3=&amp;gt; Info 
// &amp;lt;4=&amp;gt; Debug 
#ifndef NRFX_PRS_CONFIG_LOG_LEVEL
#define NRFX_PRS_CONFIG_LOG_LEVEL 3
#endif
// &amp;lt;o&amp;gt; NRFX_PRS_CONFIG_INFO_COLOR  - ANSI escape code prefix.
 
// &amp;lt;0=&amp;gt; Default 
// &amp;lt;1=&amp;gt; Black 
// &amp;lt;2=&amp;gt; Red 
// &amp;lt;3=&amp;gt; Green 
// &amp;lt;4=&amp;gt; Yellow 
// &amp;lt;5=&amp;gt; Blue 
// &amp;lt;6=&amp;gt; Magenta 
// &amp;lt;7=&amp;gt; Cyan 
// &amp;lt;8=&amp;gt; White 
#ifndef NRFX_PRS_CONFIG_INFO_COLOR
#define NRFX_PRS_CONFIG_INFO_COLOR 0
#endif
// &amp;lt;o&amp;gt; NRFX_PRS_CONFIG_DEBUG_COLOR  - ANSI escape code prefix.
 
// &amp;lt;0=&amp;gt; Default 
// &amp;lt;1=&amp;gt; Black 
// &amp;lt;2=&amp;gt; Red 
// &amp;lt;3=&amp;gt; Green 
// &amp;lt;4=&amp;gt; Yellow 
// &amp;lt;5=&amp;gt; Blue 
// &amp;lt;6=&amp;gt; Magenta 
// &amp;lt;7=&amp;gt; Cyan 
// &amp;lt;8=&amp;gt; White 

#ifndef NRFX_PRS_CONFIG_DEBUG_COLOR
#define NRFX_PRS_CONFIG_DEBUG_COLOR 0
#endif


#ifndef NRFX_PRS_BOX_4_ENABLED
#define NRFX_PRS_BOX_4_ENABLED 1
#endif

#ifndef NRFX_PRS_CONFIG_DEBUG_COLOR
#define NRFX_PRS_CONFIG_DEBUG_COLOR 0
#endif

// &amp;lt;o&amp;gt; NRFX_UARTE1_ENABLED - Enable UARTE1 instance 
#ifndef NRFX_UARTE1_ENABLED
#define NRFX_UARTE1_ENABLED 0
#endif

// &amp;lt;e&amp;gt; UART1_ENABLED - Enable UART1 instance
//==========================================================
#ifndef UART1_ENABLED
#define UART1_ENABLED 0
#endif
//==========================================================
// &amp;lt;q&amp;gt; APP_FIFO_ENABLED  - app_fifo - Software FIFO implementation
 
#ifndef APP_FIFO_ENABLED
#define APP_FIFO_ENABLED 1
#endif

// &amp;lt;e&amp;gt; APP_UART_ENABLED - app_uart - UART driver
//==========================================================
#ifndef APP_UART_ENABLED
#define APP_UART_ENABLED 1
#endif
// &amp;lt;o&amp;gt; APP_UART_DRIVER_INSTANCE  - UART instance used
 
// &amp;lt;0=&amp;gt; 0 

#ifndef APP_UART_DRIVER_INSTANCE
#define APP_UART_DRIVER_INSTANCE 0
#endif

// &amp;lt;q&amp;gt; RETARGET_ENABLED  - retarget - Retargeting stdio functions
#ifndef RETARGET_ENABLED
#define RETARGET_ENABLED 1
#endif
//==========================================================
// END Changes from USER - enable UART
//=============================================&lt;/pre&gt;&lt;/p&gt;
&lt;p&gt;I then enabled everything in my light_switch config that was also enabled in the UART config. What did mess up my project was the #define&amp;nbsp;UART_LEGACY_SUPPORT. This is set to 1 in the UART example, I had to set it to 0 for my project to work. In short, here&amp;#39;s my config file:&amp;nbsp;&lt;a href="https://devzone.nordicsemi.com/cfs-file/__key/communityserver-discussions-components-files/4/0724.sdk_5F00_config.h"&gt;devzone.nordicsemi.com/.../0724.sdk_5F00_config.h&lt;/a&gt;&lt;/p&gt;
&lt;p&gt;&lt;/p&gt;
&lt;p&gt;5) to enable the UART in the light_switch example, copy some code from the UART main.c to the light_switch main.c, to be more precice, paste this at the top of your light_switch main.c file:&amp;nbsp;&lt;/p&gt;
&lt;p&gt;&lt;pre class="ui-code" data-mode="text"&gt;/* UART stuff */
#include &amp;lt;stdbool.h&amp;gt;
#include &amp;lt;stdint.h&amp;gt;
#include &amp;lt;stdio.h&amp;gt;
#include &amp;quot;app_uart.h&amp;quot;
#include &amp;quot;app_error.h&amp;quot;
#include &amp;quot;nrf_delay.h&amp;quot;
#include &amp;quot;nrf.h&amp;quot;
#include &amp;quot;bsp.h&amp;quot;
#if defined (UART_PRESENT)
#include &amp;quot;nrf_uart.h&amp;quot;
#endif
#if defined (UARTE_PRESENT)
#include &amp;quot;nrf_uarte.h&amp;quot;
#endif


//#define ENABLE_LOOPBACK_TEST  /**&amp;lt; if defined, then this example will be a loopback test, which means that TX should be connected to RX to get data loopback. */

#define MAX_TEST_DATA_BYTES     (15U)                /**&amp;lt; max number of test bytes to be used for tx and rx. */
#define UART_TX_BUF_SIZE 256                         /**&amp;lt; UART TX buffer size. */
#define UART_RX_BUF_SIZE 256                         /**&amp;lt; UART RX buffer size. */

void uart_error_handle(app_uart_evt_t * p_event)
{
    if (p_event-&amp;gt;evt_type == APP_UART_COMMUNICATION_ERROR)
    {
        APP_ERROR_HANDLER(p_event-&amp;gt;data.error_communication);
    }
    else if (p_event-&amp;gt;evt_type == APP_UART_FIFO_ERROR)
    {
        APP_ERROR_HANDLER(p_event-&amp;gt;data.error_code);
    }
}

/* When UART is used for communication with the host do not use flow control.*/
#define UART_HWFC APP_UART_FLOW_CONTROL_DISABLED&lt;/pre&gt;&lt;/p&gt;
&lt;p&gt;and paste this inside the main function in the main.c:&lt;/p&gt;
&lt;p&gt;&lt;pre class="ui-code" data-mode="text"&gt;    uint32_t err_code;

    bsp_board_init(BSP_INIT_LEDS);

    const app_uart_comm_params_t comm_params =
      {
          RX_PIN_NUMBER,
          TX_PIN_NUMBER,
          RTS_PIN_NUMBER,
          CTS_PIN_NUMBER,
          UART_HWFC,
          false,
#if defined (UART_PRESENT)
          NRF_UART_BAUDRATE_115200
#else
          NRF_UARTE_BAUDRATE_115200
#endif
      };

    APP_UART_FIFO_INIT(&amp;amp;comm_params,
                         UART_RX_BUF_SIZE,
                         UART_TX_BUF_SIZE,
                         uart_error_handle,
                         APP_IRQ_PRIORITY_LOWEST,
                         err_code);

    APP_ERROR_CHECK(err_code);
&lt;/pre&gt;&lt;/p&gt;
&lt;p&gt;&lt;/p&gt;
&lt;p&gt;6) Now you can user the printf() function wherever you want in your main.c file and read it on your PC with HTerm or Putty.&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: Sending messages to PC</title><link>https://devzone.nordicsemi.com/thread/239690?ContentTypeID=1</link><pubDate>Fri, 13 Mar 2020 10:58:32 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:09892395-a52a-4972-a3fd-55e5a7ec1ba9</guid><dc:creator>BroccLee</dc:creator><description>&lt;p&gt;Okay I found the answer to this problem; from the uart example, right click on the project-&amp;gt;options-&amp;gt;dropdown common-&amp;gt;preprocessor-&amp;gt;Preprocessor definitions-&amp;gt; copy all the entries and past them in the Preprocessor definitions of my project. These definitions disable the #include &amp;quot;bsp.h&amp;quot;.&lt;/p&gt;
&lt;p&gt;now the only problem is that in the nrf_drv_uart.h file there are #defines that should be grayed out, which are not.&amp;nbsp;&lt;/p&gt;
&lt;p&gt;&lt;pre class="ui-code" data-mode="text"&gt;#include &amp;lt;nrfx.h&amp;gt;

#if defined(UARTE_PRESENT) &amp;amp;&amp;amp; NRFX_CHECK(NRFX_UARTE_ENABLED)
    #define NRF_DRV_UART_WITH_UARTE
#endif&lt;/pre&gt;&lt;/p&gt;
&lt;p&gt;this code should not be grayedd out, but it is for me. This means that&amp;nbsp;&lt;strong&gt;NRFX_UARTE_ENABLED&lt;/strong&gt; should be defined. this is defined in the apply_old_config.h.&amp;nbsp;&lt;/p&gt;
&lt;p&gt;&lt;pre class="ui-code" data-mode="text"&gt;#if defined(UART_ENABLED)

#undef NRFX_UART_ENABLED
#define NRFX_UART_ENABLED   (UART_ENABLED &amp;amp;&amp;amp; NRFX_UART0_ENABLED)
#undef NRFX_UARTE_ENABLED
#define NRFX_UARTE_ENABLED  (UART_ENABLED &amp;amp;&amp;amp; (NRFX_UARTE0_ENABLED || NRFX_UARTE1_ENABLED))&lt;/pre&gt;So &lt;strong&gt;UART_ENABLED&lt;/strong&gt; has to be defined for this to work.&lt;/p&gt;
&lt;p&gt;I did define UART_ENABLED in my sdk_config.h:&amp;nbsp;&lt;/p&gt;
&lt;p&gt;&lt;pre class="ui-code" data-mode="text"&gt;// &amp;lt;e&amp;gt; UART_ENABLED - nrf_drv_uart - UART/UARTE peripheral driver - legacy layer
//==========================================================
#ifndef UART_ENABLED
#define UART_ENABLED 1  // was o in server example
#endif&lt;/pre&gt;&lt;/p&gt;
&lt;p&gt;but it still doesn&amp;#39;t work.&amp;nbsp;&lt;/p&gt;
&lt;p&gt;Any help? Thanks&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: Sending messages to PC</title><link>https://devzone.nordicsemi.com/thread/239665?ContentTypeID=1</link><pubDate>Fri, 13 Mar 2020 09:25:46 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:1c2d1094-16c3-421b-82b7-f31554b16a5e</guid><dc:creator>BroccLee</dc:creator><description>&lt;p&gt;Hi Hung,&lt;/p&gt;
&lt;p&gt;A co-worker&amp;nbsp;told me that it should be sufficient to just include the the paths to the .h files which i include in the main.c. It should then inlude the .c files automatically.&lt;/p&gt;
&lt;p&gt;I did this in the project optins/user defined libraries and added all the relative paths needed (I basically copied the paths from the uart example). For example, i have&amp;nbsp;&lt;strong&gt;#include &amp;quot;bsp.h&amp;quot; &lt;/strong&gt;in my main.c, so I added the path&lt;strong&gt;&amp;nbsp;../../../../nRF5_SDK_16/components/libraries/bsp&amp;nbsp;&lt;/strong&gt;to the project path. However, I now have the error message &amp;quot;app_button.h: No such file or directory&amp;quot;, which is inside the app_uart.h file, so I would need to include this file as well. This would go on forever.&lt;/p&gt;
&lt;p&gt;In the uart example, those subfiles are nowhere declared and it still works. Am I doing this wrong?&lt;/p&gt;
&lt;p&gt;Thanks&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: Sending messages to PC</title><link>https://devzone.nordicsemi.com/thread/239367?ContentTypeID=1</link><pubDate>Wed, 11 Mar 2020 14:32:02 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:7b2686c9-1c29-4c61-be4a-2aca4bc688a4</guid><dc:creator>Hung Bui</dc:creator><description>&lt;p&gt;Hi Brocc,&amp;nbsp;&lt;/p&gt;
&lt;p&gt;&lt;br /&gt;If you want to be able to printout on UART you need to implement the uart module. This include all the .c files of the libraries and retarget.c also must be included. You can&amp;#39;t just use printf() without the uart library.&amp;nbsp;&lt;br /&gt;&lt;br /&gt;&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item></channel></rss>