How to Use HCI Raw Data Mode in CYW20706 - KBA225970

Version 3

    Version: **

     

    Translation - Japanese: CYW20706のHCI Raw Dataモードの使い方 - KBA225970- Community Translated (JA)

    The HCI UART in CYW20706 supports two modes: HCI Mode and Raw Data Mode.

    For HCI Mode, you can send HCI commands to control the device as described in “WICED HCI Control Protocol.pdf” in the SDK. For HCI Mode, you can use it as a common UART interface for your application.

    This KBA explains how to use the HCI Raw Data mode. A demo code based on SPP is attached with this article. The demo shows a HCI UART to SPP bridge which transfers data between the HCI UART and peer device through BT SPP.

     

    1. Set the HCI UART to Raw Data Mode in transport_cfg.

    The following configuration sets the transport interface to HCI UART, RAW Data Mode with 115200 baud rate. The data received by the UART is handled in the hci_control_proc_rx_cmd function.

     

    const wiced_transport_cfg_t transport_cfg =

    {

        WICED_TRANSPORT_UART,

        {  WICED_TRANSPORT_UART_RAW_MODE, 115200 },

        {  TRANS_UART_BUFFER_SIZE, 2 },

        NULL,

        hci_control_proc_rx_cmd,

        NULL

    };

     

    2. Define the hci_control_proc_rx_cmd function to handle the received data. The *p_buffer parameter is a pointer to the received data; length is the bytes number of the data.

    uint32_t hci_control_proc_rx_cmd( uint8_t *p_buffer, uint32_t length )

    {

       uint8_t *p_data = p_buffer;

       …

       …

    }

     

    3. There is a little difference with the HCI Mode. You must return the data length read by the hci_control_proc_rx_cmd function because the RAW Data Transport uses a circular buffer to receive the data. Add the following code at the end of the function.

    return length;

     

    4. When data is received from the SPP peer device, send the data to HCI UART with the following API function.

    wiced_result_t wiced_transport_send_data ( uint16_t code, uint8_t* p_data, uint16_t length );

    Using the demo

    1. Download and extract the attached file. Copy the extracted files to the CYW20706 project (for example, 20706-A2_Bluetooth\apps\demo).
    2. Create a new make target such as demo.spp-CYW920706WCDEVAL download.
    3. Plug the CYW920706WCDEVAL Kit board to the computer. Build the project and download it to the device.
    4. Connect the device named “SPP test” with a phone which has an app supporting the SPP function.
    5. Open a UART application on the computer and select HCI UART.
    6. Send data from computer or phone. You can receive the data on the other side.