蓝牙学习之Provision(7)bind (1)

在 Bluetooth Mesh 网络中,设备完成 Provisioning(配网) 后,虽然已分配了 地址(Unicast Address) 和 网络密钥(NetKey),但此时它还不能接收任何应用层命令(如开关灯、调光等),因为它的 Model 尚未绑定 AppKey。

未绑定 AppKey 的 Model 会丢弃所有应用消息,即使地址匹配!Binding(绑定)就是将一个 AppKey 与某个 Model 关联,表示该 Model 可以处理使用此 AppKey 加密的消息。

cpp 复制代码
bind_all
<0000>10:07:34:788 [INFO]:(KEYBIND)start key bind and the appkey is : 60 96 47 71 73 4f bd 76 e3 b4 05 19 d1 d9 4a 48 
<0001>10:07:34:788 [INFO]:(GATEWAY)HCI_GATEWAY_CMD_START_KEYBIND : e9 ff 0b 00 00 00 60 96 47 71 73 4f bd 76 e3 b4 05 19 d1 d9 4a 48 

为model绑定app_key。点击bind_all为model绑定app_key。
bind_all对应的命令为:HCI_CMD_GATEWAY_CTL+ HCI_GATEWAY_CMD_START_KEYBIND + fast_bind + +app_key index(2 byte)+app_key(16 bytes)。即:e9 ff + 0b + fast_bind + app_key index(2 byte)+app_key(16 bytes)。

fast_bind → 00 
app_key index(2 byte) → 00 00 
app_key(16 bytes)     → 60 96 47 71 73 4f bd 76 e3 b4 05 19 d1 d9 4a 48 

关于fast_bind标志位
fast_bind为1时:网关只会下发appkey add,被provision的设备需打开默认绑定功能(PROVISION_FLOW_SIMPLE_EN设置为1)。
fast_bind为0时:网关默认绑定全部model id,为了节省时间,用户可选择需要绑定的model id。网关端打开宏MD_BIND_WHITE_LIST_EN,需要绑定的model id详见Mesh_common.c文件中master_filter_list[],用户可根据需要自行修改。

<0002>10:07:34:868 [INFO]:(GATEWAY) gateway mesh cmd sendback src:0001 dst:0002,opcode is 0880: ff  → 在SDK里有定义:#define COMPOSITION_DATA_GET 0x0880
GATEWAY(0x0001)发送给设备(0x0002),opcode为0x0880

<0003>10:07:35:748 [INFO]:(cmd_rsp)Status Rsp______________: 02 00 01 00 02 00 11 02  01 00 33 33 69 00 07 00  00 00 0c 01 00 00 02 00  03 00 00 10 02 10 04 10 06 10 07 10 00 13 01 13  03 13 04 13 11 02 00 00  00 00 02 00 02 10 06 13  

02 00:Destination Address
01 00:Source Address
02 00:unicastAddress
11 02:Company ID
01 00:Product ID
33 33:Version ID
69 00:CRPL
07 00:Features → 支持 Relay(1) + Proxy(2) + Friend(4)
-------------------element1------------------
00 00:u16 location;
0c :u8  num_s → SIG Models = 12
01 :u8  num_v → Vendor Models = 1
00 00:  0x0000 -- Configuration Server
02 00:  0x0002 -- Health Server
03 00:  0x0003 -- Health Client
00 10:  0x1000 -- Generic OnOff Server
02 10:  0x1002 -- Generic Level Server
04 10:  0x1004 -- Generic Power OnOff Server
06 10:  0x1006 -- Light Lightness Server
07 10:  0x1007 -- Light CTL Server
00 13:  0x1300 -- Scene Server
01 13:  0x1301 -- Scene Setup Server
03 13:  0x1303 -- Scheduler Server
04 13:  0x1304 -- Scheduler Setup Server
11 02 00 00: 0x00000211 → Vendor Model
-------------------element2------------------
00 00 :u16 location;
02 :u8  num_s → SIG Models = 2
00 :u8  num_v → Vendor Models = 0
02 10:  0x1002 -- Generic Level Server
06 13:  0x1306 -- Light HSL Server

关于u16 location的说明,参考下表:

Location = 0x0000 的含义:

"未指定位置" 或 "位置不重要"

这是 Bluetooth SIG 定义的保留值,表示:

  • 该 Element 没有明确的物理位置;
  • 或者设备是单一功能单元(如一个灯泡),无需区分位置;
  • 或者厂商未配置具体位置信息。

Specifications | Bluetooth® Technology Website

值(Hex) 含义
0x0000 Unassigned / Not Specified(未分配)✅
0x0001 Top
0x0002 Bottom
0x0003 Front
0x0004 Back
0x0005 Left
0x0006 Right
0x0007 Primary (主单元)
0x0008 Secondary (副单元)
... (还有更多,如 Ceiling、Wall、Outdoor 等)

关于:

00 00: 0x0000 -- Configuration Server

02 00: 0x0002 -- Health Server

03 00: 0x0003 -- Health Client

相关推荐
盐焗西兰花1 小时前
鸿蒙学习实战之路-Reader Kit构建阅读器最佳实践
学习·华为·harmonyos
深蓝海拓2 小时前
PySide6从0开始学习的笔记(二十七) 日志管理
笔记·python·学习·pyqt
慎独4132 小时前
科学赋能,让孩子专注高效爱上学习
学习
LGL6030A2 小时前
Java学习历程26——线程安全
java·开发语言·学习
学历真的很重要3 小时前
【系统架构师】第二章 操作系统知识 - 第二部分:进程管理(详解版)
学习·职场和发展·系统架构·系统架构师
Nebula_g3 小时前
线程进阶: 无人机自动防空平台开发教程(更新)
java·开发语言·数据结构·学习·算法·无人机
星期五不见面3 小时前
机器人学习!(二)ROS2-节点(7)2026/02/03
学习
狂奔蜗牛飙车3 小时前
Python学习之路-循环语句学习详解
python·学习·python学习·#python学习笔记·循环语句详解
电饭叔4 小时前
Jupyter学习中的问题--FileNotFoundError
ide·学习·jupyter
峥嵘life4 小时前
Android16 【CTS】CtsMediaCodecTestCases等一些列Media测试存在Failed项
android·linux·学习