在原先bluez的工程下
./configure --prefix=/usr --mandir=/usr/share/man --sysconfdir=/etc --localstatedir=/var --enable-mesh make -j8
有时候会出现以下错误
概率是编译器不能正常识别该变量,改改,通过即可.
查询版本,还是老版本.安装下
sudo make install
接下来就是执行下面这个指令启动 meshctl
➜ tools ./meshctl --config mesh
修复此问题,将json复制到环境变量中
sudo cp local_node.json /home/***/.config/meshctl/ sudo cp prov_db.json /home/***/.config/meshctl/
运行通过.
进入meshctl 环境
meshctl
输入 discover-unprovisioned on 命令会自动搜索周围未配置的 sig mesh 设备
[meshctl]# discover-unprovisioned on SetDiscoveryFilter success Discovery started Adapter property changed [CHG] Controller A0:D3:7A:DD:18:D1 Discovering: yes Mesh Provisioning Service (00001827-0000-1000-8000-00805f9b34fb) Device UUID: dc234e9d0cc550156b657964396b3471 OOB: 0000 [NEW] Device DC:23:4E:9D:0C:C5 DC-23-4E-9D-0C-C5
用下列命令将配网安全等级设置为0:(从涂鸦IOT平台上创建的灯采用的认证机制是:no oob)
[meshctl]# security 0 Provision Security Level set to 0 (low)
然后调用 provision
对设备进行连接配置:(其中 Composition data 就是该节点的配置信息)
[meshctl]# provision dc234e9d0cc550156b657964396b3471 Trying to connect Device DC:23:4E:9D:0C:C5 DC-23-4E-9D-0C-C5 Adapter property changed [CHG] Controller A0:D3:7A:DD:18:D1 Discovering: no Connection successful Service added /org/bluez/hci0/dev_DC_23_4E_9D_0C_C5/service0008 Service added /org/bluez/hci0/dev_DC_23_4E_9D_0C_C5/service000d Service added /org/bluez/hci0/dev_DC_23_4E_9D_0C_C5/service0011 Char added /org/bluez/hci0/dev_DC_23_4E_9D_0C_C5/service0011/char0012: Char added /org/bluez/hci0/dev_DC_23_4E_9D_0C_C5/service0011/char0016: Service added /org/bluez/hci0/dev_DC_23_4E_9D_0C_C5/service001a Char added /org/bluez/hci0/dev_DC_23_4E_9D_0C_C5/service001a/char001b: Char added /org/bluez/hci0/dev_DC_23_4E_9D_0C_C5/service001a/char001f: Service added /org/bluez/hci0/dev_DC_23_4E_9D_0C_C5/service0023 Service added /org/bluez/hci0/dev_DC_23_4E_9D_0C_C5/service0027 Services resolved yes Found matching char: path /org/bluez/hci0/dev_DC_23_4E_9D_0C_C5/service0011/char0016, uuid 00002adb-0000-1000-8000-00805f9b34fb Found matching char: path /org/bluez/hci0/dev_DC_23_4E_9D_0C_C5/service0011/char0012, uuid 00002adc-0000-1000-8000-00805f9b34fb Start notification on /org/bluez/hci0/dev_DC_23_4E_9D_0C_C5/service0011/char0012 Characteristic property changed /org/bluez/hci0/dev_DC_23_4E_9D_0C_C5/service0011/char0012 AcquireNotify success: fd 7 MTU 250 Notify for Mesh Provisioning Out Data started Open-Node: 0x55ca07d0c530 Open-Prov: 0x55ca07d2a5d0 Open-Prov: proxy 0x55ca07d1fb00 Initiated provisioning .................. Mesh session is open Characteristic property changed /org/bluez/hci0/dev_DC_23_4E_9D_0C_C5/service001a/char001f AcquireWrite success: fd 8 MTU 250 GATT-TX: 02 f4 9e 64 99 fe 13 cd c8 9b 0e 1c e5 61 82 cc GATT-TX: ab f5 83 70 GATT-TX: 00 f4 b2 38 02 d1 dc 42 cd 7a 74 ff fa 2d 4f c6 GATT-TX: a3 0b b0 be 8f 0c GATT-RX: 02 f4 03 5c 17 8b 92 47 bc 72 2c 1f 9f 82 e8 9d GATT-RX: 2e 13 13 a1 cf 11 Proxy Accept list filter length: 0 GATT-RX: 00 f4 f5 58 82 02 78 6f 73 eb 26 5e 76 fc 93 6c GATT-RX: ad 89 c4 76 96 51 76 42 a1 1f 60 9e 3d 05 GATT-RX: 00 f4 82 bd 50 bd 97 e2 d2 f1 82 8b af 33 59 46 GATT-RX: 97 82 f6 63 6c eb 05 36 a9 4a 0f bb b1 88 GATT-RX: 00 f4 64 44 dd b4 81 03 55 07 8e 2a a8 66 a4 ea GATT-RX: 1b 62 02 c2 d0 2a d7 b8 28 98 db b7 a8 7b GATT-RX: 00 f4 e6 a5 23 e0 d3 d3 04 b1 4c 91 ed 32 b7 f6 GATT-RX: d4 f5 56 ad 8b 79 2f 4e 7b c7 47 1e e3 6f GATT-RX: 00 f4 4e 5d 88 52 22 a5 73 18 35 e9 84 1f 03 ad GATT-RX: 23 43 e7 b4 8c e1 e9 01 GATT-TX: 00 f4 2b 62 8c 1e e2 d1 65 31 1d 78 04 28 5d 16 GATT-TX: b2 b8 7f fe 21 62 32 b5 f3 [SigMesh-Node-0100]#
使用 menu config 进入子目录,使用 target 0100 选择当前要配置的节点为 0100 ;
用 netkey-add 0 给设备配置第0个网络秘钥,使用 appkey-add 1 给设备配置第1个应用级别秘钥 (网络秘钥和APP秘钥是 mesh 规范中要求的,该秘钥可以在 meshctl 主页菜单执行 mesh-info 看到);
最后用 bind 0 1 1000 实现将 model:1000 绑定(绑定时采用net-key 0,app-key 1)
ps: 订阅与发布是 sig mesh 实现联动控制的机制,每一个事件和动作都抽象为 model,比如:onoff model 就是规定开关逻辑的模型,其 id 也是规定死的: 0x1000
[SigMesh-Node-0100]# menu config [SigMesh-Node-0100]# target 0100 [config: Target = 0100]# netkey-add 0 [config: Target = 0100]# appkey-add 1 [config: Target = 0100]# bind 0 1 1000
从 config 子菜单返回,进入 onoff 子菜单,然后选择目标 0100,之后就可以用 onoff 命令来实现控制了:(之后如果再次打开 meshctl,只需要调用 connect 0 0100
即可实现再次连接)
[config: Target = 0100]# back [config: Target = 0100]# menu onoff [config: Target = 0100]# target 0100 [on/off: Target = 0100]# onoff 0 [on/off: Target = 0100]# onoff 1