本章分析telink sig mesh 工具通过网关给其他蓝牙设备配网的流程。
cpp
开始provision:
Log:
<0003>10:05:33:964 [INFO]:(GattProv)start provision for the device
<0004>10:05:33:964 [ERR]:(common)obj_adr 0x0002, not found VC node info
<0005>10:05:33:964 [INFO]:(GATEWAY)HCI_GATEWAY_CMD_SET_NODE_PARA : e9 ff 0a 9e f2 f2 fc 06 06 10 1a 27 27 31 3a 3a 44 4e 4e 00 00 00 11 22 33 44 02 00
typedef struct{
u8 net_work_key[16];//network key = 9e f2 f2 fc 06 06 10 1a 27 27 31 3a 3a 44 4e 4e
u16 key_index; //network key index = 00 00
union{ //00
mesh_ctl_fri_update_flag_t prov_flags;
u8 flags; // iv update flag
};
u8 iv_index[4]; // iv index = 11 22 33 44
u16 unicast_address; //02 00 → 分配给蓝牙设备的地址为0x0002
}provision_net_info_str;
1.Provisioning Invite
cpp
<0006>10:05:35:680 [INFO]:(GATEWAY)the node link open cmd is : d8 1e 92 20 c3 d0 f2 3f 9b f2 3c 5c 43 7e 75 cf → 目标蓝牙设备的 16 byte UUID
<0007>10:05:35:889 [INFO]:(common) ============= GATEWAY >>>>>>>>>>>>>>>>>> IUT===================
<0008>10:05:35:889 [INFO]:(common)prov invite cmd: 00 00
//Opcode = 0x00,处于 PROV_INVITE阶段 , ✅ Attention Duration = 0x00 表示:停止当前正在进行的 Attention 过程(即关闭识别指示)。
telink用了一个枚举来指示配网执行的各个阶段,请参考:
//provison pdu part
typedef enum{
PRO_INVITE = 0, //→ 当前处于 PROV_INVITE阶段
PRO_CAPABLI = 1,
PRO_START = 2,
PRO_PUB_KEY = 3,
PRO_INPUT_COM = 4,
PRO_CONFIRM = 5,
PRO_RANDOM = 6,
PRO_DATA = 7,
PRO_COMPLETE = 8,
PRO_FAIL = 9,
PRO_REC_REQ = 10,
PRO_REC_RSP = 11,
PRO_REC_GET = 12,
PRO_REC_LIST = 13,
PRO_COMMAND_ACK = 14,
PRO_BEARS_CTL = 15,
PRO_BEACON = 16,
PRO_RFU = 17,
}PRO_CMD_ENUM;
请参考Bluetooth Mesh Profile Specification:

2.Provisioning capabilities
cpp
<0009>10:05:36:127 [INFO]:(common) ============= GATEWAY <<<<<<<<<<<<<<<<<< IUT===================
<0010>10:05:36:127 [INFO]:(common)prov capa cmd: 01 02 00 01 00 00 00 00 00 00 00 00
//FIPS P-256(NIST P-256 / secp256r1)是一种标准化的 256 位椭圆曲线,提供约 128 位安全强度,是 Bluetooth Mesh 配网过程中强制使用的加密基础,用于安全地建立设备间的共享密钥。
请参考Bluetooth Mesh Profile Specification:

| 字段 | 值(Hex) | 解释 |
|---|---|---|
| PRO_CAPABLI | 01 | Opcode = Provisioning capabilities ✅ |
| Number of Elements | 02 |
设备有 2 个元素(比如主控 + 一个传感器或灯) |
| Supported Algorithms | 00 01 |
支持 FIPS P-256 椭圆曲线(Bit 0 = 1) → 即 只支持标准 ECC 算法(0x0001) |
| Public Key Type | 00 |
不支持 OOB 公钥传输(使用 on-the-fly 生成) |
| Static OOB Type | 00 |
不支持 Static OOB(即不能通过预共享密钥配网) |
| Output OOB Size | 00 |
不支持 Output OOB(如 LED 闪烁、屏幕显示等) |
| Output OOB Action | 00 00 |
无 Output 动作 |
| Input OOB Size | 00 |
不支持 Input OOB(如按键输入、扫码等) |
| Input OOB Action | 00 00 |
无 Input 动作 |
3.Provisioning Start
cpp
<0011>10:05:36:143 [INFO]:(common) ============= GATEWAY >>>>>>>>>>>>>>>>>> IUT===================
<0012>10:05:36:143 [INFO]:(common)prov start cmd: 02 00 00 00 00 00
请参考Bluetooth Mesh Profile Specification:

| 字节位置 | 值(Hex) | 含义 |
|---|---|---|
| [0] | 02 |
Opcode = Provisioning Start ✅ |
| [1] | 00 |
Algorithm = 0x00 → FIPS P-256 Elliptic Curve(这是唯一合法值,强制要求) |
| [2] | 00 |
Public Key = 0 → 不使用 OOB 公钥(设备使用临时生成的公钥) |
| [3] | 00 |
Authentication Method = No OOB(无带外认证) |
| [4] | 00 |
Authentication Action = 0(No OOB 时此字段忽略) |
| [5] | 00 |
Authentication Size = 0(No OOB 时无 OOB 值) |