Implement MLE Discovery Request and Response. (#322)

This commit is contained in:
Jonathan Hui
2016-08-03 13:16:35 -07:00
committed by GitHub
parent 2fe487f0e8
commit b326f01821
18 changed files with 1149 additions and 95 deletions
+18 -3
View File
@@ -12,6 +12,7 @@ OpenThread test scripts use the CLI to execute test cases.
* [childtimeout](#childtimeout)
* [contextreusedelay](#contextreusedelay)
* [counter](#counter)
* [discover](#discover)
* [eidcache](#eidcache)
* [extaddr](#extaddr)
* [extpanid](#extpanid)
@@ -168,6 +169,20 @@ RxTotal: 11
RxErrOther: 0
```
### discover \[channel\]
Perform an MLE Discovery operation.
* channel: The channel to discover on. If no channel is provided, the discovery will cover all valid channels.
```bash
> discover
| J | Network Name | Extended PAN | PAN | MAC Address | Ch | dBm | LQI |
+---+------------------+------------------+------+------------------+----+-----+-----+
| 0 | OpenThread | dead00beef00cafe | ffff | f1d92a82c8d8fe43 | 11 | -20 | 0 |
Done
```
### eidcache
Print the EID-to-RLOC cache entries.
@@ -574,9 +589,9 @@ Perform an IEEE 802.15.4 Active Scan.
```bash
> scan
| J | Network Name | Extended PAN | PAN | MAC Address | Ch | dBm |
+---+------------------+------------------+------+------------------+----+-----+
| 0 | OpenThread | dead00beef00cafe | ffff | f1d92a82c8d8fe43 | 11 | -20 |
| J | Network Name | Extended PAN | PAN | MAC Address | Ch | dBm | LQI |
+---+------------------+------------------+------+------------------+----+-----+-----+
| 0 | OpenThread | dead00beef00cafe | ffff | f1d92a82c8d8fe43 | 11 | -20 | 0 |
Done
```
+26 -2
View File
@@ -56,6 +56,7 @@ const struct Command Interpreter::sCommands[] =
{ "childtimeout", &ProcessChildTimeout },
{ "contextreusedelay", &ProcessContextIdReuseDelay },
{ "counter", &ProcessCounters },
{ "discover", &ProcessDiscover },
{ "eidcache", &ProcessEidCache },
{ "extaddr", &ProcessExtAddress },
{ "extpanid", &ProcessExtPanId },
@@ -353,6 +354,28 @@ void Interpreter::ProcessCounters(int argc, char *argv[])
}
}
void Interpreter::ProcessDiscover(int argc, char *argv[])
{
ThreadError error = kThreadError_None;
uint32_t scanChannels = 0;
long value;
if (argc > 0)
{
SuccessOrExit(error = ParseLong(argv[0], value));
scanChannels = 1 << value;
}
SuccessOrExit(error = otDiscover(scanChannels, 0, OT_PANID_BROADCAST, &HandleActiveScanResult));
sServer->OutputFormat("| J | Network Name | Extended PAN | PAN | MAC Address | Ch | dBm | LQI |\r\n");
sServer->OutputFormat("+---+------------------+------------------+------+------------------+----+-----+-----+\r\n");
return;
exit:
AppendResult(error);
}
void Interpreter::ProcessEidCache(int argc, char *argv[])
{
otEidCacheEntry entry;
@@ -1246,7 +1269,9 @@ void Interpreter::HandleActiveScanResult(otActiveScanResult *aResult)
if (aResult->mExtPanId != NULL)
{
sServer->OutputFormat("| ");
OutputBytes(aResult->mExtPanId, OT_EXT_PAN_ID_SIZE);
sServer->OutputFormat(" ");
}
else
{
@@ -1254,9 +1279,8 @@ void Interpreter::HandleActiveScanResult(otActiveScanResult *aResult)
}
sServer->OutputFormat("| %04x | ", aResult->mPanId);
OutputBytes(aResult->mExtAddress.m8, OT_EXT_ADDRESS_SIZE);
sServer->OutputFormat("| %2d ", aResult->mChannel);
sServer->OutputFormat(" | %2d ", aResult->mChannel);
sServer->OutputFormat("| %3d ", aResult->mRssi);
sServer->OutputFormat("| %3d |\r\n", aResult->mLqi);
+1
View File
@@ -93,6 +93,7 @@ private:
static void ProcessChildTimeout(int argc, char *argv[]);
static void ProcessContextIdReuseDelay(int argc, char *argv[]);
static void ProcessCounters(int argc, char *argv[]);
static void ProcessDiscover(int argc, char *argv[]);
static void ProcessEidCache(int argc, char *argv[]);
static void ProcessExtAddress(int argc, char *argv[]);
static void ProcessExtPanId(int argc, char *argv[]);