在 Bluetooth Mesh 网络中,设备完成 Provisioning(配网) 后,虽然已分配了 地址(Unicast Address) 和 网络密钥(NetKey),但此时它还不能接收任何应用层命令(如开关灯、调光等),因为它的 Model 尚未绑定 AppKey。
未绑定 AppKey 的 Model 会丢弃所有应用消息,即使地址匹配!Binding(绑定)就是将一个 AppKey 与某个 Model 关联,表示该 Model 可以处理使用此 AppKey 加密的消息。
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