[cli] add CLI commands for multi-radio feature (#6178)

This commit adds new CLI command `multiradio` to get the list of
supported radio types by device and `multiradio neighbor` sub-command
to get the radio info (supported radios and the their preference) for
specific neighbor or for all neighbors.
This commit is contained in:
Abtin Keshavarzian
2021-02-19 09:36:26 -08:00
committed by GitHub
parent a906e14732
commit 5756b9db66
3 changed files with 131 additions and 0 deletions
+38
View File
@@ -67,6 +67,7 @@ Done
- [masterkey](#masterkey)
- [mlr](#mlr-reg-ipaddr--timeout)
- [mode](#mode)
- [multiradio](#multiradio)
- [neighbor](#neighbor-list)
- [netdata](README_NETDATA.md)
- [netstat](#netstat)
@@ -1404,6 +1405,43 @@ Done
Done
```
### multiradio
Get the list of supported radio links by the device.
This command is always available, even when only a single radio is supported by the device.
```bash
> multiradio
[15.4, TREL]
Done
```
### multiradio neighbor list
Get the list of neighbors and their supported radios and their preference.
This command is only available when device supports more than one radio link.
```bash
> multiradio neighbor list
ExtAddr:3a65bc38dbe4a5be, RLOC16:0xcc00, Radios:[15.4(255), TREL(255)]
ExtAddr:17df23452ee4a4be, RLOC16:0x1300, Radios:[15.4(255)]
Done
```
### multiradio neighbor \<ext address\>
Get the radio info for specific neighbor with a given extended address.
This command is only available when device supports more than one radio link.
```bash
> multiradio neighbor 3a65bc38dbe4a5be
[15.4(255), TREL(255)]
Done
```
### neighbor list
List RLOC16 of neighbors.
+88
View File
@@ -2639,6 +2639,94 @@ exit:
return error;
}
otError Interpreter::ProcessMultiRadio(uint8_t aArgsLength, char *aArgs[])
{
otError error = OT_ERROR_NONE;
OT_UNUSED_VARIABLE(aArgs);
if (aArgsLength == 0)
{
bool isFirst = true;
OutputFormat("[");
#if OPENTHREAD_CONFIG_RADIO_LINK_IEEE_802_15_4_ENABLE
OutputFormat("15.4");
isFirst = false;
#endif
#if OPENTHREAD_CONFIG_RADIO_LINK_TREL_ENABLE
OutputFormat("%sTREL", isFirst ? "" : ", ");
#endif
OutputLine("]");
OT_UNUSED_VARIABLE(isFirst);
}
#if OPENTHREAD_CONFIG_MULTI_RADIO
else if (strcmp(aArgs[0], "neighbor") == 0)
{
otMultiRadioNeighborInfo multiRadioInfo;
VerifyOrExit(aArgsLength == 2, error = OT_ERROR_INVALID_ARGS);
if (strcmp(aArgs[1], "list") == 0)
{
otNeighborInfoIterator iterator = OT_NEIGHBOR_INFO_ITERATOR_INIT;
otNeighborInfo neighInfo;
while (otThreadGetNextNeighborInfo(mInstance, &iterator, &neighInfo) == OT_ERROR_NONE)
{
if (otMultiRadioGetNeighborInfo(mInstance, &neighInfo.mExtAddress, &multiRadioInfo) != OT_ERROR_NONE)
{
continue;
}
OutputFormat("ExtAddr:");
OutputExtAddress(neighInfo.mExtAddress);
OutputFormat(", RLOC16:0x%04x, Radios:", neighInfo.mRloc16);
OutputMultiRadioInfo(multiRadioInfo);
}
}
else
{
otExtAddress extAddress;
SuccessOrExit(error = ParseAsHexString(aArgs[1], extAddress.m8));
SuccessOrExit(error = otMultiRadioGetNeighborInfo(mInstance, &extAddress, &multiRadioInfo));
OutputMultiRadioInfo(multiRadioInfo);
}
}
#endif // OPENTHREAD_CONFIG_MULTI_RADIO
else
{
ExitNow(error = OT_ERROR_INVALID_COMMAND);
}
exit:
return error;
}
#if OPENTHREAD_CONFIG_MULTI_RADIO
void Interpreter::OutputMultiRadioInfo(const otMultiRadioNeighborInfo &aMultiRadioInfo)
{
bool isFirst = true;
OutputFormat("[");
if (aMultiRadioInfo.mSupportsIeee802154)
{
OutputFormat("15.4(%d)", aMultiRadioInfo.mIeee802154Info.mPreference);
isFirst = false;
}
if (aMultiRadioInfo.mSupportsTrelUdp6)
{
OutputFormat("%sTREL(%d)", isFirst ? "" : ", ", aMultiRadioInfo.mTrelUdp6Info.mPreference);
}
OutputLine("]");
}
#endif // OPENTHREAD_CONFIG_MULTI_RADIO
#if OPENTHREAD_FTD
otError Interpreter::ProcessNeighbor(uint8_t aArgsLength, char *aArgs[])
{
+5
View File
@@ -424,6 +424,10 @@ private:
uint8_t aFailedAddressNum);
#endif
otError ProcessMode(uint8_t aArgsLength, char *aArgs[]);
otError ProcessMultiRadio(uint8_t aArgsLength, char *aArgsp[]);
#if OPENTHREAD_CONFIG_MULTI_RADIO
void OutputMultiRadioInfo(const otMultiRadioNeighborInfo &aMultiRadioInfo);
#endif
#if OPENTHREAD_FTD
otError ProcessNeighbor(uint8_t aArgsLength, char *aArgs[]);
#endif
@@ -711,6 +715,7 @@ private:
{"mlr", &Interpreter::ProcessMlr},
#endif
{"mode", &Interpreter::ProcessMode},
{"multiradio", &Interpreter::ProcessMultiRadio},
#if OPENTHREAD_FTD
{"neighbor", &Interpreter::ProcessNeighbor},
#endif