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

RX and TX characteristics in ble_app_uart example

I want to transfer some data stored in nRF51822 to another BLE central device. I guess the idea is very similar to "ble_app_uart" example except that I don't need the part interfacing with local hardware UART. The app seems to send out data via notifications. It seems a very silly question, but why do I still need TX characteristics when the data are already in the notification packet?

Also, the documentation indicates "the peer can send data to the device by writing to the RX Characteristic of the service". However, the "on_write" function in "ble_nus.c" actually indicates the handle is of TX characteristic:

static void on_write(ble_nus_t * p_nus, ble_evt_t * p_ble_evt)
{
    ble_gatts_evt_write_t * p_evt_write = &p_ble_evt->evt.gatts_evt.params.write;

    if (
        (p_evt_write->handle == p_nus->rx_handles.cccd_handle)
        &&
        (p_evt_write->len == 2)
       )
    {
        if (ble_srv_is_notification_enabled(p_evt_write->data))
        {
            p_nus->is_notification_enabled = true;
        }
        else
        {
            p_nus->is_notification_enabled = false;
        }
    }
    else if (
             (p_evt_write->handle == p_nus->tx_handles.value_handle)
             &&
             (p_nus->data_handler != NULL)
            )
    {
        p_nus->data_handler(p_nus, p_evt_write->data, p_evt_write->len);
    }
    else
    {
        // Do Nothing. This event is not relevant for this service.
    }
}

Why is there such a difference?

Parents
  • The documentation is incorrect, it should be:

    TX Characteristic (UUID: 6E400002-B5A3-F393-E0A9-E50E24DCCA9E) The peer can send data to the device by writing to the TX Characteristic of the service. ATT Write Request or ATT Write Command can be used. The received data is sent on the UART interface.

    RX Characteristic (UUID: 6E400003-B5A3-F393-E0A9-E50E24DCCA9E) If the peer has enabled notifications for the RX Characteristic, the application can send data to the peer as notifications. The application will transmit all data received over UART as notifications.

    I have reported this.

Reply
  • The documentation is incorrect, it should be:

    TX Characteristic (UUID: 6E400002-B5A3-F393-E0A9-E50E24DCCA9E) The peer can send data to the device by writing to the TX Characteristic of the service. ATT Write Request or ATT Write Command can be used. The received data is sent on the UART interface.

    RX Characteristic (UUID: 6E400003-B5A3-F393-E0A9-E50E24DCCA9E) If the peer has enabled notifications for the RX Characteristic, the application can send data to the peer as notifications. The application will transmit all data received over UART as notifications.

    I have reported this.

Children
Related