Beware that this post is related to an SDK in maintenance mode
More Info: Consider nRF Connect SDK for new designs
This post is older than 2 years and might not be relevant anymore
More Info: Consider searching for newer posts

How to send data to UART for the provisioner example of mesh sdk.

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 "provisioner" example of mesh sdk in place "meshsdk/example/provisioner". How to procees with it, can anyone help me?

2) I combined uart example of nrf 17.0 sdk with the provisioner example of mesh sdk but not able to receive the data over UART. Is this the right way to do, can i use uart example with the provisioner, if yes then can you please provide me the source code, as for me it is not working, i am not sure if having some issues in combining both the project of both sdks.

3) Can i use the provisioner code for dongle nrf52840(PCA10059) where i want to get data over USB, as it is mentioned in nordic infocenter that we can not. If we can then can you please provide me with required source code.

If anyone can help me, it is very helpful for me to proceed. Can anyone help me with high priority?

Thanks & Regards,

Ela

  • Hi Mttrinh,

    1) I have tried with freshly downloaded sdks but still face the same issue.

    2) I have called uart_init() in the initialize function of main.c attaching the code,

    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, "----- BLE Mesh Static Provisioner Demo -----\n");
    
        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();
    }
    

    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:

    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("\r\nUART started uart event handler.\r\n");
        switch (p_event->evt_type)
        {
            case APP_UART_DATA_READY:
            {
                UNUSED_VARIABLE(app_uart_get(&data_array[index]));
                printf("Data array in switch %c\r\n",data_array[index]);
    
                index++;
    
                 if ( data_array[index - 1] == '1')
                {
                   printf("Sucess pressed 1 \r\n");
                   check_network_state();
                   index = 0;
                   memset(data_array[index], 0 , sizeof(data_array[index]));
    
                }
    
                if ( data_array[index - 1] == '2')
                {
                   printf("Sucess pressed 2 \r\n");
                   provisioning_resume();
                   index = 0;
                   memset(data_array[index], 0 , sizeof(data_array[index]));
    
                }
    
                 if ( data_array[index - 1] == '4')
                  {
                   printf("Sucess pressed 4 \r\n");
                 
                     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] == ';')
                {
                   printf("sucess \r\n");
                   index = 0;
                   memset(data_array[index], 0 , sizeof(data_array[index]));
    
                }
                #endif
               
                    
                break;
                }
    
            case APP_UART_COMMUNICATION_ERROR:
                APP_ERROR_HANDLER(p_event->data.error_communication);
                break;
    
            case APP_UART_FIFO_ERROR:
                APP_ERROR_HANDLER(p_event->data.error_code);
                break;
    
            default:
                break;
        }
      }
    
    
    
     

    Can you please help me with this?

    Thanks & Regards,

    Ela

  • Hi Mttrinh,

    Any update for this?

    Thanks & Regards,

    Ela

  • 1) This seems really strange, can you provide the exact step you have done?

    2) Sorry, seems like I missed it.

    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. 

Related