mirror of
https://github.com/espressif/openthread.git
synced 2026-09-03 07:40:10 +00:00
Feature/extra clis for thci support (#345)
Update feature extra clis for thci support. * cli: add set/get PartitionId * cli: add get information about thread device's parent. * cli: add set/get the data poll period for sleepy end device. * cli: add blacklist relative commands to support network topology defined in Harness test case. * cli: add set/get assigned linkquality during parent selection of attaching. * cli: add reset to trigger a platform reset. * Add link-local 16 only for sleepy end device.
This commit is contained in:
@@ -8,6 +8,7 @@ OpenThread test scripts use the CLI to execute test cases.
|
||||
## OpenThread Command List
|
||||
|
||||
* [channel](#channel)
|
||||
* [blacklist](#blacklist)
|
||||
* [child](#child)
|
||||
* [childtimeout](#childtimeout)
|
||||
* [contextreusedelay](#contextreusedelay)
|
||||
@@ -19,16 +20,21 @@ OpenThread test scripts use the CLI to execute test cases.
|
||||
* [ifconfig](#ifconfig)
|
||||
* [ipaddr](#ipaddr)
|
||||
* [keysequence](#keysequence)
|
||||
* [leaderpartitionid](#leaderpartitionid)
|
||||
* [leaderweight](#leaderweight)
|
||||
* [linkquality](#linkquality)
|
||||
* [masterkey](#masterkey)
|
||||
* [mode](#mode)
|
||||
* [netdataregister](#netdataregister)
|
||||
* [networkidtimeout](#networkidtimeout)
|
||||
* [networkname](#networkname)
|
||||
* [panid](#panid)
|
||||
* [parent](#parent)
|
||||
* [ping](#ping)
|
||||
* [pollperiod](#pollperiod)
|
||||
* [prefix](#prefix)
|
||||
* [releaserouterid](#releaserouterid)
|
||||
* [reset](#reset)
|
||||
* [rloc16](#rloc16)
|
||||
* [route](#route)
|
||||
* [router](#router)
|
||||
@@ -42,6 +48,62 @@ OpenThread test scripts use the CLI to execute test cases.
|
||||
|
||||
## OpenThread Command Details
|
||||
|
||||
### blacklist
|
||||
|
||||
List the blacklist entries.
|
||||
|
||||
```bash
|
||||
> blacklist
|
||||
Enabled
|
||||
166e0a0000000002
|
||||
166e0a0000000003
|
||||
Done
|
||||
```
|
||||
|
||||
### blacklist add \<extaddr\>
|
||||
|
||||
Add an IEEE 802.15.4 Extended Address to the blacklist.
|
||||
|
||||
```bash
|
||||
> blacklist add 166e0a0000000002
|
||||
Done
|
||||
```
|
||||
|
||||
### blacklist clear
|
||||
|
||||
Clear all entries from the blacklist.
|
||||
|
||||
```bash
|
||||
> blacklist clear
|
||||
Done
|
||||
```
|
||||
|
||||
### blacklist disable
|
||||
|
||||
Disable MAC blacklist filtering.
|
||||
|
||||
```bash
|
||||
> blacklist disable
|
||||
Done
|
||||
```
|
||||
|
||||
### blacklist enable
|
||||
|
||||
Enable MAC blacklist filtering.
|
||||
|
||||
```bash
|
||||
> blacklist enable
|
||||
Done
|
||||
```
|
||||
|
||||
### blacklist remove \<extaddr\>
|
||||
|
||||
Remove an IEEE 802.15.4 Extended Address from the blacklist.
|
||||
|
||||
```bash
|
||||
> blacklist remove 166e0a0000000002
|
||||
Done
|
||||
```
|
||||
### channel
|
||||
|
||||
Get the IEEE 802.15.4 Channel value.
|
||||
@@ -312,6 +374,25 @@ Set the Thread Key Sequence.
|
||||
Done
|
||||
```
|
||||
|
||||
### leaderpartitionid
|
||||
|
||||
Get the Thread Leader Partition ID.
|
||||
|
||||
```bash
|
||||
> leaderpartitionid
|
||||
4294967295
|
||||
Done
|
||||
```
|
||||
|
||||
### leaderpartitionid \<partitionid>\
|
||||
|
||||
Set the Thread Leader Partition ID.
|
||||
|
||||
```bash
|
||||
> leaderpartitionid 0xffffffff
|
||||
Done
|
||||
```
|
||||
|
||||
### leaderweight
|
||||
|
||||
Get the Thread Leader Weight.
|
||||
@@ -331,6 +412,25 @@ Set the Thread Leader Weight.
|
||||
Done
|
||||
```
|
||||
|
||||
### linkquality \<extaddr>\
|
||||
|
||||
Get the link quality on the link to a given extended address.
|
||||
|
||||
```bash
|
||||
> linkquality 36c1dd7a4f5201ff
|
||||
3
|
||||
Done
|
||||
```
|
||||
|
||||
### linkquality \<extaddr>\ \<linkquality>\
|
||||
|
||||
Set the link quality on the link to a given extended address.
|
||||
|
||||
```bash
|
||||
> linkquality 36c1dd7a4f5201ff 3
|
||||
Done
|
||||
```
|
||||
|
||||
### masterkey
|
||||
|
||||
Get the Thread Master Key value.
|
||||
@@ -445,6 +545,17 @@ Set the IEEE 802.15.4 PAN ID value.
|
||||
Done
|
||||
```
|
||||
|
||||
### parent
|
||||
|
||||
Get the diagnostic information for a Thread Router as parent.
|
||||
|
||||
```bash
|
||||
> parent
|
||||
Ext Addr: be1857c6c21dce55
|
||||
Rloc: 5c00
|
||||
Done
|
||||
```
|
||||
|
||||
### ping \<ipaddr\> [size] [count] [interval]
|
||||
|
||||
Send an ICMPv6 Echo Request.
|
||||
@@ -454,6 +565,25 @@ Send an ICMPv6 Echo Request.
|
||||
16 bytes from fdde:ad00:beef:0:558:f56b:d688:799: icmp_seq=1 hlim=64 time=28ms
|
||||
```
|
||||
|
||||
### pollperiod
|
||||
|
||||
Get the data poll period of sleepy end device
|
||||
|
||||
```bash
|
||||
> pollperiod
|
||||
240
|
||||
Done
|
||||
```
|
||||
|
||||
### pollperiod \<pollperiod>\
|
||||
|
||||
Set the data poll period for sleepy end device
|
||||
|
||||
```bash
|
||||
> pollperiod 240
|
||||
Done
|
||||
```
|
||||
|
||||
### prefix add \<prefix\> [pvdcsr] [prf]
|
||||
|
||||
Add a valid prefix to the Network Data.
|
||||
@@ -483,11 +613,19 @@ Done
|
||||
|
||||
### releaserouterid \<routerid\>
|
||||
Release a Router ID that has been allocated by the device in the Leader role.
|
||||
|
||||
```bash
|
||||
> releaserouterid 16
|
||||
Done
|
||||
```
|
||||
|
||||
### reset
|
||||
Signal a platform reset.
|
||||
|
||||
```bash
|
||||
> reset
|
||||
```
|
||||
|
||||
### rloc16
|
||||
|
||||
Get the Thread RLOC16 value.
|
||||
|
||||
+173
-1
@@ -53,6 +53,7 @@ namespace Cli {
|
||||
const struct Command Interpreter::sCommands[] =
|
||||
{
|
||||
{ "help", &ProcessHelp },
|
||||
{ "blacklist", &ProcessBlacklist },
|
||||
{ "channel", &ProcessChannel },
|
||||
{ "child", &ProcessChild },
|
||||
{ "childtimeout", &ProcessChildTimeout },
|
||||
@@ -67,16 +68,21 @@ const struct Command Interpreter::sCommands[] =
|
||||
{ "ipaddr", &ProcessIpAddr },
|
||||
{ "keysequence", &ProcessKeySequence },
|
||||
{ "leaderdata", &ProcessLeaderData },
|
||||
{ "leaderpartitionid", &ProcessLeaderPartitionId },
|
||||
{ "leaderweight", &ProcessLeaderWeight },
|
||||
{ "linkquality", &ProcessLinkQuality },
|
||||
{ "masterkey", &ProcessMasterKey },
|
||||
{ "mode", &ProcessMode },
|
||||
{ "netdataregister", &ProcessNetworkDataRegister },
|
||||
{ "networkidtimeout", &ProcessNetworkIdTimeout },
|
||||
{ "networkname", &ProcessNetworkName },
|
||||
{ "panid", &ProcessPanId },
|
||||
{ "parent", &ProcessParent },
|
||||
{ "ping", &ProcessPing },
|
||||
{ "pollperiod", &ProcessPollPeriod },
|
||||
{ "prefix", &ProcessPrefix },
|
||||
{ "releaserouterid", &ProcessReleaseRouterId },
|
||||
{ "reset", &ProcessReset },
|
||||
{ "rloc16", &ProcessRloc16 },
|
||||
{ "route", &ProcessRoute },
|
||||
{ "router", &ProcessRouter },
|
||||
@@ -192,6 +198,13 @@ ThreadError Interpreter::ParseLong(char *argv, long &value)
|
||||
return (*endptr == '\0') ? kThreadError_None : kThreadError_Parse;
|
||||
}
|
||||
|
||||
ThreadError Interpreter::ParseUnsignedLong(char *argv, unsigned long &value)
|
||||
{
|
||||
char *endptr;
|
||||
value = strtoul(argv, &endptr, 0);
|
||||
return (*endptr == '\0') ? kThreadError_None : kThreadError_Parse;
|
||||
}
|
||||
|
||||
void Interpreter::ProcessHelp(int argc, char *argv[])
|
||||
{
|
||||
for (unsigned int i = 0; i < sizeof(sCommands) / sizeof(sCommands[0]); i++)
|
||||
@@ -203,6 +216,72 @@ void Interpreter::ProcessHelp(int argc, char *argv[])
|
||||
(void)argv;
|
||||
}
|
||||
|
||||
void Interpreter::ProcessBlacklist(int argc, char *argv[])
|
||||
{
|
||||
ThreadError error = kThreadError_None;
|
||||
otMacBlacklistEntry entry;
|
||||
int argcur = 0;
|
||||
uint8_t extAddr[8];
|
||||
|
||||
if (argcur >= argc)
|
||||
{
|
||||
if (otIsMacBlacklistEnabled())
|
||||
{
|
||||
sServer->OutputFormat("Enabled\r\n");
|
||||
}
|
||||
else
|
||||
{
|
||||
sServer->OutputFormat("Disabled\r\n");
|
||||
}
|
||||
|
||||
for (uint8_t i = 0; ; i++)
|
||||
{
|
||||
if (otGetMacBlacklistEntry(i, &entry) != kThreadError_None)
|
||||
{
|
||||
break;
|
||||
}
|
||||
|
||||
if (entry.mValid == false)
|
||||
{
|
||||
continue;
|
||||
}
|
||||
|
||||
OutputBytes(entry.mExtAddress.m8, OT_EXT_ADDRESS_SIZE);
|
||||
|
||||
sServer->OutputFormat("\r\n");
|
||||
}
|
||||
}
|
||||
else if (strcmp(argv[argcur], "add") == 0)
|
||||
{
|
||||
VerifyOrExit(++argcur < argc, error = kThreadError_Parse);
|
||||
VerifyOrExit(Hex2Bin(argv[argcur], extAddr, sizeof(extAddr)) == sizeof(extAddr), error = kThreadError_Parse);
|
||||
|
||||
otAddMacBlacklist(extAddr);
|
||||
VerifyOrExit(otAddMacBlacklist(extAddr) == kThreadError_None, error = kThreadError_Parse);
|
||||
}
|
||||
else if (strcmp(argv[argcur], "clear") == 0)
|
||||
{
|
||||
otClearMacBlacklist();
|
||||
}
|
||||
else if (strcmp(argv[argcur], "disable") == 0)
|
||||
{
|
||||
otDisableMacBlacklist();
|
||||
}
|
||||
else if (strcmp(argv[argcur], "enable") == 0)
|
||||
{
|
||||
otEnableMacBlacklist();
|
||||
}
|
||||
else if (strcmp(argv[argcur], "remove") == 0)
|
||||
{
|
||||
VerifyOrExit(++argcur < argc, error = kThreadError_Parse);
|
||||
VerifyOrExit(Hex2Bin(argv[argcur], extAddr, sizeof(extAddr)) == sizeof(extAddr), error = kThreadError_Parse);
|
||||
otRemoveMacBlacklist(extAddr);
|
||||
}
|
||||
|
||||
exit:
|
||||
AppendResult(error);
|
||||
}
|
||||
|
||||
void Interpreter::ProcessChannel(int argc, char *argv[])
|
||||
{
|
||||
ThreadError error = kThreadError_None;
|
||||
@@ -597,7 +676,7 @@ void Interpreter::ProcessLeaderData(int argc, char *argv[])
|
||||
|
||||
SuccessOrExit(error = otGetLeaderData(&leaderData));
|
||||
|
||||
sServer->OutputFormat("Partition ID: %d\r\n", leaderData.mPartitionId);
|
||||
sServer->OutputFormat("Partition ID: %u\r\n", leaderData.mPartitionId);
|
||||
sServer->OutputFormat("Weighting: %d\r\n", leaderData.mWeighting);
|
||||
sServer->OutputFormat("Data Version: %d\r\n", leaderData.mDataVersion);
|
||||
sServer->OutputFormat("Stable Data Version: %d\r\n", leaderData.mStableDataVersion);
|
||||
@@ -609,6 +688,25 @@ exit:
|
||||
AppendResult(error);
|
||||
}
|
||||
|
||||
void Interpreter::ProcessLeaderPartitionId(int argc, char *argv[])
|
||||
{
|
||||
ThreadError error = kThreadError_None;
|
||||
unsigned long value;
|
||||
|
||||
if (argc == 0)
|
||||
{
|
||||
sServer->OutputFormat("%u\r\n", otGetLocalLeaderPartitionId());
|
||||
}
|
||||
else
|
||||
{
|
||||
SuccessOrExit(error = ParseUnsignedLong(argv[0], value));
|
||||
otSetLocalLeaderPartitionId(static_cast<uint32_t>(value));
|
||||
}
|
||||
|
||||
exit:
|
||||
AppendResult(error);
|
||||
}
|
||||
|
||||
void Interpreter::ProcessLeaderWeight(int argc, char *argv[])
|
||||
{
|
||||
ThreadError error = kThreadError_None;
|
||||
@@ -628,6 +726,31 @@ exit:
|
||||
AppendResult(error);
|
||||
}
|
||||
|
||||
void Interpreter::ProcessLinkQuality(int argc, char *argv[])
|
||||
{
|
||||
ThreadError error = kThreadError_None;
|
||||
uint8_t extAddress[8];
|
||||
uint8_t linkQuality;
|
||||
long value;
|
||||
|
||||
VerifyOrExit(Hex2Bin(argv[0], extAddress, OT_EXT_ADDRESS_SIZE) >= 0, error = kThreadError_Parse);
|
||||
|
||||
if (argc == 1)
|
||||
{
|
||||
VerifyOrExit(otGetAssignLinkQuality(extAddress, &linkQuality) == kThreadError_None,
|
||||
error = kThreadError_InvalidArgs);
|
||||
sServer->OutputFormat("%d\r\n", linkQuality);
|
||||
}
|
||||
else
|
||||
{
|
||||
SuccessOrExit(error = ParseLong(argv[1], value));
|
||||
otSetAssignLinkQuality(extAddress, static_cast<uint8_t>(value));
|
||||
}
|
||||
|
||||
exit:
|
||||
AppendResult(error);
|
||||
}
|
||||
|
||||
void Interpreter::ProcessMasterKey(int argc, char *argv[])
|
||||
{
|
||||
ThreadError error = kThreadError_None;
|
||||
@@ -790,6 +913,29 @@ exit:
|
||||
AppendResult(error);
|
||||
}
|
||||
|
||||
void Interpreter::ProcessParent(int argc, char *argv[])
|
||||
{
|
||||
ThreadError error = kThreadError_None;
|
||||
otRouterInfo parentInfo;
|
||||
|
||||
SuccessOrExit(error = otGetParentInfo(&parentInfo));
|
||||
sServer->OutputFormat("Ext Addr: ");
|
||||
|
||||
for (size_t i = 0; i < sizeof(parentInfo.mExtAddress); i++)
|
||||
{
|
||||
sServer->OutputFormat("%02x", parentInfo.mExtAddress.m8[i]);
|
||||
}
|
||||
|
||||
sServer->OutputFormat("\r\n");
|
||||
|
||||
sServer->OutputFormat("Rloc: %x\r\n", parentInfo.mRloc16);
|
||||
|
||||
exit:
|
||||
(void)argc;
|
||||
(void)argv;
|
||||
AppendResult(error);
|
||||
}
|
||||
|
||||
void Interpreter::HandleEchoResponse(void *aContext, Message &aMessage, const Ip6::MessageInfo &aMessageInfo)
|
||||
{
|
||||
Ip6::IcmpHeader icmp6Header;
|
||||
@@ -887,6 +1033,25 @@ void Interpreter::HandlePingTimer(void *aContext)
|
||||
(void)aContext;
|
||||
}
|
||||
|
||||
void Interpreter::ProcessPollPeriod(int argc, char *argv[])
|
||||
{
|
||||
ThreadError error = kThreadError_None;
|
||||
long value;
|
||||
|
||||
if (argc == 0)
|
||||
{
|
||||
sServer->OutputFormat("%d\r\n", otGetPollPeriod());
|
||||
}
|
||||
else
|
||||
{
|
||||
SuccessOrExit(error = ParseLong(argv[0], value));
|
||||
otSetPollPeriod(static_cast<uint32_t>(value));
|
||||
}
|
||||
|
||||
exit:
|
||||
AppendResult(error);
|
||||
}
|
||||
|
||||
ThreadError Interpreter::ProcessPrefixAdd(int argc, char *argv[])
|
||||
{
|
||||
ThreadError error = kThreadError_None;
|
||||
@@ -1048,6 +1213,13 @@ exit:
|
||||
AppendResult(error);
|
||||
}
|
||||
|
||||
void Interpreter::ProcessReset(int argc, char *argv[])
|
||||
{
|
||||
otPlatformReset();
|
||||
(void)argc;
|
||||
(void)argv;
|
||||
}
|
||||
|
||||
void Interpreter::ProcessRloc16(int argc, char *argv[])
|
||||
{
|
||||
sServer->OutputFormat("%04x\r\n", otGetRloc16());
|
||||
|
||||
@@ -97,6 +97,18 @@ public:
|
||||
*/
|
||||
static ThreadError ParseLong(char *aString, long &aLong);
|
||||
|
||||
/**
|
||||
* This method parses an ASCII string as an unsigned long.
|
||||
*
|
||||
* @param[in] aString A pointer to the ASCII string.
|
||||
* @param[out] aUnsignedLong A reference to where the parsed unsigned long is placed.
|
||||
*
|
||||
* @retval kThreadError_None Successfully parsed the ASCII string.
|
||||
* @retval kThreadError_Parse Could not parse the ASCII string.
|
||||
*
|
||||
*/
|
||||
static ThreadError ParseUnsignedLong(char *aString, unsigned long &aUnsignedLong);
|
||||
|
||||
/**
|
||||
* This method converts a hex string to binary.
|
||||
*
|
||||
@@ -118,6 +130,7 @@ private:
|
||||
static void OutputBytes(const uint8_t *aBytes, uint8_t aLength);
|
||||
|
||||
static void ProcessHelp(int argc, char *argv[]);
|
||||
static void ProcessBlacklist(int argc, char *argv[]);
|
||||
static void ProcessChannel(int argc, char *argv[]);
|
||||
static void ProcessChild(int argc, char *argv[]);
|
||||
static void ProcessChildTimeout(int argc, char *argv[]);
|
||||
@@ -134,18 +147,23 @@ private:
|
||||
static ThreadError ProcessIpAddrDel(int argc, char *argv[]);
|
||||
static void ProcessKeySequence(int argc, char *argv[]);
|
||||
static void ProcessLeaderData(int argc, char *argv[]);
|
||||
static void ProcessLeaderPartitionId(int argc, char *argv[]);
|
||||
static void ProcessLeaderWeight(int argc, char *argv[]);
|
||||
static void ProcessLinkQuality(int argc, char *argv[]);
|
||||
static void ProcessMasterKey(int argc, char *argv[]);
|
||||
static void ProcessMode(int argc, char *argv[]);
|
||||
static void ProcessNetworkDataRegister(int argc, char *argv[]);
|
||||
static void ProcessNetworkIdTimeout(int argc, char *argv[]);
|
||||
static void ProcessNetworkName(int argc, char *argv[]);
|
||||
static void ProcessPanId(int argc, char *argv[]);
|
||||
static void ProcessParent(int argc, char *argv[]);
|
||||
static void ProcessPing(int argc, char *argv[]);
|
||||
static void ProcessPollPeriod(int argc, char *argv[]);
|
||||
static void ProcessPrefix(int argc, char *argv[]);
|
||||
static ThreadError ProcessPrefixAdd(int argc, char *argv[]);
|
||||
static ThreadError ProcessPrefixRemove(int argc, char *argv[]);
|
||||
static void ProcessReleaseRouterId(int argc, char *argv[]);
|
||||
static void ProcessReset(int argc, char *argv[]);
|
||||
static void ProcessRoute(int argc, char *argv[]);
|
||||
static void ProcessRouter(int argc, char *argv[]);
|
||||
static ThreadError ProcessRouteAdd(int argc, char *argv[]);
|
||||
|
||||
Reference in New Issue
Block a user