[cli] add energy scan channel (#5677)

This commit is contained in:
Yakun Xu
2020-10-21 12:17:28 -07:00
committed by GitHub
parent 8787cc106c
commit ff76aac3db
3 changed files with 21 additions and 5 deletions
+9 -1
View File
@@ -1825,7 +1825,7 @@ Perform an IEEE 802.15.4 Active Scan.
Done
```
### scan energy \[duration\]
### scan energy \[duration\] \[channel\]
Perform an IEEE 802.15.4 Energy Scan.
@@ -1854,6 +1854,14 @@ Perform an IEEE 802.15.4 Energy Scan.
Done
```
```bash
> scan energy 10 20
| Ch | RSSI |
+----+------+
| 20 | -82 |
Done
```
### service
Module for controlling service registration in Network Data. Each change in service registration must be sent to leader by `netdata register` command before taking effect.
+7 -4
View File
@@ -3355,23 +3355,26 @@ otError Interpreter::ProcessScan(uint8_t aArgsLength, char *aArgs[])
uint32_t scanChannels = 0;
uint16_t scanDuration = 0;
bool energyScan = false;
uint8_t index = 0;
if (aArgsLength > 0)
{
if (strcmp(aArgs[0], "energy") == 0)
if (strcmp(aArgs[index], "energy") == 0)
{
energyScan = true;
index++;
if (aArgsLength > 1)
{
SuccessOrExit(error = ParseAsUint16(aArgs[1], scanDuration));
SuccessOrExit(error = ParseAsUint16(aArgs[index++], scanDuration));
}
}
else
if (index < aArgsLength)
{
uint8_t channel;
SuccessOrExit(error = ParseAsUint8(aArgs[0], channel));
SuccessOrExit(error = ParseAsUint8(aArgs[index++], channel));
VerifyOrExit(channel < sizeof(scanChannels) * CHAR_BIT, error = OT_ERROR_INVALID_ARGS);
scanChannels = 1 << channel;
}
@@ -75,6 +75,11 @@ for {set i 11} {$i <= 26} {incr i} {
expect -re "\\| +$i \\| +-?\\d+ \\|"
}
expect "Done"
send "scan energy 100 $channel\n"
expect "| Ch | RSSI |"
expect "+----+------+"
expect -re "\\| +$channel \\| +-?\\d+ \\|"
expect "Done"
switch_node 3
send "ifconfig up\n"