Skip to content

Commit

Permalink
[cli] add the sync option to the linkmetrics cli commands (openthread…
Browse files Browse the repository at this point in the history
…#10518)

The cli command `linkmetrics` only provides an asynchronous output
method. It is difficult for scripts to call the `ot-ctl` to capture
the results of asynchronous output.

This commit replaces the command `linkmetrics mgmt` and `linkmetrics
query` with commands `linkmetrics config` and `linkmetrics
request`. Both the commands `linkmetrics config` and `linkmetrics
request` are set to the `sync` mode by default, and an option `async`
is added to these commands to support `async` mode.
  • Loading branch information
zhanglongxia authored Aug 2, 2024
1 parent e219fe9 commit c5ad131
Show file tree
Hide file tree
Showing 9 changed files with 250 additions and 121 deletions.
69 changes: 53 additions & 16 deletions src/cli/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -66,7 +66,7 @@ Done
- [keysequence](#keysequence-counter)
- [leaderdata](#leaderdata)
- [leaderweight](#leaderweight)
- [linkmetrics](#linkmetrics-mgmt-ipaddr-enhanced-ack-clear)
- [linkmetrics](#linkmetrics-config-async-ipaddr-enhanced-ack-clear)
- [linkmetricsmgr](#linkmetricsmgr-disable)
- [locate](#locate)
- [log](#log-filename-filename)
Expand Down Expand Up @@ -1861,23 +1861,30 @@ Set the Thread Leader Weight.
Done
```
### linkmetrics mgmt \<ipaddr\> enhanced-ack clear
### linkmetrics config \[async\] \<ipaddr\> enhanced-ack clear
Send a Link Metrics Management Request to clear an Enhanced-ACK Based Probing.
- async: Use the non-blocking mode.
- ipaddr: Peer address (SHOULD be link local address of the neighboring device).
```bash
> linkmetrics mgmt fe80:0:0:0:3092:f334:1455:1ad2 enhanced-ack clear
> linkmetrics config fe80:0:0:0:3092:f334:1455:1ad2 enhanced-ack clear
Received Link Metrics Management Response from: fe80:0:0:0:3092:f334:1455:1ad2
Status: Success
Done
> linkmetrics config async fe80:0:0:0:3092:f334:1455:1ad2 enhanced-ack clear
Done
> Received Link Metrics Management Response from: fe80:0:0:0:3092:f334:1455:1ad2
Status: Success
```
### linkmetrics mgmt \<ipaddr\> enhanced-ack register [qmr][r]
### linkmetrics config \[async\] \<ipaddr\> enhanced-ack register \<qmr\> \[r\]
Send a Link Metrics Management Request to register an Enhanced-ACK Based Probing.
- async: Use the non-blocking mode.
- ipaddr: Peer address.
- qmr: This specifies what metrics to query. At most two options are allowed to select (per spec 4.11.3.4.4.6).
- q: Layer 2 LQI.
Expand All @@ -1886,21 +1893,27 @@ Send a Link Metrics Management Request to register an Enhanced-ACK Based Probing
- r: This is optional and only used for reference devices. When this option is specified, Type/Average Enum of each Type Id Flags would be set to `reserved`. This is used to verify the Probing Subject correctly handles invalid Type Id Flags. This is only available when `OPENTHREAD_CONFIG_REFERENCE_DEVICE_ENABLE` is enabled.
```bash
> linkmetrics mgmt fe80:0:0:0:3092:f334:1455:1ad2 enhanced-ack register qm
> linkmetrics config fe80:0:0:0:3092:f334:1455:1ad2 enhanced-ack register qm
Received Link Metrics Management Response from: fe80:0:0:0:3092:f334:1455:1ad2
Status: Success
Done
> linkmetrics config async fe80:0:0:0:3092:f334:1455:1ad2 enhanced-ack register qm
Done
> Received Link Metrics Management Response from: fe80:0:0:0:3092:f334:1455:1ad2
Status: Success
> linkmetrics mgmt fe80:0:0:0:3092:f334:1455:1ad2 enhanced-ack register qm r
> linkmetrics config async fe80:0:0:0:3092:f334:1455:1ad2 enhanced-ack register qm r
Done
> Received Link Metrics Management Response from: fe80:0:0:0:3092:f334:1455:1ad2
Status: Cannot support new series
```
### linkmetrics mgmt \<ipaddr\> forward \<seriesid\> [ldraX][pqmr]
### linkmetrics config \[async\] \<ipaddr\> forward \<seriesid\> \<ldraX\> \<pqmr\>
Send a Link Metrics Management Request to configure a Forward Tracking Series.
- async: Use the non-blocking mode.
- ipaddr: Peer address.
- seriesid: The Series ID.
- ldraX: This specifies which frames are to be accounted.
Expand All @@ -1916,7 +1929,12 @@ Send a Link Metrics Management Request to configure a Forward Tracking Series.
- r: RSSI.
```bash
> linkmetrics mgmt fe80:0:0:0:3092:f334:1455:1ad2 forward 1 dra pqmr
> linkmetrics config fe80:0:0:0:3092:f334:1455:1ad2 forward 1 dra pqmr
Received Link Metrics Management Response from: fe80:0:0:0:3092:f334:1455:1ad2
Status: SUCCESS
Done
> linkmetrics config async fe80:0:0:0:3092:f334:1455:1ad2 forward 1 dra pqmr
Done
> Received Link Metrics Management Response from: fe80:0:0:0:3092:f334:1455:1ad2
Status: SUCCESS
Expand All @@ -1935,19 +1953,28 @@ Send a MLE Link Probe message to the peer.
Done
```
### linkmetrics query \<ipaddr\> single [pqmr]
### linkmetrics request \[async\] \<ipaddr\> single \<pqmr\>
Perform a Link Metrics query (Single Probe).
- async: Use the non-blocking mode.
- ipaddr: Peer address.
- pqmr: This specifies what metrics to query.
- p: Layer 2 Number of PDUs received.
- q: Layer 2 LQI.
- m: Link Margin.
- r: RSSI.
- p: Layer 2 Number of PDUs received.
- q: Layer 2 LQI.
- m: Link Margin.
- r: RSSI.
```bash
> linkmetrics query fe80:0:0:0:3092:f334:1455:1ad2 single qmr
> linkmetrics request fe80:0:0:0:3092:f334:1455:1ad2 single qmr
Received Link Metrics Report from: fe80:0:0:0:3092:f334:1455:1ad2
- LQI: 76 (Exponential Moving Average)
- Margin: 82 (dB) (Exponential Moving Average)
- RSSI: -18 (dBm) (Exponential Moving Average)
Done
> linkmetrics request async fe80:0:0:0:3092:f334:1455:1ad2 single qmr
Done
> Received Link Metrics Report from: fe80:0:0:0:3092:f334:1455:1ad2
Expand All @@ -1956,15 +1983,25 @@ Done
- RSSI: -18 (dBm) (Exponential Moving Average)
```
### linkmetrics query \<ipaddr\> forward \<seriesid\>
### linkmetrics request \[async\] \<ipaddr\> forward \<seriesid\>
Perform a Link Metrics query (Forward Tracking Series).
- sync: Use the blocking mode.
- ipaddr: Peer address.
- seriesid: The Series ID.
```bash
> linkmetrics query fe80:0:0:0:3092:f334:1455:1ad2 forward 1
> linkmetrics request fe80:0:0:0:3092:f334:1455:1ad2 forward 1
Received Link Metrics Report from: fe80:0:0:0:3092:f334:1455:1ad2
- PDU Counter: 2 (Count/Summation)
- LQI: 76 (Exponential Moving Average)
- Margin: 82 (dB) (Exponential Moving Average)
- RSSI: -18 (dBm) (Exponential Moving Average)
Done
> linkmetrics request async fe80:0:0:0:3092:f334:1455:1ad2 forward 1
Done
> Received Link Metrics Report from: fe80:0:0:0:3092:f334:1455:1ad2
Expand Down
Loading

0 comments on commit c5ad131

Please sign in to comment.