matter搭建环境

前言

  • 一定要fan墙
  • 最好使用ubuntu20以上版本,测试发现ubuntu18搭建环境时提示python版本是3.6搭建环境失败。后来官网查到matter需要python3.8以上版本
    • 目前测试ubuntu20&&ubuntu22都可以正常搭建环境
  • 支持蓝牙4.0以上的pc,pc没有可外接usb蓝牙适配器(适配器需要支持ubuntu)

1. 下载代码

git clone --recurse-submodules https://github.com/project-chip/connectedhomeip.git

 2. 切换到稳定分支

先查看分支

git branch -a

输出

切换到最新的稳定分支,test_event_7.lts此分支为长期支持版本

git checkout test_event_7.lts

更新依赖库执行。需要注意以后每次切换分支都需要执行。

git submodule update --init

3. 安装编译需要的环境

  • 安装编译依赖包
sudo apt-get install git gcc g++ pkg-config libssl-dev libdbus-1-dev libglib2.0-dev libavahi-client-dev ninja-build python3-venv python3-dev python3-pip unzip libgirepository1.0-dev libcairo2-dev libreadline-dev
  • 准备编译matter所需环境。注:如切换了其他分支需要重新运行
source scripts/bootstrap.sh

输出

  • 激活编译matter环境
source scripts/activate.sh

输出

4. esp32目标板demo编译下载

以esp32为例,先搭建esp32的运行环境,安装官方的文档搭建esp32的编译环境

4.1 下载esp-idf代码(来源esp32官方)

git clone --recursive https://github.com/espressif/esp-idf.git

4.2 切换esp32-idf稳定分支(来源esp32官方)

cd esp-idf; git checkout v4.4.1; git submodule update --init --recursive;

4.3 安装esp32的编译环境(来源esp32官方)

cd esp-idf; ./install.sh;

4.4 声明esp32的编译环境(来源esp32官方)

. ./export.sh;

4.5 切换到matter 的 esp32 demo的目录(来源matter官方)

cd ../connectedhomeip/examples/all-clusters-app/esp32/

4.6 设置目标(来源matter官方)

idf.py set-target esp32

4.7 编译(来源matter官方)

idf.py build

4.8 擦除esp32目标板 flash(来源matter官方)

idf.py erase-flash

4.9 烧录程序和打开串口监视(来源matter官方)

idf.py flash monitor

esp32 已经跑起来了,log如下:

I (28) boot: ESP-IDF v4.4.1 2nd stage bootloader
I (28) boot: compile time 15:23:22
I (28) boot: chip revision: 1
I (31) boot_comm: chip revision: 1, min. bootloader chip revision: 0
I (38) boot.esp32: SPI Speed      : 40MHz
I (43) boot.esp32: SPI Mode       : DIO
I (47) boot.esp32: SPI Flash Size : 2MB
I (52) boot: Enabling RNG early entropy source...
I (57) boot: Partition Table:
I (61) boot: ## Label            Usage          Type ST Offset   Length
I (68) boot:  0 nvs              WiFi data        01 02 00009000 00006000
I (76) boot:  1 phy_init         RF data          01 01 0000f000 00001000
I (83) boot:  2 factory          factory app      00 00 00010000 001db000
I (91) boot:  3 ot_storage       Unknown data     01 3a 001eb000 00002000
I (98) boot: End of partition table
I (102) boot_comm: chip revision: 1, min. application chip revision: 0
I (109) esp_image: segment 0: paddr=00010020 vaddr=3f400020 size=2c180h (180608) map
I (183) esp_image: segment 1: paddr=0003c1a8 vaddr=3ffbdb60 size=03e70h ( 15984) load
I (190) esp_image: segment 2: paddr=00040020 vaddr=400d0020 size=d106ch (856172) map
I (500) esp_image: segment 3: paddr=00111094 vaddr=3ffc19d0 size=01758h (  5976) load
I (503) esp_image: segment 4: paddr=001127f4 vaddr=40080000 size=1c98ch (117132) load
I (554) esp_image: segment 5: paddr=0012f188 vaddr=50000000 size=00010h (    16) load
I (568) boot: Loaded app from partition at offset 0x10000
I (568) boot: Disabling RNG early entropy source...
I (580) cpu_start: Pro cpu up.
I (580) cpu_start: Starting app cpu, entry point is 0x400813cc
I (0) cpu_start: App cpu up.
I (596) cpu_start: Pro cpu start user code
I (596) cpu_start: cpu freq: 160000000
I (596) cpu_start: Application information:
I (601) cpu_start: Project name:     chip-all-clusters-app
I (607) cpu_start: App version:      test_event_4_2021_07_06-1275-g1
I (614) cpu_start: Compile time:     Sep 18 2022 15:23:09
I (620) cpu_start: ELF file SHA256:  23ea219fee317b50...
I (626) cpu_start: ESP-IDF:          v4.4.1
I (631) heap_init: Initializing. RAM available for dynamic allocation:
I (638) heap_init: At 3FFAFF10 len 000000F0 (0 KiB): DRAM
I (644) heap_init: At 3FFB6388 len 00001C78 (7 KiB): DRAM
I (650) heap_init: At 3FFB9A20 len 00004108 (16 KiB): DRAM
I (657) heap_init: At 3FFD1D38 len 0000E2C8 (56 KiB): DRAM
I (663) heap_init: At 3FFE0440 len 00003AE0 (14 KiB): D/IRAM
I (669) heap_init: At 3FFE4350 len 0001BCB0 (111 KiB): D/IRAM
I (675) heap_init: At 4009C98C len 00003674 (13 KiB): IRAM
I (683) spi_flash: detected chip: gd
I (686) spi_flash: flash io: dio
W (690) spi_flash: Detected size(4096k) larger than the size in the binary image header(2048k). Using the size in the binary image header.
I (706) cpu_start: Starting scheduler on PRO CPU.
I (0) cpu_start: Starting scheduler on APP CPU.
I (714) all-clusters-app: All Clusters Demo!
I (724) all-clusters-app: This is ESP32 chip with 2 CPU cores, WiFi/BT/BLE, 
I (724) all-clusters-app: silicon revision 1, 
I (734) all-clusters-app: 2MB external flash
I (774) wifi:wifi driver task: 3ffd90b4, prio:23, stack:6656, core=0
I (774) system_api: Base MAC address is not set
I (774) system_api: read default base MAC address from EFUSE
I (784) wifi:wifi firmware version: 63017e0
I (794) wifi:wifi certification version: v7.0
I (794) wifi:config NVS flash: enabled
I (794) wifi:config nano formating: disabled
> I (804) wifi:Init data frame dynamic rx buffer num: 32
I (804) wifi:Init management frame dynamic rx buffer num: 32
I (814) wifi:Init management short buffer num: 32
I (814) wifi:Init dynamic tx buffer num: 32
I (814) wifi:Init static rx buffer size: 1600
I (814) wifi:Init static rx buffer num: 10
I (834) wifi:Init dynamic rx buffer num: 32
I (834) wifi_init: rx ba win: 6
I (834) wifi_init: tcpip mbox: 32
I (844) wifi_init: udp mbox: 6
I (844) wifi_init: tcp mbox: 6
I (844) wifi_init: tcp tx win: 5744
I (844) wifi_init: tcp rx win: 5744
I (854) wifi_init: tcp mss: 1440
I (854) wifi_init: WiFi IRAM OP enabled
I (854) wifi_init: WiFi RX IRAM OP enabled
I (874) chip[DL]: AUDIT: ===== RANDOM NUMBER GENERATOR AUDIT START ====
I (874) chip[DL]: AUDIT: * Validate buf1 and buf2 are <<<different every run/boot!>>>
I (884) chip[DL]: AUDIT: * Validate r1 and r2 are <<<different every run/boot!>>>
I (894) chip[DL]: AUDIT: * buf1: 3EDD8AA032ECE3C159977B628BBA366B
I (894) chip[DL]: AUDIT: * buf2: DC14F9B7414EB75951291758D212AFA5
I (904) chip[DL]: AUDIT: * r1: 0xAB8C61C2 r2: 0xC008600F
I (904) chip[DL]: AUDIT: ===== RANDOM NUMBER GENERATOR AUDIT END ====
I (934) chip[DL]: NVS set: chip-counters/reboot-count = 7 (0x7)
I (934) all-clusters-app: Setup discriminator: 3840 (0xf00)
I (934) all-clusters-app: Setup PIN code: 20202021 (0x1344225)
I (934) BTDM_INIT: BT controller compile version [5688ed5]
I (954) all-clusters-app: Short Manual(decimal) setup code: 34970112332
I (954) all-clusters-app: Long Manual(decimal) setup code:  749701123309050177298
I (954) phy_init: phy_version 4670,719f9f6,Feb 18 2021,17:07:07
I (964) all-clusters-app: QR CODE Text: 'MT:C8XA0SRB00KA0648G00'
I (974) all-clusters-app: Copy/paste the below URL in a browser to see the QR CODE:
        https://dhrishi.github.io/connectedhomeip/qrcode.html?data=MT%3AC8XA0SRB00KA0648G00
I (1344) CHIP[DL]: BLE host-controller synced
I (1844) chip[DL]: Configuring CHIPoBLE advertising (interval 25 ms, connectable, device name MATTER-3840)
I (1854) NimBLE: GAP procedure initiated: advertise; 
I (1864) NimBLE: disc_mode=2
I (1864) NimBLE:  adv_channel_map=0 own_addr_type=2 adv_filter_policy=0 adv_itvl_min=40 adv_itvl_max=40
I (1874) NimBLE: 

I (1884) chip[DL]: CHIPoBLE advertising started
E (1884) chip[DL]: Long dispatch time: 950 ms, for event type 2
I (1884) chip[DL]: Starting ESP WiFi layer
I (1894) wifi:mode : sta (30:ae:a4:cb:b0:40)
I (1894) wifi:enable tsf
W (1904) wifi:Haven't to connect to a suitable AP now!
I (1904) chip[DL]: Done driving station state, nothing else to do...
W (1914) wifi:Haven't to connect to a suitable AP now!
I (1914) chip[DL]: Done driving station state, nothing else to do...
I (1924) chip[ZCL]: Using ZAP configuration...
I (1934) chip[ZCL]: OpCreds: Initiating OpCreds cluster by writing fabrics list from fabric table.
I (1944) chip[ZCL]: OpCreds: Call to writeFabricsIntoFabricsListAttribute
I (1954) chip[ZCL]: OpCreds: Stored 0 fabrics in fabrics list attribute.
I (1954) app-devicecallbacks: PostAttributeChangeCallback - Cluster ID: '0x003e', EndPoint ID: '0x00', Attribute ID: '0x0003'
I (1964) app-devicecallbacks: Unhandled cluster ID: 62
I (1974) app-devicecallbacks: Current free heap: 101636

I (1974) app-devicecallbacks: PostAttributeChangeCallback - Cluster ID: '0x003e', EndPoint ID: '0x00', Attribute ID: '0x0002'
I (1994) app-devicecallbacks: Unhandled cluster ID: 62
I (2004) app-devicecallbacks: Current free heap: 101636

5. 编译matter的调试工具chiptool

5.1 前提

切换到/matter/connectedhomeip目录下,激活matter环境;

source scripts/activate.sh

5.2 基于python编译chiptool调试工具

5.2.1 安装依赖包

sudo apt-get install git gcc g++ python pkg-config libssl-dev libdbus-1-dev libglib2.0-dev libavahi-client-dev ninja-build python3-venv python3-dev python3-pip unzip libgirepository1.0-dev libcairo2-dev bluez

5.2.2 编译python调试工具

scripts/build_python.sh -m platform

编译后输出如下log:

5.2.3 激活python虚拟环境

source out/python_env/bin/activate

5.2.4 以 root 权限运行 Python CHIP 控制器,获取蓝牙接口访问权限

sudo out/python_env/bin/chip-device-ctrl

输出

/matter/connectedhomeip$ sudo out/python_env/bin/chip-device-ctrl
[sudo] password for user: 
[1663731886.612103][15024:15024] CHIP:CTL: Generating NOC
[1663731886.612171][15024:15024] CHIP:CTL: Generating ICAC
[1663731886.612209][15024:15024] CHIP:CTL: Generating RCAC
[1663731886.613118][15024:15024] CHIP:DL: AUDIT: ===== RANDOM NUMBER GENERATOR AUDIT START ====
[1663731886.613124][15024:15024] CHIP:DL: AUDIT: * Validate buf1 and buf2 are <<<different every run/boot!>>>
[1663731886.613126][15024:15024] CHIP:DL: AUDIT: * Validate r1 and r2 are <<<different every run/boot!>>>
[1663731886.613128][15024:15024] CHIP:DL: AUDIT: * buf1: C35D583E28E9E998AB1702DC43467984
[1663731886.613130][15024:15024] CHIP:DL: AUDIT: * buf2: F9A03FECA1FE4B1DB6170BFCA6D579A5
[1663731886.613136][15024:15024] CHIP:DL: AUDIT: * r1: 0xC5A9E090 r2: 0x1764E6EB
[1663731886.613138][15024:15024] CHIP:DL: AUDIT: ===== RANDOM NUMBER GENERATOR AUDIT END ====
[1663731886.613180][15024:15024] CHIP:DL: writing settings to file (/tmp/chip_factory.ini-ZzXB2c)
[1663731886.613213][15024:15024] CHIP:DL: renamed tmp file to file (/tmp/chip_factory.ini)
[1663731886.613244][15024:15024] CHIP:DL: writing settings to file (/tmp/chip_config.ini-sp44tg)
[1663731886.613324][15024:15024] CHIP:DL: renamed tmp file to file (/tmp/chip_config.ini)
[1663731886.613348][15024:15024] CHIP:DL: writing settings to file (/tmp/chip_counters.ini-cokMfh)
[1663731886.613364][15024:15024] CHIP:DL: renamed tmp file to file (/tmp/chip_counters.ini)
[1663731886.613395][15024:15024] CHIP:DL: writing settings to file (/tmp/chip_counters.ini-Yx9i8c)
[1663731886.613453][15024:15024] CHIP:DL: renamed tmp file to file (/tmp/chip_counters.ini)
[1663731886.613460][15024:15024] CHIP:DL: NVS set: chip-counters/reboot-count = 1 (0x1)
[1663731886.613484][15024:15024] CHIP:DL: writing settings to file (/tmp/chip_counters.ini-MAkVKd)
[1663731886.613526][15024:15024] CHIP:DL: renamed tmp file to file (/tmp/chip_counters.ini)
[1663731886.613536][15024:15024] CHIP:DL: NVS set: chip-counters/total-operational-hours = 0 (0x0)
[1663731886.613557][15024:15024] CHIP:DL: writing settings to file (/tmp/chip_counters.ini-J89FZd)
[1663731886.613598][15024:15024] CHIP:DL: renamed tmp file to file (/tmp/chip_counters.ini)
[1663731886.613605][15024:15024] CHIP:DL: NVS set: chip-counters/boot-reason = 0 (0x0)
[1663731886.613772][15024:15024] CHIP:DL: Got Ethernet interface: eno1
[1663731886.613897][15024:15024] CHIP:DL: Found the primary Ethernet interface:eno1
[1663731886.614029][15024:15024] CHIP:DL: Failed to get WiFi interface
[1663731886.614032][15024:15024] CHIP:DL: Failed to reset WiFi statistic counts
[1663731886.614093][15024:15024] CHIP:DL: writing settings to file (/tmp/chip_counters.ini-kLTzYd)
[1663731886.614139][15024:15024] CHIP:DL: renamed tmp file to file (/tmp/chip_counters.ini)
[1663731886.614147][15024:15024] CHIP:DL: NVS set: chip-counters/GlobalMCTR = 1000 (0x3E8)
[1663731886.615077][15024:15024] CHIP:DL: Avahi client registered
[1663731886.615238][15024:15024] CHIP:ZCL: Using ZAP configuration...
[1663731886.615445][15024:15024] CHIP:DIS: Verifying the received credentials
[1663731886.615929][15024:15024] CHIP:DIS: Added new fabric at index: 1, Initialized: 1
[1663731886.615935][15024:15024] CHIP:DIS: Assigned compressed fabric ID: 0x65869E9248648601, node ID: 0x000000000001B669
[1663731886.615940][15024:15024] CHIP:CTL: Joined the fabric at index 1. Compressed fabric ID is: 0x65869E9248648601
[1663731886.616088][15024:15024] CHIP:DIS: Failed to find a valid admin pairing. Node ID unknown
[1663731886.616094][15024:15024] CHIP:DIS: Start dns-sd server - no current nodeId
[1663731886.616100][15024:15024] CHIP:DL: MAC is not known, using a default.
[1663731886.616114][15024:15024] CHIP:DIS: Advertise commission parameter vendorID=9050 productID=65279 discriminator=3840/00
[1663731886.616122][15024:15024] CHIP:DL: Cannot get device role with Thread api client: 
[1663731886.616597][15024:15024] CHIP:DL: PublishService AF71E93BD399E588._matterc._udp5540.-1
[1663731886.617647][15024:15024] CHIP:DL: MAC is not known, using a default.
[1663731886.617661][15024:15024] CHIP:DIS: Advertise commission parameter vendorID=9050 productID=65279 discriminator=3840/00
[1663731886.617669][15024:15024] CHIP:DL: Cannot get device role with Thread api client: 
[1663731886.617818][15024:15024] CHIP:DL: PublishService AF71E93BD399E588._matterd._udp5550.-1
[1663731886.617977][15024:15024] CHIP:DL: Avahi publish service failed: ../../src/platform/Linux/DnssdImpl.cpp:478: CHIP Error 0x000000AC: Internal error
[1663731886.617984][15024:15024] CHIP:DIS: Failed to advertise commissioner: ../../src/platform/Linux/DnssdImpl.cpp:478: CHIP Error 0x000000AC: Internal error
[1663731886.629736][15024:15030] CHIP:DL: Platform main loop started.
[1663731886.630375][15024:15030] CHIP:DIS: Failed to find a valid admin pairing. Node ID unknown
[1663731886.630382][15024:15030] CHIP:DIS: Start dns-sd server - no current nodeId
[1663731886.630415][15024:15030] CHIP:DL: MAC is not known, using a default.
[1663731886.630442][15024:15030] CHIP:DIS: Advertise commission parameter vendorID=9050 productID=65279 discriminator=3840/00
[1663731886.630472][15024:15030] CHIP:DL: Cannot get device role with Thread api client: 
[1663731886.630635][15024:15030] CHIP:DL: PublishService AF71E93BD399E588._matterc._udp5540.-1
[1663731886.631453][15024:15030] CHIP:DL: MAC is not known, using a default.
[1663731886.631466][15024:15030] CHIP:DIS: Advertise commission parameter vendorID=9050 productID=65279 discriminator=3840/00
[1663731886.631472][15024:15030] CHIP:DL: Cannot get device role with Thread api client: 
[1663731886.631584][15024:15030] CHIP:DL: PublishService AF71E93BD399E588._matterd._udp5550.-1
[1663731886.631909][15024:15030] CHIP:DL: Avahi publish service failed: ../../src/platform/Linux/DnssdImpl.cpp:478: CHIP Error 0x000000AC: Internal error
[1663731886.631914][15024:15030] CHIP:DIS: Failed to advertise commissioner: ../../src/platform/Linux/DnssdImpl.cpp:478: CHIP Error 0x000000AC: Internal error
[1663731886.631925][15024:15030] CHIP:DL: Avahi re-register required
[1663731886.632267][15024:15030] CHIP:DL: Cannot get device role with Thread api client: 
[1663731886.632359][15024:15030] CHIP:DL: PublishService AF71E93BD399E588._matterc._udp5540.-1
Chip Device Controller Shell

chip-device-ctrl > [1663731887.411942][15024:15030] CHIP:DL: Avahi client registered
[1663731887.412596][15024:15030] CHIP:DIS: Failed to find a valid admin pairing. Node ID unknown
[1663731887.412600][15024:15030] CHIP:DIS: Start dns-sd server - no current nodeId
[1663731887.412610][15024:15030] CHIP:DL: MAC is not known, using a default.
[1663731887.412638][15024:15030] CHIP:DIS: Advertise commission parameter vendorID=9050 productID=65279 discriminator=3840/00
[1663731887.412648][15024:15030] CHIP:DL: Cannot get device role with Thread api client: 
[1663731887.412891][15024:15030] CHIP:DL: PublishService AF71E93BD399E588._matterc._udp5540.-1
[1663731887.413926][15024:15030] CHIP:DL: MAC is not known, using a default.
[1663731887.413940][15024:15030] CHIP:DIS: Advertise commission parameter vendorID=9050 productID=65279 discriminator=3840/00
[1663731887.413946][15024:15030] CHIP:DL: Cannot get device role with Thread api client: 
[1663731887.414160][15024:15030] CHIP:DL: PublishService AF71E93BD399E588._matterd._udp5550.-1
[1663731887.414368][15024:15030] CHIP:DL: Avahi publish service failed: ../../src/platform/Linux/DnssdImpl.cpp:478: CHIP Error 0x000000AC: Internal error
[1663731887.414374][15024:15030] CHIP:DIS: Failed to advertise commissioner: ../../src/platform/Linux/DnssdImpl.cpp:478: CHIP Error 0x000000AC: Internal error
[1663731887.427053][15024:15030] CHIP:DL: Avahi group established
[1663731888.207716][15024:15030] CHIP:DL: Avahi group established

chip-device-ctrl >

5.3 正常编译chiptool调试工具

待补充。。。

6 matter测试

6.1 准备

通过4.9中的log发现一下信息:

I (934) all-clusters-app: Setup discriminator: 3840 (0xf00) I (934) all-clusters-app: Setup PIN code: 20202021 (0x1344225)

6.2 激活python的chiptool控制器

切换到matter的对应目录输入下面命令

source scripts/activate.sh
source out/python_env/bin/activate
sudo out/python_env/bin/chip-device-ctrl

6.3 通过BLE链接Matter设备

connect -ble 3840 20202021 1234

其中:

  • 设备的判别器是3840
  • 设备的设置密码为20202021
  • 临时matter设备节点 ID 为1234

输出信息:

chip-device-ctrl > connect -ble 3840 20202021 1234
Device is assigned with nodeid = 1234
[1663744164.973243][148045:148051] CHIP:IN: Prepared plaintext message 0x7f82d8eb58e0 to 0x0000000000000000 of type 0x20 and protocolId (0, 0) on exchange 19986i with MessageCounter:3140847465.
[1663744164.973269][148045:148051] CHIP:IN: Sending plaintext msg 0x7f82d8eb58e0 with MessageCounter:3140847465 to 0x0000000000000000 at monotonic time: 16468392 msec
[1663744164.979559][148045:148049] CHIP:BLE: BLE removing known devices.
[1663744164.980015][148045:148049] CHIP:BLE: BLE initiating scan.
[1663744165.842298][148045:148049] CHIP:BLE: New device scanned: 30:AE:A4:CB:B0:42
[1663744165.842312][148045:148049] CHIP:BLE: Device discriminator match. Attempting to connect.
[1663744165.848742][148045:148049] CHIP:BLE: Scan complete notification without an active scan.
[1663744167.691472][148045:148051] CHIP:BLE: subscribe complete, ep = 0x7f82dbf2b1c0
[1663744167.698435][148045:148051] CHIP:BLE: peripheral chose BTP version 4; central expected between 4 and 4
[1663744167.698446][148045:148051] CHIP:BLE: using BTP fragment sizes rx 244 / tx 244.
[1663744167.698448][148045:148051] CHIP:BLE: local and remote recv window size = 5
[1663744168.194223][148045:148051] CHIP:EM: Received message of type 0x21 with protocolId (0, 0) and MessageCounter:867382125 on exchange 19986i
[1663744168.194529][148045:148051] CHIP:IN: Prepared plaintext message 0x7f82d8eb60b0 to 0x0000000000000000 of type 0x22 and protocolId (0, 0) on exchange 19986i with MessageCounter:3140847466.
[1663744168.194541][148045:148051] CHIP:IN: Sending plaintext msg 0x7f82d8eb60b0 with MessageCounter:3140847466 to 0x0000000000000000 at monotonic time: 16471613 msec
[1663744169.894798][148045:148051] CHIP:EM: Received message of type 0x23 with protocolId (0, 0) and MessageCounter:867382126 on exchange 19986i
[1663744169.895151][148045:148051] CHIP:IN: Prepared plaintext message 0x7f82d8eb6150 to 0x0000000000000000 of type 0x24 and protocolId (0, 0) on exchange 19986i with MessageCounter:3140847467.
[1663744169.895166][148045:148051] CHIP:IN: Sending plaintext msg 0x7f82d8eb6150 with MessageCounter:3140847467 to 0x0000000000000000 at monotonic time: 16473313 msec
[1663744170.042137][148045:148051] CHIP:EM: Received message of type 0x40 with protocolId (0, 0) and MessageCounter:867382127 on exchange 19986i
[1663744170.042267][148045:148051] CHIP:IN: Prepared encrypted message 0x7f82d8eb5f10 to 0x00000000000004D2 of type 0x8 and protocolId (0, 1) on exchange 19987i with MessageCounter:0.
[1663744170.042279][148045:148051] CHIP:IN: Sending encrypted msg 0x7f82d8eb5f10 with MessageCounter:0 to 0x00000000000004D2 at monotonic time: 16473461 msec
[1663744170.211745][148045:148051] CHIP:EM: Received message of type 0x9 with protocolId (0, 1) and MessageCounter:1 on exchange 19987i
[1663744170.211793][148045:148051] CHIP:DMG: Received Command Response Data, Endpoint=0 Cluster=0x0000_003E Command=0x0000_0003
SetCommandIndexStatus commandHandle=1 commandIndex=1
[1663744170.211913][148045:148051] CHIP:ZCL: CertificateChainResponse:
[1663744170.211916][148045:148051] CHIP:ZCL:   Certificate: 451
[1663744170.211922][148045:148051] CHIP:CTL: Received certificate chain from the device
[1663744170.212003][148045:148051] CHIP:IN: Prepared encrypted message 0x7f82d8eb5960 to 0x00000000000004D2 of type 0x8 and protocolId (0, 1) on exchange 19988i with MessageCounter:1.
[1663744170.212012][148045:148051] CHIP:IN: Sending encrypted msg 0x7f82d8eb5960 with MessageCounter:1 to 0x00000000000004D2 at monotonic time: 16473630 msec
[1663744170.392983][148045:148051] CHIP:EM: Received message of type 0x9 with protocolId (0, 1) and MessageCounter:2 on exchange 19988i
[1663744170.393038][148045:148051] CHIP:DMG: Received Command Response Data, Endpoint=0 Cluster=0x0000_003E Command=0x0000_0003
SetCommandIndexStatus commandHandle=1 commandIndex=1
[1663744170.393123][148045:148051] CHIP:ZCL: CertificateChainResponse:
[1663744170.393126][148045:148051] CHIP:ZCL:   Certificate: 494
[1663744170.393130][148045:148051] CHIP:CTL: Received certificate chain from the device
[1663744170.393135][148045:148051] CHIP:CTL: Sending Attestation Request to the device.
[1663744170.393175][148045:148051] CHIP:IN: Prepared encrypted message 0x7f82d8eb5960 to 0x00000000000004D2 of type 0x8 and protocolId (0, 1) on exchange 19989i with MessageCounter:2.
[1663744170.393183][148045:148051] CHIP:IN: Sending encrypted msg 0x7f82d8eb5960 with MessageCounter:2 to 0x00000000000004D2 at monotonic time: 16473811 msec
[1663744170.948360][148045:148051] CHIP:EM: Received message of type 0x9 with protocolId (0, 1) and MessageCounter:3 on exchange 19989i
[1663744170.948405][148045:148051] CHIP:DMG: Received Command Response Data, Endpoint=0 Cluster=0x0000_003E Command=0x0000_0001
SetCommandIndexStatus commandHandle=1 commandIndex=1
[1663744170.948508][148045:148051] CHIP:ZCL: AttestationResponse:
[1663744170.948510][148045:148051] CHIP:ZCL:   AttestationElements: 171
[1663744170.948512][148045:148051] CHIP:ZCL:   Signature: 64
[1663744170.948514][148045:148051] CHIP:CTL: Received Attestation Information from the device
[1663744170.949059][148045:148051] CHIP:CTL: Successfully validated 'Attestation Information' command received from the device.
[1663744170.949064][148045:148051] CHIP:CTL: Sending 'CSR request' command to the device.
[1663744170.949127][148045:148051] CHIP:IN: Prepared encrypted message 0x7f82d8eb5960 to 0x00000000000004D2 of type 0x8 and protocolId (0, 1) on exchange 19990i with MessageCounter:3.
[1663744170.949136][148045:148051] CHIP:IN: Sending encrypted msg 0x7f82d8eb5960 with MessageCounter:3 to 0x00000000000004D2 at monotonic time: 16474367 msec
[1663744171.743339][148045:148051] CHIP:EM: Received message of type 0x9 with protocolId (0, 1) and MessageCounter:4 on exchange 19990i
[1663744171.743387][148045:148051] CHIP:DMG: Received Command Response Data, Endpoint=0 Cluster=0x0000_003E Command=0x0000_0005
SetCommandIndexStatus commandHandle=1 commandIndex=1
[1663744171.743464][148045:148051] CHIP:ZCL: OpCSRResponse:
[1663744171.743466][148045:148051] CHIP:ZCL:   NOCSRElements: 253
[1663744171.743467][148045:148051] CHIP:ZCL:   AttestationSignature: 0
[1663744171.743470][148045:148051] CHIP:CTL: Received certificate signing request from the device
[1663744171.743472][148045:148051] CHIP:CTL: Getting certificate chain for the device from the issuer
[1663744171.743474][148045:148051] CHIP:CTL: Verifying Certificate Signing Request
[1663744171.743622][148045:148051] CHIP:CTL: Generating NOC
[1663744171.743689][148045:148051] CHIP:CTL: Generating ICAC
[1663744171.743732][148045:148051] CHIP:CTL: Providing certificate chain to the commissioner
[1663744171.743735][148045:148051] CHIP:CTL: Received callback from the CA for NOC Chain generation. Status ../../src/controller/ExampleOperationalCredentialsIssuer.cpp:183: Success
[1663744171.743764][148045:148051] CHIP:CTL: Sending root certificate to the device
[1663744171.743801][148045:148051] CHIP:IN: Prepared encrypted message 0x7f82d8eb5680 to 0x00000000000004D2 of type 0x8 and protocolId (0, 1) on exchange 19991i with MessageCounter:4.
[1663744171.743810][148045:148051] CHIP:IN: Sending encrypted msg 0x7f82d8eb5680 with MessageCounter:4 to 0x00000000000004D2 at monotonic time: 16475162 msec
[1663744171.743831][148045:148051] CHIP:CTL: Sent root certificate to the device
[1663744171.992806][148045:148051] CHIP:EM: Received message of type 0x9 with protocolId (0, 1) and MessageCounter:5 on exchange 19991i
[1663744171.992869][148045:148051] CHIP:DMG: Received Command Response Status for Endpoint=0 Cluster=0x0000_003E Command=0x0000_000B Status=0x0
SetCommandIndexStatus commandHandle=1 commandIndex=1
[1663744171.992967][148045:148051] CHIP:ZCL: DefaultResponse:
[1663744171.992969][148045:148051] CHIP:ZCL:   Transaction: 0x7f82c40251a0
[1663744171.992972][148045:148051] CHIP:ZCL:   status: EMBER_ZCL_STATUS_SUCCESS (0x00)
[1663744171.992976][148045:148051] CHIP:CTL: Device confirmed that it has received the root certificate
[1663744171.992979][148045:148051] CHIP:CTL: Sending operational certificate chain to the device
[1663744171.993024][148045:148051] CHIP:IN: Prepared encrypted message 0x7f82d8eb5af0 to 0x00000000000004D2 of type 0x8 and protocolId (0, 1) on exchange 19992i with MessageCounter:5.
[1663744171.993032][148045:148051] CHIP:IN: Sending encrypted msg 0x7f82d8eb5af0 with MessageCounter:5 to 0x00000000000004D2 at monotonic time: 16475411 msec
[1663744171.993054][148045:148051] CHIP:CTL: Sent operational certificate to the device
[1663744174.092914][148045:148051] CHIP:EM: Received message of type 0x9 with protocolId (0, 1) and MessageCounter:6 on exchange 19992i
[1663744174.092958][148045:148051] CHIP:DMG: Received Command Response Data, Endpoint=0 Cluster=0x0000_003E Command=0x0000_0008
SetCommandIndexStatus commandHandle=1 commandIndex=1
[1663744174.093061][148045:148051] CHIP:ZCL: NOCResponse:
[1663744174.093086][148045:148051] CHIP:ZCL:   StatusCode: 0
[1663744174.093089][148045:148051] CHIP:ZCL:   FabricIndex: 1
[1663744174.093090][148045:148051] CHIP:ZCL:   DebugText: 
[1663744174.093094][148045:148051] CHIP:CTL: Device returned status 0 on receiving the NOC
[1663744174.093098][148045:148051] CHIP:CTL: Operational credentials provisioned on device 0x26e2058
Secure Session to Device Established
Device temporary node id (**this does not match spec**): 1234
chip-device-ctrl > 

6.4 发送控制设备命令

zcl OnOff Toggle 1234 1 0

输出:

chip-device-ctrl > zcl OnOff Toggle 1234 1 0
[1663744221.708785][148045:148051] CHIP:IN: Prepared encrypted message 0x7f82d8eb5920 to 0x00000000000004D2 of type 0x8 and protocolId (0, 1) on exchange 19993i with MessageCounter:7.
[1663744221.708800][148045:148051] CHIP:IN: Sending encrypted msg 0x7f82d8eb5920 with MessageCounter:7 to 0x00000000000004D2 at monotonic time: 16525127 msec
[1663744221.942682][148045:148051] CHIP:EM: Received message of type 0x9 with protocolId (0, 1) and MessageCounter:7 on exchange 19993i
[1663744221.942724][148045:148051] CHIP:DMG: Received Command Response Status for Endpoint=1 Cluster=0x0000_0006 Command=0x0000_0002 Status=0x0
SetCommandIndexStatus commandHandle=1 commandIndex=1
[1663744221.942826][148045:148051] CHIP:ZCL: DefaultResponse:
[1663744221.942828][148045:148051] CHIP:ZCL:   Transaction: 0x7f82c40273e0
[1663744221.942829][148045:148051] CHIP:ZCL:   status: EMBER_ZCL_STATUS_SUCCESS (0x00)
Received command status response:
Container: 
    Status = 0
    ClusterStatus = 255
    EndpointId = 1
    ClusterId = 6
    CommandId = 2
    CommandIndex = 1
chip-device-ctrl > 

从log可以看出可以成功控制。

至此matter环境已经搭建成功

评论 1
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值