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

About RX and TX characteristics in NUS

Hello; I have been working with nrf52840 dk's for the past couple months, and came across a few questions.

First off, my temporary goal using nrf52840 is to send a timestamp using TIMER via UART, which is a preferred method 

of transferring data after two ble 5 devices establish a connection between each other.

I have been looking into how the NUS functions, and couldn't quite make a clear sense of what the 

RX characteristic and TX characteristic are - seems like each instances of nus within the code

contain 1 of each RX and TX characteristics, but I'm not crystal clear with what these characteristics do.

Also, If possible, could I get a word of advise as to how we could inject // implant timestamp data, whether it be RTC based or TIMER based, 

into the packets sent over the UART interface? 

Thank you in advance.

Parents
  • Hello,

    Sorry for my late reply.
    Just to make sure I understand you correctly, you currently have two nRF52840 DK who will communicate what they are told over UART with each other using BLE?
    Could you tell me which application is running on the devices - are you using examples from the SDK, and if so; which examples have you flashed them with? For example BLE_central/ble_app_uart_c and BLE_peripheral/ble_app_uart.

    You are correct that each NUS instance contain both an RX and a TX characteristic - one for receiving transmissions, and one for sending.
    The characteristics serves as the "datatype" of the transmission - a standard, so both sides know what to expect when they receive a transmission. If you would like a more in depth explanation of characteristics, I can highly recommend this guide.

    For your last question, have you made a timestamp that you would like to send using NUS, or are you asking how to create the timestamp?
    If it is the former, I suggest you look at the callback functions in the event of received UART or BLE_uart data in the BLE_central/ble_app_uart_c example, specifically, the uart_event_handle() and ble_nus_c_evt_handler(), they might be what you are looking for.
    If it is the latter, please specify what kind of timestamp you are after, and have a look at the app_timer from components/libraries/timer in the SDK.

    Just to clarify, you do not need to create the data packet to be sent yourself - this is taken care of by the uart_event_handle, if you send data to your device over UART. Here is an exempt of the uart_event_handle() docstring:

    uart_event_handle()
    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 'new line' '\n' (hex 0x0A) or if the string has reached the maximum data length. 


    Best regards,
    Karl

Reply
  • Hello,

    Sorry for my late reply.
    Just to make sure I understand you correctly, you currently have two nRF52840 DK who will communicate what they are told over UART with each other using BLE?
    Could you tell me which application is running on the devices - are you using examples from the SDK, and if so; which examples have you flashed them with? For example BLE_central/ble_app_uart_c and BLE_peripheral/ble_app_uart.

    You are correct that each NUS instance contain both an RX and a TX characteristic - one for receiving transmissions, and one for sending.
    The characteristics serves as the "datatype" of the transmission - a standard, so both sides know what to expect when they receive a transmission. If you would like a more in depth explanation of characteristics, I can highly recommend this guide.

    For your last question, have you made a timestamp that you would like to send using NUS, or are you asking how to create the timestamp?
    If it is the former, I suggest you look at the callback functions in the event of received UART or BLE_uart data in the BLE_central/ble_app_uart_c example, specifically, the uart_event_handle() and ble_nus_c_evt_handler(), they might be what you are looking for.
    If it is the latter, please specify what kind of timestamp you are after, and have a look at the app_timer from components/libraries/timer in the SDK.

    Just to clarify, you do not need to create the data packet to be sent yourself - this is taken care of by the uart_event_handle, if you send data to your device over UART. Here is an exempt of the uart_event_handle() docstring:

    uart_event_handle()
    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 'new line' '\n' (hex 0x0A) or if the string has reached the maximum data length. 


    Best regards,
    Karl

Children
No Data
Related