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

nRF UART app Send

FormerMember
FormerMember

In the nRF UART v2.0 App, the app have the "send" command. And I can send the data to my nRF52 DK, and it print what I'm sending on the Serial monitor.

However, in the ble_app_uart example code, I don't see where this function of code is locate, Does anyone know where in the code this function is called which when we "send" the data from phone to nRF52 and print it out on monitor?

Thanks.

Parents
  • I think what you are looking for is the callback function nus_data_handler() in main.c

    The handler is passed to the uart service during initialisation, and the on_write() function in the uart service calls the function pointer (which points to the callback function in main)

    If you are not seeing any output on your hardware (UART) pins, then you don't have the TX and RX pins configured correctly for the board you are using.

  • FormerMember
    0 FormerMember in reply to Roger Clark

    the data send from phone to nRF52 is not display in "int" type,

        static void nus_data_handler(ble_nus_t * p_nus, uint8_t * p_data, uint16_t length)
        {
        	int send_value;
            for (uint32_t i = 0; i < length; i++)
            {
                while (app_uart_put(p_data[i]) != NRF_SUCCESS);
        	send_value = ((p_data[i]-'0'));
            }
            while (app_uart_put('\r') != NRF_SUCCESS);
            while (app_uart_put('\n') != NRF_SUCCESS);
            printf("send_value: %d\n",send_value);
        }
    

    The problem is when I enter number from 0 to 9 it works fine, but after entered number above 10 it shows the 0-9 again. any idea on how to let it display as integer type number?

    Thanks

Reply
  • FormerMember
    0 FormerMember in reply to Roger Clark

    the data send from phone to nRF52 is not display in "int" type,

        static void nus_data_handler(ble_nus_t * p_nus, uint8_t * p_data, uint16_t length)
        {
        	int send_value;
            for (uint32_t i = 0; i < length; i++)
            {
                while (app_uart_put(p_data[i]) != NRF_SUCCESS);
        	send_value = ((p_data[i]-'0'));
            }
            while (app_uart_put('\r') != NRF_SUCCESS);
            while (app_uart_put('\n') != NRF_SUCCESS);
            printf("send_value: %d\n",send_value);
        }
    

    The problem is when I enter number from 0 to 9 it works fine, but after entered number above 10 it shows the 0-9 again. any idea on how to let it display as integer type number?

    Thanks

Children
No Data
Related