![]() |
OpenWeave include una serie di strumenti a riga di comando per configurare, gestire e testare le distribuzioni OpenWeave.
Costruisci strumenti di tessitura
Il target di weave-tools
costruisce un archivio tar di strumenti da riga di comando Weave selezionati per la distribuzione. Include i seguenti strumenti:
Attrezzo | Descrizione | Posizione di costruzione autonoma |
---|---|---|
gen-qr-code | Genera un codice QR | /src/tools/misc |
mock-device | Simulatore di dispositivo generico Weave | /src/test-apps |
weave | Genera e gestisci i certificati Weave | /src/tools/weave |
weave-device-descriptor | Codifica e decodifica le stringhe del descrittore del dispositivo Weave per l'associazione dei codici QR | /src/test-apps |
weave-device-mgr | Gestisci il processo di associazione del dispositivo | /src/device-manager/python |
weave-heartbeat | Invia e ricevi messaggi di profilo Heartbeat | /src/test-apps |
weave-key-export | Invia richieste di esportazione chiave | /src/test-apps |
weave-ping | Invia e ricevi messaggi di profilo Echo | /src/test-apps |
Per costruire l'obiettivo:
- Installa tutti i prerequisiti di build .
- Configurare OpenWeave senza supporto 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
Usa gen-qr-code
per generare un codice QR per scopi di accoppiamento del dispositivo. L'input per lo strumento deve risiedere in un file locale. Ad esempio, per generare un codice QR che invia l'utente a https://www.google.com :
- Crea un file con la stringa per il codice 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
Quindi avvia il dispositivo fittizio 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
Usa il flag --help
per visualizzare tutte le opzioni di configurazione disponibili.
tessere-dispositivo-descrittore
Lo strumento weave-device-descriptor
codifica o decodifica una stringa descrittore del dispositivo. Queste stringhe contengono informazioni di identificazione per un dispositivo che è codificato nel suo codice QR di accoppiamento Weave. Usa il flag --help
con le opzioni di encode
o decode
per maggiori informazioni.
./weave-device-descriptor encode --help
./weave-device-descriptor decode --help
codificare
Ad esempio, per codificare una stringa del descrittore del dispositivo con le seguenti informazioni di identificazione, utilizzare i flag e i valori appropriati:
Campo | Bandiera | Valore |
---|---|---|
ID del venditore | -V | 1 |
Codice prodotto | -p | 1 |
Numero di revisione del prodotto | -r | 2 |
Numero di serie | -s | 18B4300000000004 |
Data di produzione | -m | 2018/05/02 |
Indirizzo MAC 802.15.4 (thread, BLE) | -8 | 000D6F000DA80466 |
Codice di accoppiamento | -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$
Usa questa stringa di output con lo strumento gen-qr-code
per generare il codice QR.
decodificare
Utilizzare la decode
opzione per decodificare un elemento di una stringa descrittore dispositivo. L'elemento da decodificare ha la seguente sintassi:
1 + <device-descriptor-element> + $
Ad esempio, per decodificare l'elemento descrittore del dispositivo W:5CF370800E77
:
./weave-device-descriptor decode 1W:5CF370800E77$
Primary WiFi MAC: 5C:F3:70:80:0E:77
tessere il battito cardiaco
Usa weave-heartbeat
per inviare e ricevere i messaggi del profilo tra due nodi di Weave. Heartbeat fornisce un mezzo per indicare la vitalità di un nodo agli altri nodi della rete o per verificare se un nodo rimane connesso al fabric. Heartbeat
Un Heartbeat riuscito richiede che un nodo agisca da server (in ascolto e che risponda all'Heartbeat) e un nodo che agisca come client (inviando l'Heartbeat).
Prova lo strumento weave-heartbeat
utilizzando l'interfaccia di loopback per imitare due nodi:
- Aggiungere gli indirizzi IPv6 da utilizzare per ogni nodo Heartbeat all'interfaccia
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
Battito cardiaco con un finto dispositivo
weave-heartbeat
crea un'istanza di un mock-device
sia per il server che per il client. La stessa funzionalità Heartbeat può essere dimostrata utilizzando mock-device
al posto del primo server Heartbeat di weave-heartbeat
:
./mock-device -a fd00:0:1:1::1
tessitura
Usa il weave-ping
per inviare e ricevere messaggi di profilo Echo tra due nodi Weave. Un payload Echo è costituito da dati arbitrari forniti dal nodo richiedente e si prevede che venga ripetuto alla lettera nella risposta. Echo fornisce un mezzo per testare la connettività di rete e la latenza.
Un Echo di successo richiede che un nodo agisca da server (ascoltando e rispondendo alla richiesta Echo) e un nodo agisca come client (inviando la richiesta Echo).
Prova lo strumento di weave-ping
utilizzando l'interfaccia di loopback per imitare due nodi:
- Aggiungere gli indirizzi IPv6 da utilizzare per ogni nodo Echo all'interfaccia
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
Eco con un finto dispositivo
weave-ping
crea un'istanza di un mock-device
sia per il server che per il client. La stessa funzionalità Echo può essere dimostrata utilizzando mock-device
al posto del primo server Echo di weave-ping
:
./mock-device -a fd00:0:1:1::1