nRF52832 Bluetooth peripheral_uart sample: use RX data and not sent to BLE

I want to intercept some data in the RX (in section UART_RX_READY in uart_cb() as a command with arguments.  And I do not want this data to be sent on the the BLE.

After I get the data that I want, what should I do with the buf, so the process continues getting new data from the UART RX?

Do I just k_free(buf)?  Or something else?

Parents Reply Children
  • Hello,

    BradEA said:
    Also, is there a more complete description of this sample or what's involved with how this all works?

    The sample's documentation contains all the description of its function. Let me know if there is anything in particular that is not covered there that you have questions about.

    BradEA said:
    Does this always require a carriage return or linefeed character before actually sending to the BLE?

    Yes, the buffer filling for a single message will end when the \n or \r character is received, as shown in the UART_RX_RDY handling.

    Best regards,
    Karl

  • I want to be able to send any number of bytes without using \n or \r characters to indicate end of the input data packet, if possible.

    And I want the program to not lose data in the middle of sending data to the BLE Tx, regardless of its MTU size.

    I don't understand how data input to the uart ends up at the UART_RX_READY point in the code.

  • Another question: where and how is the flow control handled, use of RTS/CTS?

  • another question: how does the BLE prevent or control the flow of data into itself for sending to the tablet?

  • Hello,

    BradEA said:
    I want to be able to send any number of bytes without using \n or \r characters to indicate end of the input data packet, if possible.

    Then you would have to modify the code section I referenced earlier. However, the application will need some kind of way to know when to stop the read, so that it can be placed in the BLE TX buffer for transmission.

    BradEA said:
    And I want the program to not lose data in the middle of sending data to the BLE Tx, regardless of its MTU size.

    Could you elaborate what you mean by this? BLE is a lossless protocol - everything you have queued for transmission will either be sent successfully, or the link will be terminated, there is not data lost in the link.

    BradEA said:
    I don't understand how data input to the uart ends up at the UART_RX_READY point in the code.

    The UART_RX_READY is the event handling of the registered UART callback function, which will be called whenever the UART peripheral has generated an event.

    BradEA said:
    Another question: where and how is the flow control handled, use of RTS/CTS?

    This would be handled by the UART peripheral, and needs to be enabled during initialization of the UART peripheral / driver.

    BradEA said:
    another question: how does the BLE prevent or control the flow of data into itself for sending to the tablet?

    Could you elaborate what you mean by this? In the case that you try to queue data for sending while the sending buffer is full the call to queue data will fail with an error code indicating that the buffer is full. The sample is made to re-try the sending if this happens, which you can see as part of the ble_write_thread implementation.

    Best regards,
    Karl

Related