<?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>How to send data to UART for the provisioner example of mesh sdk.</title><link>https://devzone.nordicsemi.com/f/nordic-q-a/71925/how-to-send-data-to-uart-for-the-provisioner-example-of-mesh-sdk</link><description>Hi, 
 
 I am using nrf17.02 sdk and nrf mesh 5.0 sdk for nrf52832 dev kit. 
 1) I want to send the data to UART not on RTT while using the mesh example &amp;quot;provisioner&amp;quot; example of mesh sdk in place &amp;quot;meshsdk/example/provisioner&amp;quot;. How to procees with it, can</description><dc:language>en-US</dc:language><generator>Telligent Community 13</generator><lastBuildDate>Mon, 22 Mar 2021 17:51:47 GMT</lastBuildDate><atom:link rel="self" type="application/rss+xml" href="https://devzone.nordicsemi.com/f/nordic-q-a/71925/how-to-send-data-to-uart-for-the-provisioner-example-of-mesh-sdk" /><item><title>RE: How to send data to UART for the provisioner example of mesh sdk.</title><link>https://devzone.nordicsemi.com/thread/301290?ContentTypeID=1</link><pubDate>Mon, 22 Mar 2021 17:51:47 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:0a89bb25-8931-4623-8718-a8a946d9781e</guid><dc:creator>Mttrinh</dc:creator><description>&lt;p&gt;1) This seems really strange, can you provide the exact step you have done?&lt;/p&gt;
&lt;p&gt;2) Sorry, seems like I missed it.&lt;/p&gt;
&lt;p&gt;3) When debugging can you see if the code enters your uart handler at all? Set a breakpoint inside the handler and see if it enters when you send data. The first thing would be to get the uart part to work first. Make sure that you can receive anything via UART at all.&amp;nbsp;&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: How to send data to UART for the provisioner example of mesh sdk.</title><link>https://devzone.nordicsemi.com/thread/301099?ContentTypeID=1</link><pubDate>Mon, 22 Mar 2021 03:53:52 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:3a8a784a-8332-4af0-8bb9-51e71280a4f3</guid><dc:creator>Ela</dc:creator><description>&lt;p&gt;Hi Mttrinh,&lt;/p&gt;
&lt;p&gt;Any update for this?&lt;/p&gt;
&lt;p&gt;Thanks &amp;amp; Regards,&lt;/p&gt;
&lt;p&gt;Ela&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: How to send data to UART for the provisioner example of mesh sdk.</title><link>https://devzone.nordicsemi.com/thread/300895?ContentTypeID=1</link><pubDate>Fri, 19 Mar 2021 11:21:52 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:7c08962a-43bc-437a-aab5-d480080d596a</guid><dc:creator>Ela</dc:creator><description>&lt;p&gt;Hi Mttrinh,&lt;/p&gt;
&lt;p&gt;&lt;/p&gt;
&lt;p&gt;1) I have tried with freshly downloaded sdks but still face the same issue.&lt;/p&gt;
&lt;p&gt;2) I have called uart_init() in the initialize function of main.c attaching the code,&lt;/p&gt;
&lt;p&gt;&lt;pre class="ui-code" data-mode="text"&gt;
static void initialize(void)
{
    
      uart_init();
   
   // __LOG_INIT(LOG_SRC_APP | LOG_SRC_ACCESS, LOG_LEVEL_INFO, LOG_CALLBACK_DEFAULT);
    __LOG_INIT(LOG_SRC_APP | LOG_SRC_FRIEND, LOG_LEVEL_DBG1, log_callback_rtt);
    __LOG(LOG_SRC_APP, LOG_LEVEL_INFO, &amp;quot;----- BLE Mesh Static Provisioner Demo -----\n&amp;quot;);

    ERROR_CHECK(app_timer_init());
    hal_leds_init();

#if BUTTON_BOARD
    ERROR_CHECK(hal_buttons_init(button_event_handler));
#endif

    ble_stack_init();
    mesh_init();
    node_setup_uri_check();
}
&lt;/pre&gt;&lt;/p&gt;
&lt;p&gt;3) I have debugged this but not able to find out why it is not happening, i have put condition for scanning and resetting the does but not able to perform, not even able to reset the node. Can you find any memory issue, when i am pressing 4 nothing is coming as response, according to uart_event_handler it should reset the node, attaching the uart_event_handler which i have implemented for the desired output:&lt;/p&gt;
&lt;p&gt;&lt;pre class="ui-code" data-mode="text"&gt;void uart_event_handler(app_uart_evt_t * p_event)
{
    static uint8_t data_array[244];
    static uint8_t index = 0;
   // static uint8_t val = 0;
    uint32_t       err_code;

     //printf(&amp;quot;\r\nUART started uart event handler.\r\n&amp;quot;);
    switch (p_event-&amp;gt;evt_type)
    {
        case APP_UART_DATA_READY:
        {
            UNUSED_VARIABLE(app_uart_get(&amp;amp;data_array[index]));
            printf(&amp;quot;Data array in switch %c\r\n&amp;quot;,data_array[index]);

            index++;

             if ( data_array[index - 1] == &amp;#39;1&amp;#39;)
            {
               printf(&amp;quot;Sucess pressed 1 \r\n&amp;quot;);
               check_network_state();
               index = 0;
               memset(data_array[index], 0 , sizeof(data_array[index]));

            }

            if ( data_array[index - 1] == &amp;#39;2&amp;#39;)
            {
               printf(&amp;quot;Sucess pressed 2 \r\n&amp;quot;);
               provisioning_resume();
               index = 0;
               memset(data_array[index], 0 , sizeof(data_array[index]));

            }

             if ( data_array[index - 1] == &amp;#39;4&amp;#39;)
              {
               printf(&amp;quot;Sucess pressed 4 \r\n&amp;quot;);
             
                 if (mesh_stack_is_device_provisioned())
                 {
                   /* Clear all the states to reset the node. */
                   provisioner_invalidate();
                   mesh_stack_config_clear();
                 }
               node_reset();
               index = 0;
               memset(data_array[index], 0 , sizeof(data_array[index]));

              }

                
            #if 0
            if ( data_array[index - 1] == &amp;#39;;&amp;#39;)
            {
               printf(&amp;quot;sucess \r\n&amp;quot;);
               index = 0;
               memset(data_array[index], 0 , sizeof(data_array[index]));

            }
            #endif
           
                
            break;
            }

        case APP_UART_COMMUNICATION_ERROR:
            APP_ERROR_HANDLER(p_event-&amp;gt;data.error_communication);
            break;

        case APP_UART_FIFO_ERROR:
            APP_ERROR_HANDLER(p_event-&amp;gt;data.error_code);
            break;

        default:
            break;
    }
  }


&lt;/pre&gt;&amp;nbsp;&lt;/p&gt;
&lt;p&gt;&lt;/p&gt;
&lt;p&gt;Can you please help me with this?&lt;/p&gt;
&lt;p&gt;&lt;/p&gt;
&lt;p&gt;Thanks &amp;amp; Regards,&lt;/p&gt;
&lt;p&gt;Ela&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: How to send data to UART for the provisioner example of mesh sdk.</title><link>https://devzone.nordicsemi.com/thread/300507?ContentTypeID=1</link><pubDate>Wed, 17 Mar 2021 16:49:00 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:b48ccb11-8083-48f1-9abc-e1bf8f27c5c9</guid><dc:creator>Mttrinh</dc:creator><description>[quote user="Ekta hav"]1) Yes i have copied the ble_app_uart_coexist folder into ble_peripheral folder and set the MESH_ROOT in global macros to the mesh sdk path.[/quote]
&lt;p&gt;This is strange, I would suggest you try download a fresh copy of the SDKs and see if that helpes solve this.&lt;/p&gt;
&lt;p&gt;As for the implementation, unfortunately we don&amp;#39;t have an exact example to show you how to do this. Your implementation of your uart handler seems correct. Have you&amp;nbsp;tried debugging through the code to see what happens? Does the code enter the uart handler when you send the commands?&amp;nbsp;&lt;/p&gt;
&lt;p&gt;It looks like in your main that you don&amp;#39;t call uart_init()?&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: How to send data to UART for the provisioner example of mesh sdk.</title><link>https://devzone.nordicsemi.com/thread/300281?ContentTypeID=1</link><pubDate>Wed, 17 Mar 2021 06:54:33 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:857943c6-2db8-441c-ab56-957ab766bef8</guid><dc:creator>Ela</dc:creator><description>&lt;p&gt;Hi Mttrinh,&lt;/p&gt;
&lt;p&gt;It will be very helpful if a working code can be provided as reference for the desired output.&lt;/p&gt;
&lt;p&gt;Thanks &amp;amp; Regards,&lt;/p&gt;
&lt;p&gt;Ela&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: How to send data to UART for the provisioner example of mesh sdk.</title><link>https://devzone.nordicsemi.com/thread/300280?ContentTypeID=1</link><pubDate>Wed, 17 Mar 2021 06:54:33 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:e9aee04d-8292-4c0f-be3c-9cd0a5142b2e</guid><dc:creator>Ela</dc:creator><description>&lt;p&gt;Hi Mttrinh,&lt;/p&gt;
&lt;p&gt;It will be very helpful if a working code can be provided as reference for the desired output.&lt;/p&gt;
&lt;p&gt;Thanks &amp;amp; Regards,&lt;/p&gt;
&lt;p&gt;Ela&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: How to send data to UART for the provisioner example of mesh sdk.</title><link>https://devzone.nordicsemi.com/thread/300277?ContentTypeID=1</link><pubDate>Wed, 17 Mar 2021 06:31:05 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:cf9c6c46-be1c-417f-8ada-830adcf8d254</guid><dc:creator>Ela</dc:creator><description>&lt;p&gt;Hi Mttrinh,&lt;/p&gt;
&lt;p&gt;&lt;/p&gt;
&lt;p&gt;Can you please provide the implementation code for using UART logging for provisioner example code in mesh sdk , so that we are able to provision the unprovisioned nodes.&amp;nbsp;&lt;/p&gt;
&lt;p&gt;I have shared the implementation with you, but not able to achieve the desired result, not able to provision the unprovisioned nodes. I am attaching the main.c file what i have used for the UART logging and getting provision event handlers in uart_event_handler.&lt;/p&gt;
&lt;p&gt;It will be very helpful if i can get the quickest response as its been long raising this issue, causing delay for me, i hope you understand .&lt;/p&gt;
&lt;p&gt;&lt;pre class="ui-code" data-mode="text"&gt;/* Copyright (c) 2010 - 2020, Nordic Semiconductor ASA
 * All rights reserved.
 *
 * Redistribution and use in source and binary forms, with or without modification,
 * are permitted provided that the following conditions are met:
 *
 * 1. Redistributions of source code must retain the above copyright notice, this
 * list of conditions and the following disclaimer.
 *
 * 2. Redistributions in binary form, except as embedded into a Nordic
 *    Semiconductor ASA integrated circuit in a product or a software update for
 *    such product, must reproduce the above copyright notice, this list of
 *    conditions and the following disclaimer in the documentation and/or other
 *    materials provided with the distribution.
 *
 * 3. Neither the name of Nordic Semiconductor ASA nor the names of its
 *    contributors may be used to endorse or promote products derived from this
 *    software without specific prior written permission.
 *
 * 4. This software, with or without modification, must only be used with a
 *    Nordic Semiconductor ASA integrated circuit.
 *
 * 5. Any software provided in binary form under this license must not be reverse
 *    engineered, decompiled, modified and/or disassembled.
 *
 * THIS SOFTWARE IS PROVIDED BY NORDIC SEMICONDUCTOR ASA &amp;quot;AS IS&amp;quot; AND ANY EXPRESS
 * OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
 * OF MERCHANTABILITY, NONINFRINGEMENT, AND FITNESS FOR A PARTICULAR PURPOSE ARE
 * DISCLAIMED. IN NO EVENT SHALL NORDIC SEMICONDUCTOR ASA OR CONTRIBUTORS BE
 * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
 * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE
 * GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
 * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
 * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT
 * OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
 */

#include &amp;lt;stdint.h&amp;gt;
#include &amp;lt;string.h&amp;gt;

/* HAL */
#include &amp;quot;boards.h&amp;quot;
#include &amp;quot;nrf_delay.h&amp;quot;
#include &amp;quot;simple_hal.h&amp;quot;
#include &amp;quot;app_timer.h&amp;quot;

/* Core */
#include &amp;quot;nrf_mesh.h&amp;quot;
#include &amp;quot;nrf_mesh_events.h&amp;quot;
#include &amp;quot;nrf_mesh_assert.h&amp;quot;
#include &amp;quot;access_config.h&amp;quot;
#include &amp;quot;device_state_manager.h&amp;quot;
#include &amp;quot;mesh_stack.h&amp;quot;
#include &amp;quot;net_state.h&amp;quot;
#include &amp;quot;mesh_opt_provisioner.h&amp;quot;
#include &amp;quot;mesh_config_entry.h&amp;quot;
#include &amp;quot;mesh_opt.h&amp;quot;

/* Provisioning and configuration */
#include &amp;quot;provisioner_helper.h&amp;quot;
#include &amp;quot;node_setup.h&amp;quot;
#include &amp;quot;mesh_app_utils.h&amp;quot;

/* Models */
#include &amp;quot;config_client.h&amp;quot;
#include &amp;quot;config_server.h&amp;quot;
#include &amp;quot;health_client.h&amp;quot;

/* Logging and RTT */
#include &amp;quot;rtt_input.h&amp;quot;
#include &amp;quot;log.h&amp;quot;

#include &amp;quot;nrf_log_ctrl.h&amp;quot;
#include &amp;quot;nrf_uart.h&amp;quot;
#include &amp;quot;app_uart.h&amp;quot;
#include &amp;quot;nrf_log_ctrl.h&amp;quot;
#include &amp;quot;nrf_log_default_backends.h&amp;quot;
//#include &amp;quot;nrf_log_backend_interface.h&amp;quot;


/* Example specific includes */
#include &amp;quot;example_network_config.h&amp;quot;
#include &amp;quot;nrf_mesh_config_examples.h&amp;quot;
#include &amp;quot;ble_softdevice_support.h&amp;quot;
#include &amp;quot;example_common.h&amp;quot;

/*****************************************************************************
 * Definitions
 *****************************************************************************/
#define APP_PROVISIONING_LED            BSP_LED_0
#define APP_CONFIGURATION_LED           BSP_LED_1





#define UART_TX_BUF_SIZE                256                                         /**&amp;lt; UART TX buffer size. */
#define UART_RX_BUF_SIZE                256                                         /**&amp;lt; UART RX buffer size. */
#include &amp;quot;app_uart.h&amp;quot;
#include &amp;quot;nrf_uart.h&amp;quot;
static bool m_device_provisioned;

/*****************************************************************************
 * Forward declaration of static functions
 *****************************************************************************/
static uint32_t provisioner_setter(mesh_config_entry_id_t id, const void * p_entry);
static void provisioner_getter(mesh_config_entry_id_t id, void * p_entry);
static void provisioner_deleter(mesh_config_entry_id_t id);
static void app_health_event_cb(const health_client_t * p_client, const health_client_evt_t * p_event);
static void app_config_successful_cb(void);
static void app_config_failed_cb(void);
static void app_mesh_core_event_cb (const nrf_mesh_evt_t * p_evt);

static void app_start(void);


/*****************************************************************************
 * Static variables
 *****************************************************************************/
/* Required for the provisioner helper module */
static network_dsm_handles_data_volatile_t m_dev_handles;

static network_stats_data_stored_t m_nw_state;
static bool m_node_prov_setup_started;
static nrf_mesh_evt_handler_t m_mesh_core_event_handler = { .evt_cb = app_mesh_core_event_cb };

NRF_MESH_STATIC_ASSERT(MESH_OPT_FIRST_FREE_ID &amp;lt;= MESH_APP_FILE_ID);
MESH_CONFIG_FILE(m_provisioner_file, MESH_APP_FILE_ID, MESH_CONFIG_STRATEGY_CONTINUOUS);

MESH_CONFIG_ENTRY(provisioner,
                  PROVISIONER_ENTRY_ID,
                  1,
                  sizeof(network_stats_data_stored_t),
                  provisioner_setter,
                  provisioner_getter,
                  provisioner_deleter,
                  false);

static uint32_t provisioner_setter(mesh_config_entry_id_t id, const void * p_entry)
{
    __LOG(LOG_SRC_APP, LOG_LEVEL_DBG1, &amp;quot;Provisioner setter ...\n&amp;quot;);
    NRF_MESH_ASSERT_DEBUG(PROVISIONER_RECORD == id.record);

    network_stats_data_stored_t * p_nsds = (network_stats_data_stored_t *) p_entry;
    memcpy(&amp;amp;m_nw_state, p_nsds, sizeof(network_stats_data_stored_t));

    return NRF_SUCCESS;
}

static void provisioner_getter(mesh_config_entry_id_t id, void * p_entry)
{
    __LOG(LOG_SRC_APP, LOG_LEVEL_DBG1, &amp;quot;Provisioner getter ...\n&amp;quot;);
    NRF_MESH_ASSERT_DEBUG(PROVISIONER_RECORD == id.record);

    network_stats_data_stored_t * p_nw_state = (network_stats_data_stored_t *) p_entry;
    memcpy(p_nw_state, &amp;amp;m_nw_state, sizeof(m_nw_state));
}

static void provisioner_deleter(mesh_config_entry_id_t id)
{
    __LOG(LOG_SRC_APP, LOG_LEVEL_DBG1, &amp;quot;Provisioner deleter ...\n&amp;quot;);
    NRF_MESH_ASSERT_DEBUG(PROVISIONER_RECORD == id.record);

    /* Clear and set default values. */
    memset(&amp;amp;m_nw_state, 0x00, sizeof(m_nw_state));
}

static void provisioner_store(void)
{
    printf(&amp;quot;store \r\n&amp;quot;);
    mesh_config_entry_id_t id = PROVISIONER_ENTRY_ID;

    NRF_MESH_ERROR_CHECK(mesh_config_entry_set(id, &amp;amp;m_nw_state));
}

static void provisioner_invalidate(void)
{
    /* Stop scanner. */
    prov_helper_scan_stop();
    /* Delete all old values and remove from mesh config. */
    (void)mesh_config_entry_delete(PROVISIONER_ENTRY_ID);
}

/*****************************************************************************/

static void app_data_store_cb(void)
{
    provisioner_store();
}

/*****************************************************************************/
/**** Configuration process related callbacks ****/

static void app_config_successful_cb(void)
{
     printf(&amp;quot;config \r\n&amp;quot;);
    __LOG(LOG_SRC_APP, LOG_LEVEL_INFO, &amp;quot;Configuration of device %u successful\n&amp;quot;, m_nw_state.configured_devices);

    hal_led_pin_set(APP_CONFIGURATION_LED, 0);
    hal_led_pin_set(APP_PROVISIONING_LED, 1);

    m_nw_state.configured_devices++;
    provisioner_store();
    prov_helper_provision_next_device();
    prov_helper_scan_start();
    printf(&amp;quot; main .c file scan done \r\n&amp;quot;); 
}

static void app_config_failed_cb(void)
{
      printf(&amp;quot; main.c file app_config failed \r\n&amp;quot;);
    __LOG(LOG_SRC_APP, LOG_LEVEL_INFO, &amp;quot;Configuration of device %u failed.\n&amp;quot;, m_nw_state.configured_devices);
    __LOG(LOG_SRC_APP, LOG_LEVEL_INFO, &amp;quot;Press Button/RTT 1 to retry configuration.\n&amp;quot;);
    __LOG(LOG_SRC_APP, LOG_LEVEL_INFO, &amp;quot;Press Button/RTT 2 to start provisioning new nodes.\n&amp;quot;);
    m_node_prov_setup_started = false;
    hal_led_pin_set(APP_CONFIGURATION_LED, 0);
}

static void app_prov_success_cb(void)
{
    __LOG(LOG_SRC_APP, LOG_LEVEL_INFO, &amp;quot;Provisioning successful\n&amp;quot;);

    hal_led_pin_set(APP_PROVISIONING_LED, 0);
    hal_led_pin_set(APP_CONFIGURATION_LED, 1);

    provisioner_store();
}

static void app_prov_failed_cb(void)
{
    __LOG(LOG_SRC_APP, LOG_LEVEL_INFO, &amp;quot;Provisioning failed. Press Button 1 to retry.\n&amp;quot;);

    m_node_prov_setup_started = false;

    hal_led_pin_set(APP_PROVISIONING_LED, 0);
}


/*****************************************************************************/
/**** Model related callbacks ****/
static void app_health_event_cb(const health_client_t * p_client, const health_client_evt_t * p_event)
{
    switch (p_event-&amp;gt;type)
    {
        case HEALTH_CLIENT_EVT_TYPE_CURRENT_STATUS_RECEIVED:
            __LOG(LOG_SRC_APP,
                  LOG_LEVEL_INFO,
                  &amp;quot;Node 0x%04x alive with %u active fault(s), RSSI: %d\n&amp;quot;,
                  p_event-&amp;gt;p_meta_data-&amp;gt;src.value,
                  p_event-&amp;gt;data.fault_status.fault_array_length,
                  ((p_event-&amp;gt;p_meta_data-&amp;gt;p_core_metadata-&amp;gt;source == NRF_MESH_RX_SOURCE_SCANNER)
                       ? p_event-&amp;gt;p_meta_data-&amp;gt;p_core_metadata-&amp;gt;params.scanner.rssi
                       : 0));
            break;
        default:
            break;
    }
}

static void app_config_server_event_cb(const config_server_evt_t * p_evt)
{
    __LOG(LOG_SRC_APP, LOG_LEVEL_INFO, &amp;quot;config_server Event %d.\n&amp;quot;, p_evt-&amp;gt;type);

    if (p_evt-&amp;gt;type == CONFIG_SERVER_EVT_NODE_RESET)
    {
        /* This should never return */
        hal_device_reset(0);
    }
}

static void app_config_client_event_cb(config_client_event_type_t event_type, const config_client_event_t * p_event, uint16_t length)
{
    /* USER_NOTE: Do additional processing of config client events here if required */
    __LOG(LOG_SRC_APP, LOG_LEVEL_INFO, &amp;quot;Config client event\n&amp;quot;);

    /* Pass events to the node setup helper module for further processing */
    node_setup_config_client_event_process(event_type, p_event, length);
}


static void provisioning_start(void)
{
    __LOG(LOG_SRC_APP, LOG_LEVEL_INFO, &amp;quot;Start provisioning procedure ...\n&amp;quot;);

    prov_helper_provision_next_device();
    prov_helper_scan_start();

    hal_led_pin_set(APP_PROVISIONING_LED, 1);
}

static void provisioning_resume(void)
{
    if (!m_node_prov_setup_started)
    {
        /* If previously provisioned device is not configured. */
        if (m_nw_state.configured_devices &amp;lt; m_nw_state.provisioned_devices)
        {
            m_nw_state.provisioned_devices--;
            provisioning_start();
            m_node_prov_setup_started = true;
        }
    }
}

/** Check if all devices have been provisioned. If not, provision remaining devices.
 *  Check if all devices have been configured. If not, start configuring them.
 */
static void check_network_state(void)
{
   printf(&amp;quot; check \r\n&amp;quot;);
    if (!m_node_prov_setup_started)
    {
        /* If previously provisioned device is not configured, start node setup procedure. */
        if (m_nw_state.configured_devices &amp;lt; m_nw_state.provisioned_devices)
        {
            /* Execute configuration */
            __LOG(LOG_SRC_APP, LOG_LEVEL_INFO, &amp;quot;Waiting for provisioned node to be configured ...\n&amp;quot;);

            node_setup_start(m_nw_state.last_device_address, PROVISIONER_RETRY_COUNT,
                            m_nw_state.appkey, APPKEY_INDEX, NETKEY_INDEX, m_nw_state.current_uri);

            hal_led_pin_set(APP_CONFIGURATION_LED, 1);
        }
        else
        {
            provisioning_start();
        }

        m_node_prov_setup_started = true;
    }
    else
    {
        __LOG(LOG_SRC_APP, LOG_LEVEL_INFO, &amp;quot;Waiting for previous procedure to finish ...\n&amp;quot;);
    }
}

static void app_mesh_core_event_cb (const nrf_mesh_evt_t * p_evt)
{
    /* USER_NOTE: User can insert mesh core event processing here */
    switch(p_evt-&amp;gt;type)
    {
        /* Start user application specific functions only when stack is enabled */
        case NRF_MESH_EVT_ENABLED:
            __LOG(LOG_SRC_APP, LOG_LEVEL_DBG1, &amp;quot;Mesh evt: NRF_MESH_EVT_ENABLED\n&amp;quot;);
#if (PERSISTENT_STORAGE)
            /* Mesh stack initialization has been completed */
            app_start();
#endif
            break;

        case NRF_MESH_EVT_CONFIG_LOAD_FAILURE:
            if (p_evt-&amp;gt;params.config_load_failure.id.file == MESH_APP_FILE_ID)
            {
                __LOG(LOG_SRC_APP, LOG_LEVEL_INFO, &amp;quot;Persistent provisioner data was corrupted. Set default values. \n&amp;quot;);
                /* Clear and set default values. */
                memset(&amp;amp;m_nw_state, 0x00, sizeof(m_nw_state));
            }
            break;

        default:
            break;
    }
}

/* Binds the local models correctly with the desired keys */
void app_default_models_bind_setup(void)
{
    /* Bind health client to App key, and configure publication key */
    ERROR_CHECK(access_model_application_bind(m_dev_handles.m_health_client_instance.model_handle, m_dev_handles.m_appkey_handle));
    ERROR_CHECK(access_model_publish_application_set(m_dev_handles.m_health_client_instance.model_handle, m_dev_handles.m_appkey_handle));

    /* Bind self-config server to the self device key */
    ERROR_CHECK(config_server_bind(m_dev_handles.m_self_devkey_handle));
}

static void node_reset(void)
{
    __LOG(LOG_SRC_APP, LOG_LEVEL_INFO, &amp;quot;----- Node reset  -----\n&amp;quot;);

    hal_led_blink_ms(HAL_LED_MASK, LED_BLINK_INTERVAL_MS, LED_BLINK_CNT_RESET);
    /* This function may return if there are ongoing flash operations. */
    mesh_stack_device_reset();
}

#if NRF_MESH_LOG_ENABLE
static const char m_usage_string[] =
    &amp;quot;\n&amp;quot;
    &amp;quot;\t\t--------------------------------------------------------------------------------\n&amp;quot;
    &amp;quot;\t\t Button/RTT 1) Initiate provisioning and configuration of unprovisioned devices.\n&amp;quot;
    &amp;quot;\t\t Button/RTT 4) Clear all the states to reset the node.\n&amp;quot;
    &amp;quot;\t\t--------------------------------------------------------------------------------\n&amp;quot;;
#endif

static void button_event_handler(uint32_t button_number)
{
    /* Increase button number because the buttons on the board is marked with 1 to 4 */
    button_number++;
    __LOG(LOG_SRC_APP, LOG_LEVEL_INFO, &amp;quot;Button %u pressed\n&amp;quot;, button_number);
    switch (button_number)
    {
        case 1:
        {
            /* Check if all devices have been provisioned or not */
            check_network_state();
            break;
        }

        case 2:
        {
            provisioning_resume();
            break;
        }

        /* Initiate node reset */
        case 4:
        {
            if (mesh_stack_is_device_provisioned())
            {
                /* Clear all the states to reset the node. */
                provisioner_invalidate();
                mesh_stack_config_clear();
            }
            node_reset();
            break;
        }

        default:
            __LOG(LOG_SRC_APP, LOG_LEVEL_INFO, m_usage_string);
            break;
    }
}

//#if 0
static void app_rtt_input_handler(int key)
{
    if (key &amp;gt;= &amp;#39;1&amp;#39; &amp;amp;&amp;amp; key &amp;lt;= &amp;#39;4&amp;#39;)
    {
        uint32_t button_number = key - &amp;#39;1&amp;#39;;
        button_event_handler(button_number);
    }
    else
    {
        __LOG(LOG_SRC_APP, LOG_LEVEL_INFO, m_usage_string);
    }
}
//#endif



#if 0
static void app_uart_input_handler(int key)
{
    if (key &amp;gt;= &amp;#39;1&amp;#39; &amp;amp;&amp;amp; key &amp;lt;= &amp;#39;4&amp;#39;)
    {
       // uint32_t button_number = key - &amp;#39;1&amp;#39;;
        uart_event_handler(key);
    }
    else
    {
        __LOG(LOG_SRC_APP, LOG_LEVEL_INFO, m_usage_string);
    }
}
#endif



void models_init_cb(void)
{
    __LOG(LOG_SRC_APP, LOG_LEVEL_INFO, &amp;quot;Initializing and adding models\n&amp;quot;);
    m_dev_handles.m_netkey_handle = DSM_HANDLE_INVALID;
    m_dev_handles.m_appkey_handle = DSM_HANDLE_INVALID;
    m_dev_handles.m_self_devkey_handle = DSM_HANDLE_INVALID;

    /* This app requires following models :
     * config client : To be able to configure other devices
     * health client : To be able to interact with other health servers */
    ERROR_CHECK(config_client_init(app_config_client_event_cb));
    ERROR_CHECK(health_client_init(&amp;amp;m_dev_handles.m_health_client_instance, 0, app_health_event_cb));
}

static void mesh_init(void)
{
    bool device_provisioned;
    mesh_stack_init_params_t init_params =
    {
        .core.irq_priority       = NRF_MESH_IRQ_PRIORITY_LOWEST,
        .core.lfclksrc           = DEV_BOARD_LF_CLK_CFG,
        .models.models_init_cb   = models_init_cb,
        .models.config_server_cb = app_config_server_event_cb
    };

    nrf_mesh_evt_handler_add(&amp;amp;m_mesh_core_event_handler);
    uint32_t status = mesh_stack_init(&amp;amp;init_params, &amp;amp;device_provisioned);
    switch (status)
    {
        case NRF_ERROR_INVALID_DATA:
            __LOG(LOG_SRC_APP, LOG_LEVEL_INFO, &amp;quot;Data in the persistent memory was corrupted.\n&amp;quot;);
            __LOG(LOG_SRC_APP, LOG_LEVEL_INFO, &amp;quot;Reboot device before starting of the provisioning process.\n&amp;quot;);
            break;
        case NRF_SUCCESS:
            break;
        default:
            ERROR_CHECK(status);
    }

    if (status == NRF_SUCCESS)
    {
        /* Initialize the provisioner */
        mesh_provisioner_init_params_t m_prov_helper_init_info =
        {
            .p_dev_data = &amp;amp;m_dev_handles,
            .p_nw_data = &amp;amp;m_nw_state,
            .netkey_idx = NETKEY_INDEX,
            .attention_duration_s = ATTENTION_DURATION_S,
            .p_data_store_cb  = app_data_store_cb,
            .p_prov_success_cb = app_prov_success_cb,
            .p_prov_failed_cb = app_prov_failed_cb
        };
        prov_helper_init(&amp;amp;m_prov_helper_init_info);

        if (!device_provisioned)
        {
            __LOG(LOG_SRC_APP, LOG_LEVEL_INFO, &amp;quot;Setup defaults: Adding keys, addresses, and bindings \n&amp;quot;);

            prov_helper_provision_self();
            app_default_models_bind_setup();
            app_data_store_cb();
        }
        else
        {
            __LOG(LOG_SRC_APP, LOG_LEVEL_INFO, &amp;quot;Restored: Handles \n&amp;quot;);
            prov_helper_device_handles_load();
        }

        node_setup_cb_set(app_config_successful_cb, app_config_failed_cb);
    }
}





/**@brief   Function for handling app_uart events.
 *
 * @details This function will receive a single character from the app_uart module and append it to
 *          a string. The string will be be sent over BLE when the last character received was a
 *          &amp;#39;new line&amp;#39; &amp;#39;\n&amp;#39; (hex 0x0A) or if the string has reached the maximum data length.
 */
/**@snippet [Handling the data received over UART] */
void uart_event_handler(app_uart_evt_t * p_event)
{
    static uint8_t data_array[244];
    static uint8_t index = 0;
   // static uint8_t val = 0;
    uint32_t       err_code;

     //printf(&amp;quot;\r\nUART started uart event handler.\r\n&amp;quot;);
    switch (p_event-&amp;gt;evt_type)
    {
        case APP_UART_DATA_READY:
            UNUSED_VARIABLE(app_uart_get(&amp;amp;data_array[index]));
            printf(&amp;quot;Data array in switch %c\r\n&amp;quot;,data_array[index]);

            index++;

             if ( data_array[index - 1] == &amp;#39;1&amp;#39;)
            {
               printf(&amp;quot;Sucess pressed 1 \r\n&amp;quot;);
               check_network_state();
               index = 0;
               memset(data_array[index], 0 , sizeof(data_array[index]));

            }

            if ( data_array[index - 1] == &amp;#39;2&amp;#39;)
            {
               printf(&amp;quot;Sucess pressed 2\r\n&amp;quot;);
               provisioning_resume();
               index = 0;
               memset(data_array[index], 0 , sizeof(data_array[index]));

            }

             if ( data_array[index - 1] == &amp;#39;4&amp;#39;)
              {
               printf(&amp;quot;Sucess pressed 4 \r\n&amp;quot;);
             
                 if (mesh_stack_is_device_provisioned())
                 {
                   /* Clear all the states to reset the node. */
                   provisioner_invalidate();
                   mesh_stack_config_clear();
                }
               node_reset();
               index = 0;
               memset(data_array[index], 0 , sizeof(data_array[index]));

              }

                
            #if 0
            if ( data_array[index - 1] == &amp;#39;;&amp;#39;)
            {
               printf(&amp;quot;sucess \r\n&amp;quot;);
               index = 0;
               memset(data_array[index], 0 , sizeof(data_array[index]));

            }
            #endif

                
            break;

        case APP_UART_COMMUNICATION_ERROR:
            APP_ERROR_HANDLER(p_event-&amp;gt;data.error_communication);
            break;

        case APP_UART_FIFO_ERROR:
            APP_ERROR_HANDLER(p_event-&amp;gt;data.error_code);
            break;

        default:
            break;
    }
  }




#if 0
void uart_event_handler(app_uart_evt_t * p_event)
{
  //   printf(&amp;quot;\r\nUART started uart event handler provisioner code .\r\n&amp;quot;);

       while (true)
    {
        uint8_t cr;
        while (app_uart_get(&amp;amp;cr) != NRF_SUCCESS);
        printf(&amp;quot;\r\n cr \r\n %d&amp;quot;,cr);
        while (app_uart_put(cr) != NRF_SUCCESS);
 
        if (cr == &amp;#39;1&amp;#39;)
        {
            printf(&amp;quot; \r\n 1 pressed \r\n&amp;quot;);
            check_network_state();

            while (true)
            {
                // Do nothing.
            }
        if (cr == &amp;#39;2&amp;#39;)
        {
        printf(&amp;quot;\r\n 2 pressed &amp;quot;);
        provisioning_resume();

         while (true)
            {
                // Do nothing.
            }

        }
        if (cr == &amp;#39;4&amp;#39;)
        {
            printf(&amp;quot;\r\n 4 pressed \r\n&amp;quot;);
            if (mesh_stack_is_device_provisioned())
            {
                /* Clear all the states to reset the node. */
                provisioner_invalidate();
                mesh_stack_config_clear();
            }
            node_reset();

             while (true)
            {
                // Do nothing.
            }

        }
        else
        {
        printf(&amp;quot;\r\n else\r\n&amp;quot;);
        }
         

        }
    }
    
#if 0    
    uint32_t i;
    switch(i)
    {
    case 1:
    {
     printf(&amp;quot;\r\n Pressing 1 for scanning the unprovisioned nodes Uart event handler provisioner code .\r\n&amp;quot;);
     check_network_state();
     break;

    }
    
    case 2: 

      {
            provisioning_resume();
            break;
       }

    case 4:
         {
            printf(&amp;quot;\r\n Pressing 4 for resetting the provisioned nodes Uart event handler provisioner code .\r\n&amp;quot;);
             if (mesh_stack_is_device_provisioned())
            {
                /* Clear all the states to reset the node. */
                provisioner_invalidate();
                mesh_stack_config_clear();
            }
            node_reset();
            break;
        }
    break;
    default:

    }
#endif
}
#endif // for uart event handler 



#if 0
void uart_event_handle(app_uart_evt_t * p_event)
{
 //printf(&amp;quot;\r\nUART started uart event handler provisioner code .\r\n&amp;quot;);
}
#endif




/**@brief  Function for initializing the UART module.
 */
/**@snippet [UART Initialization] */
static void uart_init(void)
{
    uint32_t                     err_code;
    app_uart_comm_params_t const comm_params =
    {
        .rx_pin_no    = RX_PIN_NUMBER,
        .tx_pin_no    = TX_PIN_NUMBER,
        .rts_pin_no   = RTS_PIN_NUMBER,
        .cts_pin_no   = CTS_PIN_NUMBER,
        .flow_control = APP_UART_FLOW_CONTROL_DISABLED,
        .use_parity   = false,
#if defined (UART_PRESENT)
        .baud_rate    = NRF_UART_BAUDRATE_115200
#else
        .baud_rate    = NRF_UARTE_BAUDRATE_115200
#endif
    };

  APP_UART_FIFO_INIT(&amp;amp;comm_params,
                       UART_RX_BUF_SIZE,
                       UART_TX_BUF_SIZE,
                       uart_event_handler,
                       APP_IRQ_PRIORITY_LOWEST,
                       err_code);
  APP_ERROR_CHECK(err_code);
}
/**@snippet [UART Initialization] */








static void initialize(void)
{
    
      uart_init();
   
   // __LOG_INIT(LOG_SRC_APP | LOG_SRC_ACCESS, LOG_LEVEL_INFO, LOG_CALLBACK_DEFAULT);
    __LOG_INIT(LOG_SRC_APP | LOG_SRC_FRIEND, LOG_LEVEL_DBG1, log_callback_rtt);
    __LOG(LOG_SRC_APP, LOG_LEVEL_INFO, &amp;quot;----- BLE Mesh Static Provisioner Demo -----\n&amp;quot;);

    ERROR_CHECK(app_timer_init());
    hal_leds_init();

#if BUTTON_BOARD
    ERROR_CHECK(hal_buttons_init(button_event_handler));
#endif

    ble_stack_init();
    mesh_init();
    node_setup_uri_check();
}

static void app_start(void)
{
    __LOG(LOG_SRC_APP, LOG_LEVEL_INFO, &amp;quot;Starting application ...\n&amp;quot;);
    __LOG(LOG_SRC_APP, LOG_LEVEL_INFO, &amp;quot;Provisioned Nodes: %d, Configured Nodes: %d\n&amp;quot;,
          m_nw_state.provisioned_devices, m_nw_state.configured_devices);
    __LOG_XB(LOG_SRC_APP, LOG_LEVEL_INFO, &amp;quot;Dev key &amp;quot;, m_nw_state.self_devkey, NRF_MESH_KEY_SIZE);
    __LOG_XB(LOG_SRC_APP, LOG_LEVEL_INFO, &amp;quot;Net key &amp;quot;, m_nw_state.netkey, NRF_MESH_KEY_SIZE);
    __LOG_XB(LOG_SRC_APP, LOG_LEVEL_INFO, &amp;quot;App key &amp;quot;, m_nw_state.appkey, NRF_MESH_KEY_SIZE);
    __LOG(LOG_SRC_APP, LOG_LEVEL_INFO, &amp;quot;Press Button/RTT 1 to start provisioning and configuration process. \n&amp;quot;);
}

static void start(void)
{
    rtt_input_enable(app_rtt_input_handler, RTT_INPUT_POLL_PERIOD_MS);
   // rtt_input_enable(app_uart_input_handler, RTT_INPUT_POLL_PERIOD_MS);
    __LOG(LOG_SRC_APP, LOG_LEVEL_INFO, &amp;quot;&amp;lt;start&amp;gt; \n&amp;quot;);

    ERROR_CHECK(mesh_stack_start());

#if (!PERSISTENT_STORAGE)
    app_start();
#endif

    __LOG(LOG_SRC_APP, LOG_LEVEL_INFO, m_usage_string);

    hal_led_mask_set(HAL_LED_MASK, LED_MASK_STATE_OFF);
    hal_led_blink_ms(HAL_LED_MASK, LED_BLINK_INTERVAL_MS, LED_BLINK_CNT_START);
}



/**@brief Function for initializing the nrf log module.
 */
 #if 0
static void log1_init(void)
{
    ret_code_t err_code = NRF_LOG_INIT(NULL);
    APP_ERROR_CHECK(err_code);

    NRF_LOG_DEFAULT_BACKENDS_INIT();
}
#endif








#if 0
void my_uart_callback(nrfx_uarte_event_t const * p_event,
                      void *                     p_context)
{
    //TODO: Handle &amp;#39;p_event&amp;#39;
}
#endif

int main(void)
{
    

   // nrfx_uarte_t m_uart = NRFX_UARTE_INSTANCE(0); 
    //nrfx_uarte_config_t m_uart_config = NRFX_UARTE_DEFAULT_CONFIG;
    
   // nrfx_uarte_init(&amp;amp;m_uart, &amp;amp;m_uart_config, my_uart_callback);



    // uart_init();
     //log1_init();

 //   ret_code_t err_code = NRF_LOG_INIT(NULL);
  //  APP_ERROR_CHECK(err_code);

    // NRF_LOG_DEFAULT_BACKENDS_INIT();

    initialize();
    printf(&amp;quot;\r\nUART started main provisioner code .\r\n&amp;quot;);
    start();

    for (;;)
    {
        (void)sd_app_evt_wait();
    }
}
&lt;/pre&gt;&lt;/p&gt;
&lt;p&gt;&lt;/p&gt;
&lt;p&gt;&lt;/p&gt;
&lt;p&gt;Thanks &amp;amp; Regards,&lt;/p&gt;
&lt;p&gt;Ela&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: How to send data to UART for the provisioner example of mesh sdk.</title><link>https://devzone.nordicsemi.com/thread/300022?ContentTypeID=1</link><pubDate>Tue, 16 Mar 2021 08:40:42 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:4f2e553c-8ec3-4a26-9c61-587e12e95c97</guid><dc:creator>Ela</dc:creator><description>&lt;p&gt;Hi Mttrinh,&lt;/p&gt;
&lt;p&gt;&lt;/p&gt;
&lt;p&gt;1) Yes i have copied the ble_app_uart_coexist folder into ble_peripheral folder and set the MESH_ROOT in global macros to the mesh sdk path.&lt;/p&gt;
&lt;p&gt;2) In UART example there is not uart_event_handle function. I have implemented the uart_event_handler as per my application, attaching that code :&amp;nbsp;&lt;/p&gt;
&lt;p&gt;&lt;/p&gt;
&lt;p&gt;&lt;pre class="ui-code" data-mode="text"&gt;void uart_event_handler(app_uart_evt_t * p_event)
{
    static uint8_t data_array[244];
    static uint8_t index = 0;
   // static uint8_t val = 0;
    uint32_t       err_code;

     //printf(&amp;quot;\r\nUART started uart event handler.\r\n&amp;quot;);
    switch (p_event-&amp;gt;evt_type)
    {
        case APP_UART_DATA_READY:
            UNUSED_VARIABLE(app_uart_get(&amp;amp;data_array[index]));
            printf(&amp;quot;Data array in switch %c\r\n&amp;quot;,data_array[index]);

            index++;

             if ( data_array[index - 1] == &amp;#39;1&amp;#39;)
            {
               printf(&amp;quot;Sucess pressed 1 \r\n&amp;quot;);
               check_network_state();
               index = 0;
               memset(data_array[index], 0 , sizeof(data_array[index]));

            }

            if ( data_array[index - 1] == &amp;#39;2&amp;#39;)
            {
               printf(&amp;quot;Sucess pressed 2\r\n&amp;quot;);
               provisioning_resume();
               index = 0;
               memset(data_array[index], 0 , sizeof(data_array[index]));

            }

             if ( data_array[index - 1] == &amp;#39;4&amp;#39;)
              {
               printf(&amp;quot;Sucess pressed 4 \r\n&amp;quot;);
             
                 if (mesh_stack_is_device_provisioned())
                 {
                   /* Clear all the states to reset the node. */
                   provisioner_invalidate();
                   mesh_stack_config_clear();
                }
               node_reset();
               index = 0;
               memset(data_array[index], 0 , sizeof(data_array[index]));

              }

                
            #if 0
            if ( data_array[index - 1] == &amp;#39;;&amp;#39;)
            {
               printf(&amp;quot;sucess \r\n&amp;quot;);
               index = 0;
               memset(data_array[index], 0 , sizeof(data_array[index]));

            }
            #endif

                
            break;

        case APP_UART_COMMUNICATION_ERROR:
            APP_ERROR_HANDLER(p_event-&amp;gt;data.error_communication);
            break;

        case APP_UART_FIFO_ERROR:
            APP_ERROR_HANDLER(p_event-&amp;gt;data.error_code);
            break;

        default:
            break;
    }
  }&lt;/pre&gt;&lt;/p&gt;
&lt;p&gt;Is this the right way to do this? As i am not able to get command response after sometime. If i am pressing 4 nothing is happening some random letter is getting printed. If i am pressing 2 not able to recive back any command. What i am missing here, can you please let me know?&lt;/p&gt;
&lt;p&gt;&lt;/p&gt;
&lt;p&gt;Thanks &amp;amp; Regards,&lt;/p&gt;
&lt;p&gt;Ela&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: How to send data to UART for the provisioner example of mesh sdk.</title><link>https://devzone.nordicsemi.com/thread/299886?ContentTypeID=1</link><pubDate>Mon, 15 Mar 2021 15:39:12 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:3c3d78b7-e36b-4601-980a-420af8ccbab8</guid><dc:creator>Mttrinh</dc:creator><description>&lt;p&gt;Hi,&lt;/p&gt;
&lt;p&gt;1) Did you copy the coexist folder into the&amp;nbsp;&lt;code&gt;examples/ble_peripheral&lt;/code&gt;&lt;span&gt;&amp;nbsp;&lt;/span&gt;&lt;span&gt;folder at your nRF5 SDK installation path? Did you add the MESH_ROOT macro to the Global macros in SES?&lt;/span&gt;&lt;/p&gt;
&lt;p&gt;&lt;span&gt;2) The function is called&amp;nbsp;uart_event_handle in the UART example.&amp;nbsp;ble_nus_data_send() is the function that sends the data over BLE, you can remove this.&lt;/span&gt;&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: How to send data to UART for the provisioner example of mesh sdk.</title><link>https://devzone.nordicsemi.com/thread/299697?ContentTypeID=1</link><pubDate>Mon, 15 Mar 2021 09:32:06 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:ef47abfa-beae-4f01-9395-1d928dde466c</guid><dc:creator>Ela</dc:creator><description>&lt;p&gt;Hi Mtrrinh,&lt;/p&gt;
&lt;p&gt;In uart example of nrf sdk, there is no uart_event_handler, there is uart_error_handler. In ble_app_uart example of nrf sdk there is uart_event_handler where it is sending uart recieved data over ble, can you tell me how to not include the sending data over ble in that event handler.&lt;/p&gt;
&lt;p&gt;Thanks &amp;amp; Regards,&lt;/p&gt;
&lt;p&gt;Ela&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: How to send data to UART for the provisioner example of mesh sdk.</title><link>https://devzone.nordicsemi.com/thread/299688?ContentTypeID=1</link><pubDate>Mon, 15 Mar 2021 08:56:41 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:d3534782-25ce-492a-b782-512aa4547d63</guid><dc:creator>Ela</dc:creator><description>&lt;p&gt;Hi Mttrinh,&lt;/p&gt;
&lt;p&gt;&lt;/p&gt;
&lt;p&gt;1) I am attaching the compiling error i got:&lt;/p&gt;
&lt;p&gt;&lt;pre class="ui-code" data-mode="text"&gt;Rebuilding &amp;#39;ble_app_uart_pca10040_s132&amp;#39; from solution &amp;#39;ble_app_uart_pca10040_s132&amp;#39; in configuration &amp;#39;Release&amp;#39;
  Assembling &amp;#39;thumb_crt0.s&amp;#39;
  Compiling &amp;#39;nrf_log_backend_rtt.c&amp;#39;
  Compiling &amp;#39;nrf_log_backend_serial.c&amp;#39;
  Compiling &amp;#39;nrf_log_default_backends.c&amp;#39;
  Compiling &amp;#39;nrf_log_frontend.c&amp;#39;
  Compiling &amp;#39;nrf_log_str_formatter.c&amp;#39;
  Compiling &amp;#39;app_button.c&amp;#39;
  Compiling &amp;#39;app_error.c&amp;#39;
  Compiling &amp;#39;app_error_handler_gcc.c&amp;#39;
  Compiling &amp;#39;app_error_weak.c&amp;#39;
  Compiling &amp;#39;app_fifo.c&amp;#39;
  Compiling &amp;#39;app_scheduler.c&amp;#39;
  Compiling &amp;#39;hardfault_implementation.c&amp;#39;
  Compiling &amp;#39;app_util_platform.c&amp;#39;
  Compiling &amp;#39;app_uart_fifo.c&amp;#39;
  Compiling &amp;#39;nrf_atfifo.c&amp;#39;
  Compiling &amp;#39;nrf_assert.c&amp;#39;
  Compiling &amp;#39;nrf_atflags.c&amp;#39;
  Compiling &amp;#39;nrf_atomic.c&amp;#39;
  Compiling &amp;#39;nrf_fprintf.c&amp;#39;
  Compiling &amp;#39;nrf_balloc.c&amp;#39;
  Compiling &amp;#39;nrf_memobj.c&amp;#39;
  Compiling &amp;#39;nrf_fprintf_format.c&amp;#39;
  Compiling &amp;#39;nrf_pwr_mgmt.c&amp;#39;
  Compiling &amp;#39;nrf_ringbuf.c&amp;#39;
  Compiling &amp;#39;nrf_section_iter.c&amp;#39;
  Compiling &amp;#39;nrf_sortlist.c&amp;#39;
  Compiling &amp;#39;nrf_strerror.c&amp;#39;
  Compiling &amp;#39;retarget.c&amp;#39;
  Assembling &amp;#39;ses_startup_nrf52.s&amp;#39;
  Compiling &amp;#39;system_nrf52.c&amp;#39;
  Assembling &amp;#39;ses_startup_nrf_common.s&amp;#39;
  Compiling &amp;#39;nrf_drv_clock.c&amp;#39;
  Compiling &amp;#39;boards.c&amp;#39;
  Compiling &amp;#39;nrf_drv_uart.c&amp;#39;
  Compiling &amp;#39;nrfx_atomic.c&amp;#39;
  Compiling &amp;#39;nrfx_clock.c&amp;#39;
  Compiling &amp;#39;nrfx_gpiote.c&amp;#39;
  Compiling &amp;#39;nrfx_prs.c&amp;#39;
  Compiling &amp;#39;nrfx_uart.c&amp;#39;
  Compiling &amp;#39;nrfx_uarte.c&amp;#39;
  Compiling &amp;#39;bsp.c&amp;#39;
  Compiling &amp;#39;bsp_btn_ble.c&amp;#39;
  Compiling &amp;#39;main.c&amp;#39;
  Compiling &amp;#39;SEGGER_RTT.c&amp;#39;
  Compiling &amp;#39;mesh_main.c&amp;#39;
  Compiling &amp;#39;SEGGER_RTT_Syscalls_SES.c&amp;#39;
  Compiling &amp;#39;SEGGER_RTT_printf.c&amp;#39;
  Compiling &amp;#39;ble_advertising.c&amp;#39;
  Compiling &amp;#39;ble_advdata.c&amp;#39;
  Compiling &amp;#39;ble_conn_params.c&amp;#39;
  Compiling &amp;#39;ble_conn_state.c&amp;#39;
  Compiling &amp;#39;ble_link_ctx_manager.c&amp;#39;
  Compiling &amp;#39;ble_srv_common.c&amp;#39;
  Compiling &amp;#39;nrf_ble_gatt.c&amp;#39;
  Compiling &amp;#39;nrf_ble_qwr.c&amp;#39;
  Compiling &amp;#39;utf.c&amp;#39;
  Compiling &amp;#39;ble_nus.c&amp;#39;
  Compiling &amp;#39;nrf_sdh.c&amp;#39;
  Compiling &amp;#39;nrf_sdh_ble.c&amp;#39;
  Compiling &amp;#39;model_common.c&amp;#39;
  Compiling &amp;#39;nrf_sdh_soc.c&amp;#39;
  Compiling &amp;#39;config_server.c&amp;#39;
  Compiling &amp;#39;composition_data.c&amp;#39;
  Compiling &amp;#39;health_server.c&amp;#39;
  Compiling &amp;#39;packed_index_list.c&amp;#39;
  Compiling &amp;#39;generic_onoff_client.c&amp;#39;
  Compiling &amp;#39;app_timer_mesh.c&amp;#39;
  Compiling &amp;#39;uECC.c&amp;#39;
  Compiling &amp;#39;app_timer_workaround.c&amp;#39;
  Compiling &amp;#39;assertion_handler_weak.c&amp;#39;
  Compiling &amp;#39;mesh_provisionee.c&amp;#39;
  Compiling &amp;#39;mesh_app_utils.c&amp;#39;
  Compiling &amp;#39;mesh_adv.c&amp;#39;
  Generating linker script &amp;#39;ble_app_uart_pca10040_s132.ld&amp;#39;
  Linking ble_app_uart_pca10040_s132.elf
    Output/Release/Obj/ble_app_uart_pca10040_s132/mesh_main.o: in function `app_generic_onoff_client_status_cb&amp;#39;:
    undefined reference to `log_printf&amp;#39;
    /home/ekta/Desktop/26_feb_21/SmartProducts/Firmware/3rdParty/nRF5/nRF5SDK/examples/ble_peripheral/ble_app_uart_coexist/mesh_main.c:182: undefined reference to `log_printf&amp;#39;
    /home/ekta/Desktop/26_feb_21/SmartProducts/Firmware/3rdParty/nRF5/nRF5SDK/examples/ble_peripheral/ble_app_uart_coexist/mesh_main.c:182: undefined reference to `g_log_dbg_msk&amp;#39;
    /home/ekta/Desktop/26_feb_21/SmartProducts/Firmware/3rdParty/nRF5/nRF5SDK/examples/ble_peripheral/ble_app_uart_coexist/mesh_main.c:182: undefined reference to `g_log_dbg_lvl&amp;#39;
    Output/Release/Obj/ble_app_uart_pca10040_s132/mesh_main.o: in function `mesh_soc_evt_handler&amp;#39;:
    undefined reference to `nrf_mesh_on_sd_evt&amp;#39;
    Output/Release/Obj/ble_app_uart_pca10040_s132/mesh_main.o: in function `node_reset&amp;#39;:
    undefined reference to `mesh_stack_device_reset&amp;#39;
    Output/Release/Obj/ble_app_uart_pca10040_s132/mesh_main.o: in function `unicast_address_print&amp;#39;:
    undefined reference to `dsm_local_unicast_addresses_get&amp;#39;
    /home/ekta/Desktop/26_feb_21/SmartProducts/Firmware/3rdParty/nRF5/nRF5SDK/examples/ble_peripheral/ble_app_uart_coexist/mesh_main.c:126: undefined reference to `log_printf&amp;#39;
    /home/ekta/Desktop/26_feb_21/SmartProducts/Firmware/3rdParty/nRF5/nRF5SDK/examples/ble_peripheral/ble_app_uart_coexist/mesh_main.c:126: undefined reference to `g_log_dbg_msk&amp;#39;
    /home/ekta/Desktop/26_feb_21/SmartProducts/Firmware/3rdParty/nRF5/nRF5SDK/examples/ble_peripheral/ble_app_uart_coexist/mesh_main.c:126: undefined reference to `g_log_dbg_lvl&amp;#39;
    Output/Release/Obj/ble_app_uart_pca10040_s132/mesh_main.o: in function `mesh_main_button_event_handler&amp;#39;:
    undefined reference to `log_printf&amp;#39;
    /home/ekta/Desktop/26_feb_21/SmartProducts/Firmware/3rdParty/nRF5/nRF5SDK/examples/ble_peripheral/ble_app_uart_coexist/mesh_main.c:241: undefined reference to `access_model_reliable_cancel&amp;#39;
    /home/ekta/Desktop/26_feb_21/SmartProducts/Firmware/3rdParty/nRF5/nRF5SDK/examples/ble_peripheral/ble_app_uart_coexist/mesh_main.c:279: undefined reference to `g_log_dbg_msk&amp;#39;
    /home/ekta/Desktop/26_feb_21/SmartProducts/Firmware/3rdParty/nRF5/nRF5SDK/examples/ble_peripheral/ble_app_uart_coexist/mesh_main.c:279: undefined reference to `g_log_dbg_lvl&amp;#39;
    Output/Release/Obj/ble_app_uart_pca10040_s132/mesh_main.o: in function `mesh_init&amp;#39;:
    undefined reference to `mesh_stack_init&amp;#39;
    /home/ekta/Desktop/26_feb_21/SmartProducts/Firmware/3rdParty/nRF5/nRF5SDK/examples/ble_peripheral/ble_app_uart_coexist/mesh_main.c:311: undefined reference to `log_printf&amp;#39;
    /home/ekta/Desktop/26_feb_21/SmartProducts/Firmware/3rdParty/nRF5/nRF5SDK/examples/ble_peripheral/ble_app_uart_coexist/mesh_main.c:312: undefined reference to `log_printf&amp;#39;
    /home/ekta/Desktop/26_feb_21/SmartProducts/Firmware/3rdParty/nRF5/nRF5SDK/examples/ble_peripheral/ble_app_uart_coexist/mesh_main.c:319: undefined reference to `g_log_dbg_msk&amp;#39;
    /home/ekta/Desktop/26_feb_21/SmartProducts/Firmware/3rdParty/nRF5/nRF5SDK/examples/ble_peripheral/ble_app_uart_coexist/mesh_main.c:319: undefined reference to `g_log_dbg_lvl&amp;#39;
    Output/Release/Obj/ble_app_uart_pca10040_s132/mesh_main.o: in function `mesh_main_initialize&amp;#39;:
    undefined reference to `log_init&amp;#39;
    /home/ekta/Desktop/26_feb_21/SmartProducts/Firmware/3rdParty/nRF5/nRF5SDK/examples/ble_peripheral/ble_app_uart_coexist/mesh_main.c:325: undefined reference to `log_callback_rtt&amp;#39;
    Output/Release/Obj/ble_app_uart_pca10040_s132/mesh_main.o: in function `mesh_main_start&amp;#39;:
    undefined reference to `nrf_mesh_configure_device_uuid_get&amp;#39;
    /home/ekta/Desktop/26_feb_21/SmartProducts/Firmware/3rdParty/nRF5/nRF5SDK/examples/ble_peripheral/ble_app_uart_coexist/mesh_main.c:353: undefined reference to `mesh_stack_start&amp;#39;
    Output/Release/Obj/ble_app_uart_pca10040_s132/health_server.o: in function `health_server_setter&amp;#39;:
    undefined reference to `access_model_publish_period_divisor_set&amp;#39;
    Output/Release/Obj/ble_app_uart_pca10040_s132/generic_onoff_client.o: in function `generic_onoff_client_init&amp;#39;:
    undefined reference to `access_model_add&amp;#39;
    /home/ekta/Desktop/26_feb_21/SmartProducts/Firmware/3rdParty/nRF5/nrf5MeshSDK/models/model_spec/generic_onoff/src/generic_onoff_client.c:156: undefined reference to `access_model_subscription_list_alloc&amp;#39;
    Output/Release/Obj/ble_app_uart_pca10040_s132/generic_onoff_client.o: in function `generic_onoff_client_set&amp;#39;:
    undefined reference to `access_reliable_model_is_free&amp;#39;
    Output/Release/Obj/ble_app_uart_pca10040_s132/generic_onoff_client.o: in function `message_create&amp;#39;:
    undefined reference to `nrf_mesh_unique_token_get&amp;#39;
    Output/Release/Obj/ble_app_uart_pca10040_s132/generic_onoff_client.o: in function `generic_onoff_client_set&amp;#39;:
    undefined reference to `access_model_reliable_publish&amp;#39;
    Output/Release/Obj/ble_app_uart_pca10040_s132/generic_onoff_client.o: in function `message_create&amp;#39;:
    undefined reference to `nrf_mesh_unique_token_get&amp;#39;
    Output/Release/Obj/ble_app_uart_pca10040_s132/generic_onoff_client.o: in function `generic_onoff_client_set_unack&amp;#39;:
    undefined reference to `access_model_publish&amp;#39;
    Output/Release/Obj/ble_app_uart_pca10040_s132/mesh_provisionee.o: in function `provisionee_start&amp;#39;:
    undefined reference to `nrf_mesh_prov_generate_keys&amp;#39;
    /home/ekta/Desktop/26_feb_21/SmartProducts/Firmware/3rdParty/nRF5/nrf5MeshSDK/examples/common/src/mesh_provisionee.c:226: undefined reference to `nrf_mesh_prov_listen&amp;#39;
    Output/Release/Obj/ble_app_uart_pca10040_s132/mesh_provisionee.o: in function `prov_evt_handler&amp;#39;:
    undefined reference to `nrf_mesh_prov_auth_data_provide&amp;#39;
    /home/ekta/Desktop/26_feb_21/SmartProducts/Firmware/3rdParty/nRF5/nrf5MeshSDK/examples/common/src/mesh_provisionee.c:285: undefined reference to `mesh_stack_provisioning_data_store&amp;#39;
    Output/Release/Obj/ble_app_uart_pca10040_s132/mesh_provisionee.o: in function `mesh_provisionee_prov_start&amp;#39;:
    undefined reference to `nrf_mesh_prov_init&amp;#39;
    /home/ekta/Desktop/26_feb_21/SmartProducts/Firmware/3rdParty/nRF5/nrf5MeshSDK/examples/common/src/mesh_provisionee.c:324: undefined reference to `nrf_mesh_prov_bearer_adv_interface_get&amp;#39;
    /home/ekta/Desktop/26_feb_21/SmartProducts/Firmware/3rdParty/nRF5/nrf5MeshSDK/examples/common/src/mesh_provisionee.c:324: undefined reference to `nrf_mesh_prov_bearer_add&amp;#39;
    /home/ekta/Desktop/26_feb_21/SmartProducts/Firmware/3rdParty/nRF5/nrf5MeshSDK/examples/common/src/mesh_provisionee.c:336: undefined reference to `nrf_mesh_evt_handler_add&amp;#39;
Build failed&lt;/pre&gt;&lt;/p&gt;
&lt;p&gt;&lt;/p&gt;
&lt;p&gt;2) I have implemented the uart_event_handler, i press 1 from serial terminal i am able to scan all the unprovisioned nodes and then provisioned them, when press 4 reset all the provisioned nodes, attaching the code implementation i have added :&amp;nbsp;&lt;pre class="ui-code" data-mode="text"&gt;void uart_event_handle(app_uart_evt_t * p_event)
{
  //   printf(&amp;quot;\r\nUART started uart event handler provisioner code .\r\n&amp;quot;);

       while (true)
    {
        uint8_t cr;
        while (app_uart_get(&amp;amp;cr) != NRF_SUCCESS);
        printf(&amp;quot;\r\n cr \r\n %d&amp;quot;,cr);
        while (app_uart_put(cr) != NRF_SUCCESS);
 
        if (cr == &amp;#39;1&amp;#39;)
        {
            printf(&amp;quot; \r\n 1 pressed \r\n&amp;quot;);
            check_network_state();

            while (true)
            {
                // Do nothing.
            }
        if (cr == &amp;#39;2&amp;#39;)
        {
        printf(&amp;quot;\r\n 2 pressed &amp;quot;);
        provisioning_resume();

         while (true)
            {
                // Do nothing.
            }

        }
        if (cr == &amp;#39;4&amp;#39;)
        {
            printf(&amp;quot;\r\n 4 pressed \r\n&amp;quot;);
            if (mesh_stack_is_device_provisioned())
            {
                /* Clear all the states to reset the node. */
                provisioner_invalidate();
                mesh_stack_config_clear();
            }
            node_reset();

             while (true)
            {
                // Do nothing.
            }

        }
        else
        {
        printf(&amp;quot;\r\n else\r\n&amp;quot;);
        }
         

        }
    }
    
#if 0    
    uint32_t i;
    switch(i)
    {
    case 1:
    {
     printf(&amp;quot;\r\n Pressing 1 for scanning the unprovisioned nodes Uart event handler provisioner code .\r\n&amp;quot;);
     check_network_state();
     break;

    }
    
    case 2: 

      {
            provisioning_resume();
            break;
       }

    case 4:
         {
            printf(&amp;quot;\r\n Pressing 4 for resetting the provisioned nodes Uart event handler provisioner code .\r\n&amp;quot;);
             if (mesh_stack_is_device_provisioned())
            {
                /* Clear all the states to reset the node. */
                provisioner_invalidate();
                mesh_stack_config_clear();
            }
            node_reset();
            break;
        }
    break;
    default:

    }
#endif
}&lt;/pre&gt;&lt;/p&gt;
&lt;p&gt;&lt;/p&gt;
&lt;p&gt;But here i am not able to get the desired result, is this the right way to do, if not hen how shall i do this, can you attach code implementation for my application for reference.&lt;/p&gt;
&lt;p&gt;&lt;/p&gt;
&lt;p&gt;Response to this at high priority is really a great help..&lt;/p&gt;
&lt;p&gt;&lt;/p&gt;
&lt;p&gt;Thanks &amp;amp; Regards,&lt;/p&gt;
&lt;p&gt;Ela&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: How to send data to UART for the provisioner example of mesh sdk.</title><link>https://devzone.nordicsemi.com/thread/299537?ContentTypeID=1</link><pubDate>Fri, 12 Mar 2021 16:06:26 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:28aa420a-3d84-47cb-adbe-b54d701fe4b8</guid><dc:creator>Mttrinh</dc:creator><description>&lt;p&gt;Hi,&lt;/p&gt;
[quote user="Ekta hav"] I am getting compiling errors and not able to resolve it, i have used in the same way as mentioned in the infocenter.&amp;nbsp;[/quote]
&lt;p&gt;Can you provide more details about the compiling errors? Any logs?&lt;/p&gt;
[quote user="Ekta hav"]In our provisioner example code, segger_printf.c, segger_print.c, rttinput.c these files have been used for writing or reading data to RTT. &amp;quot;SEGGER_RTT_Read&amp;quot; and &amp;quot;SEGGER_RTT_Write&amp;quot; these functions are used for getting and sending data by RTT, so can i use these functions for the same operation with UART,&amp;nbsp; i think we can not use these functions, if not then how shall we do it?[/quote]
&lt;p&gt;No, these functions are for RTT. You can&amp;#39;t use the same functions for UART.&amp;nbsp;&lt;/p&gt;
&lt;p&gt;Yes, you have to create a UART event handler that handles the incoming commands. I suggest you look at the uart_event_handler from the UART example from the nRF5 SDK. It will show you how to get data from the serial terminal. Implement something similar to&amp;nbsp;app_rtt_input_handler(), which is how the RTT input is handled,&amp;nbsp;inside the uart_event_handler to handle your inputs via UART.&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: How to send data to UART for the provisioner example of mesh sdk.</title><link>https://devzone.nordicsemi.com/thread/299256?ContentTypeID=1</link><pubDate>Thu, 11 Mar 2021 12:46:27 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:6a6e55a6-4ab3-44e5-8e7e-dc2c001795ae</guid><dc:creator>Ela</dc:creator><description>&lt;p&gt;Hi Mttrinh,&lt;/p&gt;
&lt;p&gt;&lt;/p&gt;
&lt;p&gt;1) In our provisioner example code, segger_printf.c, segger_print.c, rttinput.c these files have been used for writing or reading data to RTT. &amp;quot;SEGGER_RTT_Read&amp;quot; and &amp;quot;SEGGER_RTT_Write&amp;quot; these functions are used for getting and sending data by RTT, so can i use these functions for the same operation with UART,&amp;nbsp; i think we can not use these functions, if not then how shall we do it?&lt;/p&gt;
&lt;p&gt;2) I have created &amp;quot;uart_event_handler&amp;quot; to handle 2 commands for press 1 and 4 for initiating some commands using &amp;quot;app_uart_get&amp;quot; and &amp;quot;app_uart_put&amp;quot; to send and get data from serial terminal, i am using putty for this. Can i use this way, as i tried but not getting the desired result as mentioned in above point.&amp;nbsp;&lt;/p&gt;
&lt;p&gt;Attaching the code snippet which i have implemented for the uart_event_handler:&lt;/p&gt;
&lt;p&gt;&lt;/p&gt;
&lt;p&gt;&lt;pre class="ui-code" data-mode="text"&gt;/* Copyright (c) 2010 - 2020, Nordic Semiconductor ASA
 * All rights reserved.
 *
 * Redistribution and use in source and binary forms, with or without modification,
 * are permitted provided that the following conditions are met:
 *
 * 1. Redistributions of source code must retain the above copyright notice, this
 * list of conditions and the following disclaimer.
 *
 * 2. Redistributions in binary form, except as embedded into a Nordic
 *    Semiconductor ASA integrated circuit in a product or a software update for
 *    such product, must reproduce the above copyright notice, this list of
 *    conditions and the following disclaimer in the documentation and/or other
 *    materials provided with the distribution.
 *
 * 3. Neither the name of Nordic Semiconductor ASA nor the names of its
 *    contributors may be used to endorse or promote products derived from this
 *    software without specific prior written permission.
 *
 * 4. This software, with or without modification, must only be used with a
 *    Nordic Semiconductor ASA integrated circuit.
 *
 * 5. Any software provided in binary form under this license must not be reverse
 *    engineered, decompiled, modified and/or disassembled.
 *
 * THIS SOFTWARE IS PROVIDED BY NORDIC SEMICONDUCTOR ASA &amp;quot;AS IS&amp;quot; AND ANY EXPRESS
 * OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
 * OF MERCHANTABILITY, NONINFRINGEMENT, AND FITNESS FOR A PARTICULAR PURPOSE ARE
 * DISCLAIMED. IN NO EVENT SHALL NORDIC SEMICONDUCTOR ASA OR CONTRIBUTORS BE
 * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
 * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE
 * GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
 * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
 * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT
 * OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
 */

#include &amp;lt;stdint.h&amp;gt;
#include &amp;lt;string.h&amp;gt;

/* HAL */
#include &amp;quot;boards.h&amp;quot;
#include &amp;quot;nrf_delay.h&amp;quot;
#include &amp;quot;simple_hal.h&amp;quot;
#include &amp;quot;app_timer.h&amp;quot;

/* Core */
#include &amp;quot;nrf_mesh.h&amp;quot;
#include &amp;quot;nrf_mesh_events.h&amp;quot;
#include &amp;quot;nrf_mesh_assert.h&amp;quot;
#include &amp;quot;access_config.h&amp;quot;
#include &amp;quot;device_state_manager.h&amp;quot;
#include &amp;quot;mesh_stack.h&amp;quot;
#include &amp;quot;net_state.h&amp;quot;
#include &amp;quot;mesh_opt_provisioner.h&amp;quot;
#include &amp;quot;mesh_config_entry.h&amp;quot;
#include &amp;quot;mesh_opt.h&amp;quot;

/* Provisioning and configuration */
#include &amp;quot;provisioner_helper.h&amp;quot;
#include &amp;quot;node_setup.h&amp;quot;
#include &amp;quot;mesh_app_utils.h&amp;quot;

/* Models */
#include &amp;quot;config_client.h&amp;quot;
#include &amp;quot;config_server.h&amp;quot;
#include &amp;quot;health_client.h&amp;quot;

/* Logging and RTT */
#include &amp;quot;rtt_input.h&amp;quot;
#include &amp;quot;log.h&amp;quot;

#include&amp;quot;nrf_log_ctrl.h&amp;quot;
#include &amp;quot;nrf_uart.h&amp;quot;
#include &amp;quot;app_uart.h&amp;quot;
#include &amp;quot;nrf_log_ctrl.h&amp;quot;
#include &amp;quot;nrf_log_default_backends.h&amp;quot;
//#include &amp;quot;nrf_log_backend_interface.h&amp;quot;


/* Example specific includes */
#include &amp;quot;example_network_config.h&amp;quot;
#include &amp;quot;nrf_mesh_config_examples.h&amp;quot;
#include &amp;quot;ble_softdevice_support.h&amp;quot;
#include &amp;quot;example_common.h&amp;quot;

/*****************************************************************************
 * Definitions
 *****************************************************************************/
#define APP_PROVISIONING_LED            BSP_LED_0
#define APP_CONFIGURATION_LED           BSP_LED_1





#define UART_TX_BUF_SIZE                256                                         /**&amp;lt; UART TX buffer size. */
#define UART_RX_BUF_SIZE                256                                         /**&amp;lt; UART RX buffer size. */
#include &amp;quot;app_uart.h&amp;quot;
#include &amp;quot;nrf_uart.h&amp;quot;
static bool m_device_provisioned;

/*****************************************************************************
 * Forward declaration of static functions
 *****************************************************************************/
static uint32_t provisioner_setter(mesh_config_entry_id_t id, const void * p_entry);
static void provisioner_getter(mesh_config_entry_id_t id, void * p_entry);
static void provisioner_deleter(mesh_config_entry_id_t id);
static void app_health_event_cb(const health_client_t * p_client, const health_client_evt_t * p_event);
static void app_config_successful_cb(void);
static void app_config_failed_cb(void);
static void app_mesh_core_event_cb (const nrf_mesh_evt_t * p_evt);

static void app_start(void);


/*****************************************************************************
 * Static variables
 *****************************************************************************/
/* Required for the provisioner helper module */
static network_dsm_handles_data_volatile_t m_dev_handles;

static network_stats_data_stored_t m_nw_state;
static bool m_node_prov_setup_started;
static nrf_mesh_evt_handler_t m_mesh_core_event_handler = { .evt_cb = app_mesh_core_event_cb };

NRF_MESH_STATIC_ASSERT(MESH_OPT_FIRST_FREE_ID &amp;lt;= MESH_APP_FILE_ID);
MESH_CONFIG_FILE(m_provisioner_file, MESH_APP_FILE_ID, MESH_CONFIG_STRATEGY_CONTINUOUS);

MESH_CONFIG_ENTRY(provisioner,
                  PROVISIONER_ENTRY_ID,
                  1,
                  sizeof(network_stats_data_stored_t),
                  provisioner_setter,
                  provisioner_getter,
                  provisioner_deleter,
                  false);

static uint32_t provisioner_setter(mesh_config_entry_id_t id, const void * p_entry)
{
    __LOG(LOG_SRC_APP, LOG_LEVEL_DBG1, &amp;quot;Provisioner setter ...\n&amp;quot;);
    NRF_MESH_ASSERT_DEBUG(PROVISIONER_RECORD == id.record);

    network_stats_data_stored_t * p_nsds = (network_stats_data_stored_t *) p_entry;
    memcpy(&amp;amp;m_nw_state, p_nsds, sizeof(network_stats_data_stored_t));

    return NRF_SUCCESS;
}

static void provisioner_getter(mesh_config_entry_id_t id, void * p_entry)
{
    __LOG(LOG_SRC_APP, LOG_LEVEL_DBG1, &amp;quot;Provisioner getter ...\n&amp;quot;);
    NRF_MESH_ASSERT_DEBUG(PROVISIONER_RECORD == id.record);

    network_stats_data_stored_t * p_nw_state = (network_stats_data_stored_t *) p_entry;
    memcpy(p_nw_state, &amp;amp;m_nw_state, sizeof(m_nw_state));
}

static void provisioner_deleter(mesh_config_entry_id_t id)
{
    __LOG(LOG_SRC_APP, LOG_LEVEL_DBG1, &amp;quot;Provisioner deleter ...\n&amp;quot;);
    NRF_MESH_ASSERT_DEBUG(PROVISIONER_RECORD == id.record);

    /* Clear and set default values. */
    memset(&amp;amp;m_nw_state, 0x00, sizeof(m_nw_state));
}

static void provisioner_store(void)
{
    mesh_config_entry_id_t id = PROVISIONER_ENTRY_ID;

    NRF_MESH_ERROR_CHECK(mesh_config_entry_set(id, &amp;amp;m_nw_state));
}

static void provisioner_invalidate(void)
{
    /* Stop scanner. */
    prov_helper_scan_stop();
    /* Delete all old values and remove from mesh config. */
    (void)mesh_config_entry_delete(PROVISIONER_ENTRY_ID);
}

/*****************************************************************************/

static void app_data_store_cb(void)
{
    provisioner_store();
}

/*****************************************************************************/
/**** Configuration process related callbacks ****/

static void app_config_successful_cb(void)
{
    __LOG(LOG_SRC_APP, LOG_LEVEL_INFO, &amp;quot;Configuration of device %u successful\n&amp;quot;, m_nw_state.configured_devices);

    hal_led_pin_set(APP_CONFIGURATION_LED, 0);
    hal_led_pin_set(APP_PROVISIONING_LED, 1);

    m_nw_state.configured_devices++;
    provisioner_store();
    prov_helper_provision_next_device();
    prov_helper_scan_start();
}

static void app_config_failed_cb(void)
{
    __LOG(LOG_SRC_APP, LOG_LEVEL_INFO, &amp;quot;Configuration of device %u failed.\n&amp;quot;, m_nw_state.configured_devices);
    __LOG(LOG_SRC_APP, LOG_LEVEL_INFO, &amp;quot;Press Button/RTT 1 to retry configuration.\n&amp;quot;);
    __LOG(LOG_SRC_APP, LOG_LEVEL_INFO, &amp;quot;Press Button/RTT 2 to start provisioning new nodes.\n&amp;quot;);
    m_node_prov_setup_started = false;
    hal_led_pin_set(APP_CONFIGURATION_LED, 0);
}

static void app_prov_success_cb(void)
{
    __LOG(LOG_SRC_APP, LOG_LEVEL_INFO, &amp;quot;Provisioning successful\n&amp;quot;);

    hal_led_pin_set(APP_PROVISIONING_LED, 0);
    hal_led_pin_set(APP_CONFIGURATION_LED, 1);

    provisioner_store();
}

static void app_prov_failed_cb(void)
{
    __LOG(LOG_SRC_APP, LOG_LEVEL_INFO, &amp;quot;Provisioning failed. Press Button 1 to retry.\n&amp;quot;);

    m_node_prov_setup_started = false;

    hal_led_pin_set(APP_PROVISIONING_LED, 0);
}


/*****************************************************************************/
/**** Model related callbacks ****/
static void app_health_event_cb(const health_client_t * p_client, const health_client_evt_t * p_event)
{
    switch (p_event-&amp;gt;type)
    {
        case HEALTH_CLIENT_EVT_TYPE_CURRENT_STATUS_RECEIVED:
            __LOG(LOG_SRC_APP,
                  LOG_LEVEL_INFO,
                  &amp;quot;Node 0x%04x alive with %u active fault(s), RSSI: %d\n&amp;quot;,
                  p_event-&amp;gt;p_meta_data-&amp;gt;src.value,
                  p_event-&amp;gt;data.fault_status.fault_array_length,
                  ((p_event-&amp;gt;p_meta_data-&amp;gt;p_core_metadata-&amp;gt;source == NRF_MESH_RX_SOURCE_SCANNER)
                       ? p_event-&amp;gt;p_meta_data-&amp;gt;p_core_metadata-&amp;gt;params.scanner.rssi
                       : 0));
            break;
        default:
            break;
    }
}

static void app_config_server_event_cb(const config_server_evt_t * p_evt)
{
    __LOG(LOG_SRC_APP, LOG_LEVEL_INFO, &amp;quot;config_server Event %d.\n&amp;quot;, p_evt-&amp;gt;type);

    if (p_evt-&amp;gt;type == CONFIG_SERVER_EVT_NODE_RESET)
    {
        /* This should never return */
        hal_device_reset(0);
    }
}

static void app_config_client_event_cb(config_client_event_type_t event_type, const config_client_event_t * p_event, uint16_t length)
{
    /* USER_NOTE: Do additional processing of config client events here if required */
    __LOG(LOG_SRC_APP, LOG_LEVEL_INFO, &amp;quot;Config client event\n&amp;quot;);

    /* Pass events to the node setup helper module for further processing */
    node_setup_config_client_event_process(event_type, p_event, length);
}


static void provisioning_start(void)
{
    __LOG(LOG_SRC_APP, LOG_LEVEL_INFO, &amp;quot;Start provisioning procedure ...\n&amp;quot;);

    prov_helper_provision_next_device();
    prov_helper_scan_start();

    hal_led_pin_set(APP_PROVISIONING_LED, 1);
}

static void provisioning_resume(void)
{
    if (!m_node_prov_setup_started)
    {
        /* If previously provisioned device is not configured. */
        if (m_nw_state.configured_devices &amp;lt; m_nw_state.provisioned_devices)
        {
            m_nw_state.provisioned_devices--;
            provisioning_start();
            m_node_prov_setup_started = true;
        }
    }
}

/** Check if all devices have been provisioned. If not, provision remaining devices.
 *  Check if all devices have been configured. If not, start configuring them.
 */
static void check_network_state(void)
{
    if (!m_node_prov_setup_started)
    {
        /* If previously provisioned device is not configured, start node setup procedure. */
        if (m_nw_state.configured_devices &amp;lt; m_nw_state.provisioned_devices)
        {
            /* Execute configuration */
            __LOG(LOG_SRC_APP, LOG_LEVEL_INFO, &amp;quot;Waiting for provisioned node to be configured ...\n&amp;quot;);

            node_setup_start(m_nw_state.last_device_address, PROVISIONER_RETRY_COUNT,
                            m_nw_state.appkey, APPKEY_INDEX, NETKEY_INDEX, m_nw_state.current_uri);

            hal_led_pin_set(APP_CONFIGURATION_LED, 1);
        }
        else
        {
            provisioning_start();
        }

        m_node_prov_setup_started = true;
    }
    else
    {
        __LOG(LOG_SRC_APP, LOG_LEVEL_INFO, &amp;quot;Waiting for previous procedure to finish ...\n&amp;quot;);
    }
}

static void app_mesh_core_event_cb (const nrf_mesh_evt_t * p_evt)
{
    /* USER_NOTE: User can insert mesh core event processing here */
    switch(p_evt-&amp;gt;type)
    {
        /* Start user application specific functions only when stack is enabled */
        case NRF_MESH_EVT_ENABLED:
            __LOG(LOG_SRC_APP, LOG_LEVEL_DBG1, &amp;quot;Mesh evt: NRF_MESH_EVT_ENABLED\n&amp;quot;);
#if (PERSISTENT_STORAGE)
            /* Mesh stack initialization has been completed */
            app_start();
#endif
            break;

        case NRF_MESH_EVT_CONFIG_LOAD_FAILURE:
            if (p_evt-&amp;gt;params.config_load_failure.id.file == MESH_APP_FILE_ID)
            {
                __LOG(LOG_SRC_APP, LOG_LEVEL_INFO, &amp;quot;Persistent provisioner data was corrupted. Set default values. \n&amp;quot;);
                /* Clear and set default values. */
                memset(&amp;amp;m_nw_state, 0x00, sizeof(m_nw_state));
            }
            break;

        default:
            break;
    }
}

/* Binds the local models correctly with the desired keys */
void app_default_models_bind_setup(void)
{
    /* Bind health client to App key, and configure publication key */
    ERROR_CHECK(access_model_application_bind(m_dev_handles.m_health_client_instance.model_handle, m_dev_handles.m_appkey_handle));
    ERROR_CHECK(access_model_publish_application_set(m_dev_handles.m_health_client_instance.model_handle, m_dev_handles.m_appkey_handle));

    /* Bind self-config server to the self device key */
    ERROR_CHECK(config_server_bind(m_dev_handles.m_self_devkey_handle));
}

static void node_reset(void)
{
    __LOG(LOG_SRC_APP, LOG_LEVEL_INFO, &amp;quot;----- Node reset  -----\n&amp;quot;);

    hal_led_blink_ms(HAL_LED_MASK, LED_BLINK_INTERVAL_MS, LED_BLINK_CNT_RESET);
    /* This function may return if there are ongoing flash operations. */
    mesh_stack_device_reset();
}

#if NRF_MESH_LOG_ENABLE
static const char m_usage_string[] =
    &amp;quot;\n&amp;quot;
    &amp;quot;\t\t--------------------------------------------------------------------------------\n&amp;quot;
    &amp;quot;\t\t Button/RTT 1) Initiate provisioning and configuration of unprovisioned devices.\n&amp;quot;
    &amp;quot;\t\t Button/RTT 4) Clear all the states to reset the node.\n&amp;quot;
    &amp;quot;\t\t--------------------------------------------------------------------------------\n&amp;quot;;
#endif

static void button_event_handler(uint32_t button_number)
{
    /* Increase button number because the buttons on the board is marked with 1 to 4 */
    button_number++;
    __LOG(LOG_SRC_APP, LOG_LEVEL_INFO, &amp;quot;Button %u pressed\n&amp;quot;, button_number);
    switch (button_number)
    {
        case 1:
        {
            /* Check if all devices have been provisioned or not */
            check_network_state();
            break;
        }

        case 2:
        {
            provisioning_resume();
            break;
        }

        /* Initiate node reset */
        case 4:
        {
            if (mesh_stack_is_device_provisioned())
            {
                /* Clear all the states to reset the node. */
                provisioner_invalidate();
                mesh_stack_config_clear();
            }
            node_reset();
            break;
        }

        default:
            __LOG(LOG_SRC_APP, LOG_LEVEL_INFO, m_usage_string);
            break;
    }
}

static void app_rtt_input_handler(int key)
{
    if (key &amp;gt;= &amp;#39;1&amp;#39; &amp;amp;&amp;amp; key &amp;lt;= &amp;#39;4&amp;#39;)
    {
        uint32_t button_number = key - &amp;#39;1&amp;#39;;
        button_event_handler(button_number);
    }
    else
    {
        __LOG(LOG_SRC_APP, LOG_LEVEL_INFO, m_usage_string);
    }
}

void models_init_cb(void)
{
    __LOG(LOG_SRC_APP, LOG_LEVEL_INFO, &amp;quot;Initializing and adding models\n&amp;quot;);
    m_dev_handles.m_netkey_handle = DSM_HANDLE_INVALID;
    m_dev_handles.m_appkey_handle = DSM_HANDLE_INVALID;
    m_dev_handles.m_self_devkey_handle = DSM_HANDLE_INVALID;

    /* This app requires following models :
     * config client : To be able to configure other devices
     * health client : To be able to interact with other health servers */
    ERROR_CHECK(config_client_init(app_config_client_event_cb));
    ERROR_CHECK(health_client_init(&amp;amp;m_dev_handles.m_health_client_instance, 0, app_health_event_cb));
}

static void mesh_init(void)
{
    bool device_provisioned;
    mesh_stack_init_params_t init_params =
    {
        .core.irq_priority       = NRF_MESH_IRQ_PRIORITY_LOWEST,
        .core.lfclksrc           = DEV_BOARD_LF_CLK_CFG,
        .models.models_init_cb   = models_init_cb,
        .models.config_server_cb = app_config_server_event_cb
    };

    nrf_mesh_evt_handler_add(&amp;amp;m_mesh_core_event_handler);
    uint32_t status = mesh_stack_init(&amp;amp;init_params, &amp;amp;device_provisioned);
    switch (status)
    {
        case NRF_ERROR_INVALID_DATA:
            __LOG(LOG_SRC_APP, LOG_LEVEL_INFO, &amp;quot;Data in the persistent memory was corrupted.\n&amp;quot;);
            __LOG(LOG_SRC_APP, LOG_LEVEL_INFO, &amp;quot;Reboot device before starting of the provisioning process.\n&amp;quot;);
            break;
        case NRF_SUCCESS:
            break;
        default:
            ERROR_CHECK(status);
    }

    if (status == NRF_SUCCESS)
    {
        /* Initialize the provisioner */
        mesh_provisioner_init_params_t m_prov_helper_init_info =
        {
            .p_dev_data = &amp;amp;m_dev_handles,
            .p_nw_data = &amp;amp;m_nw_state,
            .netkey_idx = NETKEY_INDEX,
            .attention_duration_s = ATTENTION_DURATION_S,
            .p_data_store_cb  = app_data_store_cb,
            .p_prov_success_cb = app_prov_success_cb,
            .p_prov_failed_cb = app_prov_failed_cb
        };
        prov_helper_init(&amp;amp;m_prov_helper_init_info);

        if (!device_provisioned)
        {
            __LOG(LOG_SRC_APP, LOG_LEVEL_INFO, &amp;quot;Setup defaults: Adding keys, addresses, and bindings \n&amp;quot;);

            prov_helper_provision_self();
            app_default_models_bind_setup();
            app_data_store_cb();
        }
        else
        {
            __LOG(LOG_SRC_APP, LOG_LEVEL_INFO, &amp;quot;Restored: Handles \n&amp;quot;);
            prov_helper_device_handles_load();
        }

        node_setup_cb_set(app_config_successful_cb, app_config_failed_cb);
    }
}





void uart_event_handle(app_uart_evt_t * p_event)
{
       while (true)
    {
        uint8_t cr;
        while (app_uart_get(&amp;amp;cr) != NRF_SUCCESS);
        while (app_uart_put(cr) != NRF_SUCCESS);

        if (cr == &amp;#39;1&amp;#39;)
        {
            printf(&amp;quot; \r\n 1 pressed \r\n&amp;quot;);
            check_network_state();

            while (true)
            {
                // Do nothing.
            }
        if (cr == &amp;#39;2&amp;#39;)
        {
        printf(&amp;quot;\r\n 2 pressed &amp;quot;);
        provisioning_resume();

         while (true)
            {
                // Do nothing.
            }

        }
        if (cr==&amp;#39;4&amp;#39;)
        {
            printf(&amp;quot;\r\n 4 pressed \r\n&amp;quot;);
            if (mesh_stack_is_device_provisioned())
            {
                /* Clear all the states to reset the node. */
                provisioner_invalidate();
                mesh_stack_config_clear();
            }
            node_reset();

             while (true)
            {
                // Do nothing.
            }

        }
         

        }
    }
    
#if 0    
    uint32_t i;
    switch(i)
    {
    case 1:
    {
     printf(&amp;quot;\r\n Pressing 1 for scanning the unprovisioned nodes Uart event handler provisioner code .\r\n&amp;quot;);
     check_network_state();
     break;

    }
    
    case 2: 

      {
            provisioning_resume();
            break;
       }

    case 4:
         {
            printf(&amp;quot;\r\n Pressing 4 for resetting the provisioned nodes Uart event handler provisioner code .\r\n&amp;quot;);
             if (mesh_stack_is_device_provisioned())
            {
                /* Clear all the states to reset the node. */
                provisioner_invalidate();
                mesh_stack_config_clear();
            }
            node_reset();
            break;
        }
    break;
    default:

    }
#endif


 //printf(&amp;quot;\r\nUART started uart event handler provisioner code .\r\n&amp;quot;);

}



/**@brief  Function for initializing the UART module.
 */
/**@snippet [UART Initialization] */
static void uart_init(void)
{
    uint32_t                     err_code;
    app_uart_comm_params_t const comm_params =
    {
        .rx_pin_no    = RX_PIN_NUMBER,
        .tx_pin_no    = TX_PIN_NUMBER,
        .rts_pin_no   = RTS_PIN_NUMBER,
        .cts_pin_no   = CTS_PIN_NUMBER,
        .flow_control = APP_UART_FLOW_CONTROL_DISABLED,
        .use_parity   = false,
#if defined (UART_PRESENT)
        .baud_rate    = NRF_UART_BAUDRATE_115200
#else
        .baud_rate    = NRF_UARTE_BAUDRATE_115200
#endif
    };

  APP_UART_FIFO_INIT(&amp;amp;comm_params,
                       UART_RX_BUF_SIZE,
                       UART_TX_BUF_SIZE,
                       uart_event_handle,
                       APP_IRQ_PRIORITY_LOWEST,
                       err_code);
    APP_ERROR_CHECK(err_code);
}
/**@snippet [UART Initialization] */








static void initialize(void)
{
    
      uart_init();
   
   // __LOG_INIT(LOG_SRC_APP | LOG_SRC_ACCESS, LOG_LEVEL_INFO, LOG_CALLBACK_DEFAULT);
    __LOG_INIT(LOG_SRC_APP | LOG_SRC_FRIEND, LOG_LEVEL_DBG1, log_callback_rtt);
    __LOG(LOG_SRC_APP, LOG_LEVEL_INFO, &amp;quot;----- BLE Mesh Static Provisioner Demo -----\n&amp;quot;);

    ERROR_CHECK(app_timer_init());
    hal_leds_init();

#if BUTTON_BOARD
    ERROR_CHECK(hal_buttons_init(button_event_handler));
#endif

    ble_stack_init();
    mesh_init();
    node_setup_uri_check();
}

static void app_start(void)
{
    __LOG(LOG_SRC_APP, LOG_LEVEL_INFO, &amp;quot;Starting application ...\n&amp;quot;);
    __LOG(LOG_SRC_APP, LOG_LEVEL_INFO, &amp;quot;Provisioned Nodes: %d, Configured Nodes: %d\n&amp;quot;,
          m_nw_state.provisioned_devices, m_nw_state.configured_devices);
    __LOG_XB(LOG_SRC_APP, LOG_LEVEL_INFO, &amp;quot;Dev key &amp;quot;, m_nw_state.self_devkey, NRF_MESH_KEY_SIZE);
    __LOG_XB(LOG_SRC_APP, LOG_LEVEL_INFO, &amp;quot;Net key &amp;quot;, m_nw_state.netkey, NRF_MESH_KEY_SIZE);
    __LOG_XB(LOG_SRC_APP, LOG_LEVEL_INFO, &amp;quot;App key &amp;quot;, m_nw_state.appkey, NRF_MESH_KEY_SIZE);
    __LOG(LOG_SRC_APP, LOG_LEVEL_INFO, &amp;quot;Press Button/RTT 1 to start provisioning and configuration process. \n&amp;quot;);
}

static void start(void)
{
    rtt_input_enable(app_rtt_input_handler, RTT_INPUT_POLL_PERIOD_MS);
    __LOG(LOG_SRC_APP, LOG_LEVEL_INFO, &amp;quot;&amp;lt;start&amp;gt; \n&amp;quot;);

    ERROR_CHECK(mesh_stack_start());

#if (!PERSISTENT_STORAGE)
    app_start();
#endif

    __LOG(LOG_SRC_APP, LOG_LEVEL_INFO, m_usage_string);

    hal_led_mask_set(HAL_LED_MASK, LED_MASK_STATE_OFF);
    hal_led_blink_ms(HAL_LED_MASK, LED_BLINK_INTERVAL_MS, LED_BLINK_CNT_START);
}



/**@brief Function for initializing the nrf log module.
 */
 #if 0
static void log1_init(void)
{
    ret_code_t err_code = NRF_LOG_INIT(NULL);
    APP_ERROR_CHECK(err_code);

    NRF_LOG_DEFAULT_BACKENDS_INIT();
}
#endif








#if 0
void my_uart_callback(nrfx_uarte_event_t const * p_event,
                      void *                     p_context)
{
    //TODO: Handle &amp;#39;p_event&amp;#39;
}
#endif

int main(void)
{
    

   // nrfx_uarte_t m_uart = NRFX_UARTE_INSTANCE(0); 
    //nrfx_uarte_config_t m_uart_config = NRFX_UARTE_DEFAULT_CONFIG;
    
   // nrfx_uarte_init(&amp;amp;m_uart, &amp;amp;m_uart_config, my_uart_callback);



    // uart_init();
     //log1_init();

 //   ret_code_t err_code = NRF_LOG_INIT(NULL);
  //  APP_ERROR_CHECK(err_code);

    // NRF_LOG_DEFAULT_BACKENDS_INIT();

    initialize();
     printf(&amp;quot;\r\nUART started main provisioner code .\r\n&amp;quot;);
    start();

    for (;;)
    {
        (void)sd_app_evt_wait();
    }
}
&lt;/pre&gt;&lt;/p&gt;
&lt;p&gt;&lt;/p&gt;
&lt;p&gt;Is this the right way i have implemented if not then how shall i proceed with it.&lt;/p&gt;
&lt;p&gt;&lt;/p&gt;
&lt;p&gt;Thanks &amp;amp; Regards,&lt;/p&gt;
&lt;p&gt;Ela&lt;/p&gt;
&lt;p&gt;&lt;/p&gt;
&lt;p&gt;&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: How to send data to UART for the provisioner example of mesh sdk.</title><link>https://devzone.nordicsemi.com/thread/299150?ContentTypeID=1</link><pubDate>Thu, 11 Mar 2021 06:30:09 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:d9a823f9-c92d-4668-9d1f-f48593c429cb</guid><dc:creator>Ela</dc:creator><description>&lt;p&gt;Hi Mttrinh,&lt;/p&gt;
&lt;p&gt;1) I am getting compiling errors and not able to resolve it, i have used in the same way as mentioned in the infocenter.&amp;nbsp;&lt;/p&gt;
&lt;p&gt;2) Can you please elaborate about when you mean have to handle how received command is being handled? For example : if i want to send press 1 to initiate the scanning of unprovisioned device as same in provisioner example code and want to send press button 4 to reset all the provisioned nodes using UART. In the existing example code we are sending using RTT same i want to do using UART.What do you mean that handle the received commands. Shall i put uart event handler with the case 1 calling funcciton to scan the unprovisioned nodes and case 4 call function to reset the provisioned node? Can you just help me with this at high priority, it will be very helpful.&lt;/p&gt;
&lt;p&gt;&lt;/p&gt;
&lt;p&gt;Thanks &amp;amp; Regards,&lt;/p&gt;
&lt;p&gt;Ela&amp;nbsp;&amp;nbsp;&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: How to send data to UART for the provisioner example of mesh sdk.</title><link>https://devzone.nordicsemi.com/thread/298835?ContentTypeID=1</link><pubDate>Tue, 09 Mar 2021 18:13:32 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:bbd5d1c6-8a35-4d5e-9f5a-0e6c43fa6845</guid><dc:creator>Mttrinh</dc:creator><description>&lt;p&gt;Hi,&lt;/p&gt;
&lt;p&gt;1) What kind of errors do you get? You run the example unmodified, correct?&lt;/p&gt;
&lt;p&gt;2) You shouldn&amp;#39;t need to add&amp;nbsp;&lt;span&gt;backend logging via UART. I haven&amp;#39;t tried to add UART logging to the provisioner example myself, so I would need some time to try this. In the mean time I would suggest you study the proximity coexist example and see how things are done there.&lt;/span&gt;&amp;nbsp;&lt;/p&gt;
[quote user="Ekta hav"]I want to know how to send and receive data via serial terminal and initiate the command of scanning the devices in provisioner code. is there any different way to do so. Can we use the same RTT interface that is been already used with existing code examples to send and receive commands as we are doing using RTT. I want to use the same functinality that we rae using by RTT with UART for sending and getting the data .[/quote]
&lt;p&gt;I think it should be possible to do the same with UART, but you have to implement how the received commands are handled yourself.&amp;nbsp;&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: How to send data to UART for the provisioner example of mesh sdk.</title><link>https://devzone.nordicsemi.com/thread/298698?ContentTypeID=1</link><pubDate>Tue, 09 Mar 2021 12:29:45 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:5de3df66-f608-4b50-82d2-63631a1b366e</guid><dc:creator>Ela</dc:creator><description>&lt;p&gt;Hi Mttrinh,&lt;/p&gt;
&lt;p&gt;I want to know how to send and receive data via serial terminal and initiate the command of scanning the devices in provisioner code. is there any different way to do so. Can we use the same RTT interface that is been already used with existing code examples to send and receive commands as we are doing using RTT. I want to use the same functinality that we rae using by RTT with UART for sending and getting the data .&lt;/p&gt;
&lt;p&gt;&lt;/p&gt;
&lt;p&gt;Thanks &amp;amp; Regards,&lt;/p&gt;
&lt;p&gt;Ela&amp;nbsp;&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: How to send data to UART for the provisioner example of mesh sdk.</title><link>https://devzone.nordicsemi.com/thread/298269?ContentTypeID=1</link><pubDate>Mon, 08 Mar 2021 08:46:03 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:454e7bc9-e3e6-4b96-8c0a-d9dc52596903</guid><dc:creator>Ela</dc:creator><description>&lt;p&gt;Hi Mttrinh,&lt;/p&gt;
&lt;p&gt;1) I was using coexist example but i am not able to compile the code as throwing some of the errors, i have done the same way it is mentioned in the infocenter for coexist example, but still not able to test the coexist example.&lt;/p&gt;
&lt;p&gt;2) I have tried merging the code, but it did not work for me. I have doubt about logging module, as we do have backend logging too in the sdk. In mesh sdk we are using log.c file for logging via RTT but in nrf sdk we are using backend logging via RTT as in file nrf_backend_rtt.c . As, i want tio use provisioner code of the mesh sdk, which logging shall i used, shall i made changes only in log.c file&amp;nbsp; or shall i add backend logging via UART. I have tried both but nothing worked, when tried doing changes in log.c file having lot of errors when added backend logging for UART. Can you please help me in achieving this, if possible by providing changes need to be done or added in the provisioner code, it will be of great help.&lt;/p&gt;
&lt;p&gt;&lt;/p&gt;
&lt;p&gt;Thanks &amp;amp; Regards,&lt;/p&gt;
&lt;p&gt;Ela&amp;nbsp;&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: How to send data to UART for the provisioner example of mesh sdk.</title><link>https://devzone.nordicsemi.com/thread/295905?ContentTypeID=1</link><pubDate>Tue, 23 Feb 2021 16:12:13 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:7e741b18-fd89-461c-a355-54cad380f61d</guid><dc:creator>Mttrinh</dc:creator><description>&lt;p&gt;Hi,&lt;/p&gt;
&lt;p&gt;1) I suggest you look at&amp;nbsp;the proximity coexist example you can see how the logging over UART is initialized instead of RTT. Then try to merge this logging functionality over to your application.&amp;nbsp;&lt;/p&gt;
&lt;p&gt;2) We do have an example in the SDK that combines UART with the light switch example. You can use this as a reference for how you can combine the uart example and the provisioner example. This is not something we have done so you have to try implementing yourself.&lt;/p&gt;
&lt;p&gt;3) Like it is mentioned &lt;a href="https://infocenter.nordicsemi.com/topic/com.nordic.infocenter.meshsdk.v5.0.0/md_doc_user_guide_mesh_compatibility.html#compatibility_nRF52840_dongle" rel="noopener noreferrer" target="_blank"&gt;here&lt;/a&gt;, only a few examples supports the dongle but with limited functionalities. It might be possible to modify the example so that it can run on the dongle,&lt;span&gt;&amp;nbsp;&lt;/span&gt;I would not recommend using the dongle since it lacks a onboard debugger and o&lt;span&gt;nly light switch server example&lt;/span&gt;&lt;span&gt;&amp;nbsp;has been tested with the dongle.&lt;/span&gt;&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item></channel></rss>