HCI RAW channel

Overview

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.

Defines

BT_L2CAP_MTU
BT_BUF_ACL_SIZE

Data size needed for ACL buffers

BT_HCI_ACL_COUNT
BT_BUF_TX_SIZE
BT_HCI_ERR_EXT_HANDLED
BT_HCI_RAW_CMD_EXT(_op, _min_len, _func)

Helper macro to define a command extension

Parameters
  • _op: Opcode of the command.

  • _min_len: Minimal length of the command.

  • _func: Handler function to be called.

Enums

enum [anonymous]

Values:

enumerator BT_HCI_RAW_MODE_PASSTHROUGH

Passthrough mode

    While in this mode the buffers are passed as is between the stack
    and the driver.

enumerator BT_HCI_RAW_MODE_H4

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.

Functions

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.

Return

Zero on success or (negative) error code otherwise.

Parameters
  • buf: netbuf packet to be send

int bt_hci_raw_set_mode(uint8_t mode)

Set Bluetooth RAW channel mode.

Set access mode of Bluetooth RAW channel.

Return

Zero on success or (negative) error code otherwise.

Parameters
  • mode: Access mode.

uint8_t bt_hci_raw_get_mode(void)

Get Bluetooth RAW channel mode.

Get access mode of Bluetooth RAW channel.

Return

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.

Parameters
  • 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.

Return

Zero on success or (negative) error code otherwise.

Parameters
  • 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.

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.

Return

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.

Parameters
  • buf: Buffer containing the command.