这是最新(主)开发分支的文档。如果您正在查找以前版本的文档,使用左侧的下拉菜单选择所需的版本。

Bluetooth: Broadcaster

概述

本示例演示如何使用 BLE 的广播功能。 程序运行后,周期性发送广播数据。数据包的内容为厂商 自定义字段,每发送一次广播,厂商自定义字段中的计数器递增 1 ,计数器为 1 Byte(当计数值达到255后, 将回滚至 0 )。

环境要求

  • 支持 BLE 功能的开发板

编译和烧录

示例位置:

examples/bluetooth/broadcaster

编译、烧录等操作,具体参考 快速入门 章节 。

运行结果

I/broadcaster     [0.110] Starting Broadcaster

I/bt_hci_core     [0.134] Identity: 28:6D:CE:01:02:03 (public)
I/bt_hci_core     [0.140] HCI: version 4.2 (0x08) revision 0x0709, manufacturer 0x070c
I/bt_hci_core     [0.146] LMP: version 4.2 (0x08) subver 0x0709
I/broadcaster     [0.152] Bluetooth initialized

I/broadcaster     [1.156] Sending advertising data: 0x00

I/broadcaster     [3.162] Sending advertising data: 0x01

I/broadcaster     [5.168] Sending advertising data: 0x02

I/broadcaster     [7.174] Sending advertising data: 0x03

I/broadcaster     [9.180] Sending advertising data: 0x04