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

Sending hex values through app_uart_put()

Hi,

I am trying to send an command line through UART to the UART device such as MP3 audio module. MP3 module is taking only hex values. How to send it to the UART device(MP3 module).

For e.g., Command line is as follows.

uint8_t Command_line[10] = { 0x7E, 0xFF, 0x06, 0x3F, 0x00, 0x00, 0x00, 0xFE, 0xBC, 0xEF};

The above is the command line which has to be sent through UART, which function should be used for sending the command to the MP3 device and how it will be executed. Is there any example code is there for this.

Parents
  • Hi,

    You can do something like this:

    uint32_t length = 10;
    
    uint8_t Command_line[10] = { 0x7E, 0xFF, 0x06, 0x3F, 0x00, 0x00, 0x00, 0xFE, 0xBC, 0xEF};
    
        for (uint32_t i = 0; i < length; i++)
        {
            do
            {
                err_code = app_uart_put(Command_line[i]);
                if ((err_code != NRF_SUCCESS) && (err_code != NRF_ERROR_BUSY))
                {
                    NRF_LOG_ERROR("Failed Error 0x%x. ", err_code);
                    APP_ERROR_CHECK(err_code);
                }
            } while (err_code == NRF_ERROR_BUSY);
        }
    

    Take a look at e.g. the ble_app_uart example on how UART initialization is done.

Reply
  • Hi,

    You can do something like this:

    uint32_t length = 10;
    
    uint8_t Command_line[10] = { 0x7E, 0xFF, 0x06, 0x3F, 0x00, 0x00, 0x00, 0xFE, 0xBC, 0xEF};
    
        for (uint32_t i = 0; i < length; i++)
        {
            do
            {
                err_code = app_uart_put(Command_line[i]);
                if ((err_code != NRF_SUCCESS) && (err_code != NRF_ERROR_BUSY))
                {
                    NRF_LOG_ERROR("Failed Error 0x%x. ", err_code);
                    APP_ERROR_CHECK(err_code);
                }
            } while (err_code == NRF_ERROR_BUSY);
        }
    

    Take a look at e.g. the ble_app_uart example on how UART initialization is done.

Children
No Data
Related