This is the documentation for the latest (main) development branch of Zephyr. If you are looking for the documentation of previous releases, use the drop-down list at the bottom of the left panel and select the desired version.

HCI RAW channel


HCI RAW channel API is intended to expose HCI interface to the remote entity. The local Bluetooth controller gets owned by the remote entity and host Bluetooth stack is not used. RAW API provides direct access to packets which are sent and received by the Bluetooth HCI driver.

API Reference

group hci_raw

HCI RAW channel.


BT_HCI_RAW_CMD_EXT(_op, _min_len, _func)

Helper macro to define a command extension.

  • _op – Opcode of the command.

  • _min_len – Minimal length of the command.

  • _func – Handler function to be called.


enum [anonymous]



Passthrough mode.

    While in this mode the buffers are passed as is between the stack
    and the driver.
enumerator BT_HCI_RAW_MODE_H4 = 0x01

H:4 mode.

    While in this mode H:4 headers will added into the buffers
    according to the buffer type when coming from the stack and will be
    removed and used to set the buffer type.


int bt_send(struct net_buf *buf)

Send packet to the Bluetooth controller.

Send packet to the Bluetooth controller. Caller needs to implement netbuf pool.

  • buf – netbuf packet to be send


Zero on success or (negative) error code otherwise.

int bt_hci_raw_set_mode(uint8_t mode)

Set Bluetooth RAW channel mode.

Set access mode of Bluetooth RAW channel.

  • mode – Access mode.


Zero on success or (negative) error code otherwise.

uint8_t bt_hci_raw_get_mode(void)

Get Bluetooth RAW channel mode.

Get access mode of Bluetooth RAW channel.


Access mode.

void bt_hci_raw_cmd_ext_register(struct bt_hci_raw_cmd_ext *cmds, size_t size)

Register Bluetooth RAW command extension table.

Register Bluetooth RAW channel command extension table, opcodes in this table are intercepted to sent to the handler function.

  • cmds – Pointer to the command extension table.

  • size – Size of the command extension table.

int bt_enable_raw(struct k_fifo *rx_queue)

Enable Bluetooth RAW channel:

Enable Bluetooth RAW HCI channel.

  • rx_queue – netbuf queue where HCI packets received from the Bluetooth controller are to be queued. The queue is defined in the caller while the available buffers pools are handled in the stack.


Zero on success or (negative) error code otherwise.

struct bt_hci_raw_cmd_ext
#include <hci_raw.h>

Public Members

uint16_t op

Opcode of the command.

size_t min_len

Minimal length of the command.

uint8_t (*func)(struct net_buf *buf)

Handler function.

Handler function to be called when a command is intercepted.

Param buf:

Buffer containing the command.


HCI Status code or BT_HCI_ERR_EXT_HANDLED if command has been handled already and a response has been sent as oppose to BT_HCI_ERR_SUCCESS which just indicates that the command can be sent to the controller to be processed.