![]() |
OpenWeave bao gồm một tập hợp các công cụ dòng lệnh để định cấu hình, quản lý và kiểm tra việc triển khai OpenWeave.
Xây dựng công cụ dệt
Mục tiêu weave-tools
xây dựng một kho lưu trữ tar gồm các công cụ dòng lệnh Weave được chọn để phân phối. Nó bao gồm các công cụ sau:
Dụng cụ | Sự miêu tả | Vị trí xây dựng độc lập |
---|---|---|
gen-qr-code | Tạo mã QR | /src/tools/misc |
mock-device | Trình mô phỏng thiết bị Generic Weave | /src/test-apps |
weave | Tạo và quản lý chứng chỉ Weave | /src/tools/weave |
weave-device-descriptor | Mã hóa và giải mã chuỗi ký tự mô tả thiết bị Weave để ghép nối mã QR | /src/test-apps |
weave-device-mgr | Quản lý quá trình ghép nối thiết bị | /src/device-manager/python |
weave-heartbeat | Gửi và nhận tin nhắn hồ sơ Heartbeat | /src/test-apps |
weave-key-export | Gửi các yêu cầu xuất quan trọng | /src/test-apps |
weave-ping | Gửi và nhận tin nhắn hồ sơ Echo | /src/test-apps |
Để xây dựng mục tiêu:
- Cài đặt tất cả các điều kiện tiên quyết của bản dựng .
- Định cấu hình OpenWeave mà không hỗ trợ BlueZ:
cd <path-to-openweave-core>
./configure --without-bluez
- Make the
weave-tools
target:make weave-tools
- Check the root
openweave-core
directory for the tar archive:ls weave*
weave-tools-x86_64-unknown-linux-gnu-4.0d.tar.gz
gen-qr-code
The gen-qr-code
tool requires the Python qrcode
module. Use pip
to install
it:
pip install --user qrcode
Sử dụng mã gen-qr-code
để tạo mã QR cho mục đích ghép nối thiết bị. Đầu vào cho công cụ phải nằm trong tệp cục bộ. Ví dụ: để tạo mã QR đưa người dùng đến https://www.google.com :
- Tạo tệp có chuỗi cho mã QR:
echo "https://www.google.com" >> ~/ow_qrcode
- Generate a 64x64 QR code of that string:
./gen-qr-code -v 1 -s 64 < ~/ow_qrcode
- To save the QR code as an image, specify an output file:
./gen-qr-code -v 1 -s 64 < ~/ow_qrcode > ~/ow_qrcode.png
Use theweave-device-descriptor
tool to generate the device descriptor string for use in a Weave device's pairing QR code.
mock-device
The mock-device
tool simulates a generic Weave node. Other tools and test case
scripts use this tool to encapsulate Weave functionality. Instantiate mock
devices on individual Happy nodes to test Weave functionality in a simulated
topology.
For example, to start a Weave mock device listening on an IPv6 address of
fd00:0:1:1::1
, first add that IPv6 address to the lo
(loopback) interface:
sudo ifconfig lo add fd00:0:1:1::1/64
Sau đó, khởi động thiết bị giả Weave:
./mock-device -a fd00:0:1:1::1
WEAVE:ML: Binding IPv6 TCP listen endpoint to [fd00:0:1:1::1]:11095
WEAVE:ML: Listening on IPv6 TCP endpoint
WEAVE:ML: Binding general purpose IPv4 UDP endpoint to [::]:11095
WEAVE:IN: IPV6_PKTINFO: 92
WEAVE:ML: Binding general purpose IPv6 UDP endpoint to [fd00:0:1:1::1]:11095 (lo)
WEAVE:ML: Listening on general purpose IPv6 UDP endpoint
WEAVE:ML: Binding IPv6 multicast receive endpoint to [ff02::1]:11095 (lo)
WEAVE:ML: Listening on IPv6 multicast receive endpoint
WEAVE:EM: Cannot listen for BLE connections, null BleLayer
Weave Node Configuration:
Fabric Id: 1
Subnet Number: 1
Node Id: 1
WEAVE:SD: init()
Weave Node Configuration:
Fabric Id: 1
Subnet Number: 1
Node Id: 1
Listening Addresses:
fd00:0:1:1::1 (ipv6)
Pairing Server: fd00:0:1:1::1
Mock Time Sync is disabled and not initialized
Mock System Time Offset initialized to: 3.213773 sec
Listening for requests...
Weave Node ready to service events; PID: 256904; PPID: 251571
Sử dụng cờ --help
để xem tất cả các tùy chọn cấu hình có sẵn.
dệt-thiết bị-mô tả
Công cụ weave-device-descriptor
mã hóa hoặc giải mã chuỗi ký tự mô tả thiết bị. Các chuỗi này chứa thông tin nhận dạng cho một thiết bị được mã hóa thành mã QR ghép nối Weave của nó. Sử dụng cờ --help
với các tùy chọn encode
hoặc decode
để biết thêm thông tin.
./weave-device-descriptor encode --help
./weave-device-descriptor decode --help
mã hóa
Ví dụ: để mã hóa một chuỗi mô tả thiết bị với thông tin nhận dạng sau, hãy sử dụng các cờ và giá trị thích hợp:
Cánh đồng | Cờ | Giá trị |
---|---|---|
Nhà cung cấp dữ liệu thông tin | -V | 1 |
ID sản phẩm | -p | 1 |
Số sửa đổi sản phẩm | -r | 2 |
Số sê-ri | -s | 18B4300000000004 |
Ngày sản xuất | -m | 2018/05/02 |
Địa chỉ MAC 802.15.4 (Luồng, BLE) | -8 | 000D6F000DA80466 |
Mã ghép nối | -P | AB713H |
./weave-device-descriptor encode -V 1 -p 1 -r 2 -s 18B4300000000004 -m 2018/05/02 \
-8 000D6F000DA80466 -w 5CF370800E77 -P AB713H
1V:1$P:1$R:2$D:180502$S:18B4300000000004$L:000D6F000DA80466$W:5CF370800E77$C:AB713H$
Sử dụng chuỗi đầu ra này với công cụ gen-qr-code
để tạo mã QR.
giải mã
Sử dụng tùy chọn decode
để giải mã một phần tử của chuỗi bộ mô tả thiết bị. Phần tử cần giải mã có cú pháp sau:
1 + <device-descriptor-element> + $
Ví dụ: để giải mã phần tử bộ mô tả thiết bị W:5CF370800E77
:
./weave-device-descriptor decode 1W:5CF370800E77$
Primary WiFi MAC: 5C:F3:70:80:0E:77
nhịp tim dệt
Sử dụng weave-heartbeat
để gửi và nhận tin nhắn hồ sơ giữa hai nút Weave. Heartbeat cung cấp một phương tiện để chỉ ra mức độ hoạt động của một nút với các nút khác trong mạng hoặc để kiểm tra xem một nút có còn kết nối với kết cấu hay không. Heartbeat
Nhịp tim thành công yêu cầu một nút hoạt động như một máy chủ (lắng nghe và phản hồi Nhịp tim) và một nút hoạt động như một máy khách (gửi Nhịp tim).
Kiểm tra công cụ weave-heartbeat
bằng cách sử dụng giao diện lặp lại để bắt chước hai nút:
- Thêm địa chỉ IPv6 sẽ được sử dụng cho mỗi nút Heartbeat vào giao diện
lo
(loopback):sudo ifconfig lo add fd00:0:1:1::1/64
sudo ifconfig lo add fd00:0:1:1::2/64
Start the Heartbeat server on the
fd00:0:1:1::1
address and assign it anode-id
of 1:./weave-heartbeat --node-addr fd00:0:1:1::1 --node-id 1 --listen
WEAVE:ML: Binding IPv6 TCP listen endpoint to [fd00:0:1:1::1]:11095 WEAVE:ML: Listening on IPv6 TCP endpoint WEAVE:ML: Binding general purpose IPv4 UDP endpoint to [::]:11095 WEAVE:IN: IPV6_PKTINFO: 92 WEAVE:ML: Binding general purpose IPv6 UDP endpoint to [fd00:0:1:1::1]:11095 (lo) WEAVE:ML: Listening on general purpose IPv6 UDP endpoint WEAVE:ML: Binding IPv6 multicast receive endpoint to [ff02::1]:11095 (lo) WEAVE:ML: Listening on IPv6 multicast receive endpoint WEAVE:EM: Cannot listen for BLE connections, null BleLayer Weave Node Configuration: Fabric Id: 1 Subnet Number: 1 Node Id: 1 Listening Addresses: fd00:0:1:1::1 (ipv6) Listening for Heartbeats... Weave Node ready to service events; PID: 170883; PPID: 170418Open a second terminal window and start the Heartbeat client on the
fd00:0:1:1::2
IPv6 address with anode-id
of 2 and the first node's IPv6 address as the destination for the Heartbeat:./weave-heartbeat --node-addr fd00:0:1:1::2 --node-id 2 --dest-addr fd00:0:1:1::1 1
WEAVE:ML: Binding IPv6 TCP listen endpoint to [fd00:0:1:1::2]:11095 WEAVE:ML: Listening on IPv6 TCP endpoint WEAVE:ML: Binding general purpose IPv4 UDP endpoint to [::]:11095 WEAVE:IN: IPV6_PKTINFO: 92 WEAVE:ML: Binding general purpose IPv6 UDP endpoint to [fd00:0:1:1::2]:11095 (lo) WEAVE:ML: Listening on general purpose IPv6 UDP endpoint WEAVE:ML: Binding IPv6 multicast receive endpoint to [ff02::1]:11095 (lo) WEAVE:ML: Listening on IPv6 multicast receive endpoint WEAVE:EM: Cannot listen for BLE connections, null BleLayer WEAVE:EM: Binding0: Allocated Weave Node Configuration: Fabric Id: 1 Subnet Number: 1 Node Id: 2 Listening Addresses: fd00:0:1:1::2 (ipv6) Sending Heartbeats via UDP to node 1 (fd00:0:1:1::1) every 1000 ms Weave Node ready to service events; PID: 170932; PPID: 170608 WEAVE:EM: Binding0: Configuring WEAVE:EM: Binding0: Preparing WEAVE:EM: Binding0: Ready, peer 1 ([fd00:0:1:1::1]:11095) via UDPAfter a successful connection, node 2 sends Heartbeats to node 1, and node 1 logs Heartbeats received from node 2:
Node 1 <code></code> WEAVE:EM: Msg rcvd 00000013:1 1 0000000000000002 0000 C993 0 MsgId:1380A259 WEAVE:EM: ec id: 1, AppState: 0xb8e89790 Heartbeat from node 2 (fd00:0:1:1::2): state=1, err=No Error ### Node 2 <code></code> WEAVE:EM: ec id: 1, AppState: 0x0 WEAVE:EM: Msg sent 00000013:1 1 0000000000000001 0000 C993 0 MsgId:1380A259 Heartbeat sent to node 1: state=1
Nhịp tim với một thiết bị giả
weave-heartbeat
khởi tạo một mock-device
cho cả máy chủ và máy khách. Chức năng Heartbeat tương tự có thể được chứng minh bằng cách sử dụng mock-device
thay cho máy chủ Heartbeat weave-heartbeat
đầu tiên:
./mock-device -a fd00:0:1:1::1
dệt-ping
Sử dụng Weave weave-ping
để gửi và nhận tin nhắn hồ sơ Echo giữa hai nút Weave. Tải trọng Echo bao gồm dữ liệu tùy ý do nút yêu cầu cung cấp và dự kiến sẽ được lặp lại nguyên văn trong phản hồi. Echo cung cấp một phương tiện để kiểm tra độ trễ và kết nối mạng.
Một Echo thành công yêu cầu một nút hoạt động như một máy chủ (lắng nghe và phản hồi yêu cầu Echo) và một nút hoạt động như một máy khách (gửi yêu cầu Echo).
Kiểm tra công cụ weave-ping
bằng cách sử dụng giao diện vòng lặp để bắt chước hai nút:
- Thêm địa chỉ IPv6 được sử dụng cho mỗi nút Echo vào giao diện
lo
(loopback):sudo ifconfig lo add fd00:0:1:1::1/64
sudo ifconfig lo add fd00:0:1:1::2/64
Start the Echo server on the
fd00:0:1:1::1
address, assigning it anode-id
of 1:./weave-ping --node-addr fd00:0:1:1::1 --node-id 1 --listen
WEAVE:ML: Binding IPv6 TCP listen endpoint to [fd00:0:1:1::1]:11095 WEAVE:ML: Listening on IPv6 TCP endpoint WEAVE:ML: Binding general purpose IPv4 UDP endpoint to [::]:11095 WEAVE:IN: IPV6_PKTINFO: 92 WEAVE:ML: Binding general purpose IPv6 UDP endpoint to [fd00:0:1:1::1]:11095 (lo) WEAVE:ML: Listening on general purpose IPv6 UDP endpoint WEAVE:ML: Binding IPv6 multicast receive endpoint to [ff02::1]:11095 (lo) WEAVE:ML: Listening on IPv6 multicast receive endpoint WEAVE:EM: Cannot listen for BLE connections, null BleLayer WEAVE:SD: init() Weave Node Configuration: Fabric Id: 1 Subnet Number: 1 Node Id: 1 Listening Addresses: fd00:0:1:1::1 (ipv6) Listening for Echo requests... Iteration 0 Weave Node ready to service events; PID: 120927; PPID: 113768 WEAVE:ECH: Listening...Open a second terminal window and start the Echo client on the
fd00:0:1:1::2
IPv6 address with anode-id
of 2 and the first node's IPv6 address as the destination for the Echo request:./weave-ping --node-addr fd00:0:1:1::2 --node-id 2 --dest-addr fd00:0:1:1::1 1
WEAVE:ML: Binding general purpose IPv4 UDP endpoint to [::]:11095 WEAVE:IN: IPV6_PKTINFO: 92 WEAVE:ML: Binding general purpose IPv6 UDP endpoint to [fd00:0:1:1::2]:11095 (lo) WEAVE:ML: Listening on general purpose IPv6 UDP endpoint WEAVE:ML: Binding IPv6 multicast receive endpoint to [ff02::1]:11095 (lo) WEAVE:ML: Listening on IPv6 multicast receive endpoint WEAVE:EM: Cannot listen for BLE connections, null BleLayer WEAVE:SD: init() Weave Node Configuration: Fabric Id: 1 Subnet Number: 1 Node Id: 2 Listening Addresses: fd00:0:1:1::2 (ipv6) Sending Echo requests to node 1 at fd00:0:1:1::1 Iteration 0 Weave Node ready to service events; PID: 121125; PPID: 121017 WEAVE:ML: Con start 9A00 0000000000000001 0001 WEAVE:ML: Con DNS complete 9A00 0 WEAVE:ML: TCP con start 9A00 fd00:0:1:1::1 11095 WEAVE:ML: TCP con complete 9A00 0 WEAVE:ML: Con complete 9A00 Connection established to node 1 (fd00:0:1:1::1)After a successful connection, node 1 logs Echo Requests from node 2, and node 2 logs Echo Responses from node 1:
Node 1 <code></code> WEAVE:ML: Con rcvd AA00 fd00:0:1:1::2 41675 Connection received from node 2 (fd00:0:1:1::2) WEAVE:EM: Msg rcvd 00000001:1 15 0000000000000002 AA00 B8A5 0 MsgId:00000000 WEAVE:EM: ec id: 1, AppState: 0xfce0ca80 Echo Request from node 2 (fd00:0:1:1::2): len=15 ... sending response. WEAVE:EM: Msg sent 00000001:2 15 0000000000000002 AA00 B8A5 0 MsgId:00000000 WEAVE:EM: Msg rcvd 00000001:1 15 0000000000000002 AA00 B8A6 0 MsgId:00000001 ### Node 2 <code></code> WEAVE:EM: ec id: 1, AppState: 0xd239baa0 WEAVE:EM: Msg sent 00000001:1 15 0000000000000001 9A00 B8A5 0 MsgId:00000000 WEAVE:EM: Msg rcvd 00000001:2 15 0000000000000001 9A00 B8A5 0 MsgId:00000000 Echo Response from node 1 (fd00:0:1:1::1): 1/1(100.00%) len=15 time=0.228ms
Echo bằng một thiết bị giả
weave-ping
khởi tạo một mock-device
cho cả máy chủ và máy khách. Chức năng Echo tương tự có thể được chứng minh bằng cách sử dụng mock-device
thay cho máy chủ Echo weave-ping
đầu tiên:
./mock-device -a fd00:0:1:1::1