当前页面为 开发中 版本,查看特定版本的文档,请在页面左下角的下拉菜单中进行选择。

Bluetooth: HCI UART

1 功能概述

此项目演示单BLE Controller的功能,支持 HCI UART,可以通过串口发送HCI命令,用于 DTM,或者配合外部 Host 使用。

2 环境要求

  • board: 支持 BLE 的蓝牙设备

  • uart: hci uart (8n1, 115200)

  • 测试软件: Panchip Serial Assistant (或其他串口软件)

3 编译和烧录

例程位置:zephyr\samples_panchip\bluetooth\hci_uart

使用 ZAL 工具可以对其进行编译、烧录、打开 VS Code 调试等操作。关于 ZAL 工具的详细介绍请参考:Zephyr APP Launcher 工具介绍

4 演示说明

  1. HCI_Reset

    串口发送 (0x) 01 03 0C 00

    串口返回 (0x) 04 0E 04 01 03 0C 00

  2. LE Transmitter Test

    串口发送 (0x) 01 1E 20 03 00 25 00

    串口返回 (0x) 04 0E 04 01 1E 20 00

  3. LE Test End

    串口发送 (0x) 01 1F 20 00

    串口返回 (0x) 04 0E 06 01 1F 20 00 00 00

有关DTM测试流程请参考Core Specification v5.3 Volume 6 Part F.

5 Host Controller Interface

主机控制器接口(HCI)提供了访问蓝牙控制器功能的统一接口方法。有关接口的细节可以参考 Core Specification v5.3 Volume 4.

5.1 HCI Command packet

The HCI Command packet is used to send commands to the Controller from the Host.

image

HCI Command Packet

Figure 1 HCI Command packet

OpCode: (Size: 2 octets)

Value

Parameter Description

0xXXXX

OGF Range (6 bits): 0x00 to 0x3F (0x3F reserved for vendor-specific debug commands)
OCF Range (10 bits): 0x0000 to 0x03FF

HCI OpCode Group Field (OGF)

Value

Description

BT_OGF_LINK_CTRL

0x01

Link Control commands

BT_OGF_BASEBAND

0x03

Controller & Baseband commands

BT_OGF_INFO

0x04

Informational parameters

BT_OGF_STATUS

0x05

Status parameters

BT_OGF_LE

0x08

LE Controller commands

Parameter_Total_Length: (Size: 1 octet)

Value

Parameter Description

0xXX

Lengths of all of the parameters contained in this packet measured in octets. (N.B.: total length of parameters, not number of parameters)

Parameter 0 - N: (Size: Parameter Total Length)

Value

Parameter Description

0xXX

Lengths of all of the parameters contained in this packet measured in octets. (N.B.: total length of parameters, not number of parameters)

5.2 HCI Event packet

The HCI Event packet is used by the Controller to notify the Host when events occur.

image

HCI Event Packet

Figure 2 HCI Event packet

Event Code: (Size: 1 octet)

Value

Parameter Description

0xXX

Each event is assigned a 1-Octet event code used to uniquely identify different types of events.
Range: 0x00 to 0xFF (The event code 0xFF is reserved for the event code used for vendor-specific debug events.)

Parameter_Total_Length: (Size: 1 octet)

Value

Parameter Description

0xXX

Length of all of the parameters contained in this packet, measured in octets.

Event_Parameter 0 - N: (Size: Parameter_Total_Length)

Value

Parameter Description

0xXX

Each event has a specific number of parameters associated with it. These parameters and the size of each of the parameters are defined for each event. Each parameter is an integer number of octets in size.

6 RAM/Flash资源使用情况

Memory region         Used Size  Region Size  %age Used
FLASH:       22176 B       384 KB      5.64%
SRAM:       20798 B        50 KB     40.62%