[cli] add docs for detach command (#9303)

This commit is contained in:
Abtin Keshavarzian
2023-07-21 10:33:57 -07:00
committed by GitHub
parent 793bf78df1
commit 955b07416b
2 changed files with 56 additions and 13 deletions
+20
View File
@@ -41,6 +41,7 @@ Done
- [csl](#csl)
- [dataset](README_DATASET.md)
- [delaytimermin](#delaytimermin)
- [detach](#detach)
- [deviceprops](#deviceprops)
- [diag](#diag)
- [discover](#discover-channel)
@@ -1065,6 +1066,25 @@ Set the minimal delay timer (in seconds).
Done
```
### detach
Start the graceful detach process by first notifying other nodes (sending Address Release if acting as a router, or setting Child Timeout value to zero on parent if acting as a child) and then stopping Thread protocol operation.
```bash
> detach
Finished detaching
Done
```
### detach async
Start the graceful detach process similar to the `detach` command without blocking and waiting for the callback indicating that detach is finished.
```bash
> detach async
Done
```
### deviceprops
Get the current device properties.
+36 -13
View File
@@ -2442,18 +2442,41 @@ exit:
}
#endif
/**
* @cli detach
* @code
* detach
* Finished detaching
* Done
* @endcode
* @par
* Start the graceful detach process by first notifying other nodes (sending Address Release if acting as a router, or
* setting Child Timeout value to zero on parent if acting as a child) and then stopping Thread protocol operation.
* @sa otThreadDetachGracefully
*/
template <> otError Interpreter::Process<Cmd("detach")>(Arg aArgs[])
{
otError error = OT_ERROR_NONE;
/**
* @cli detach async
* @code
* detach async
* Done
* @endcode
* @par
* Start the graceful detach process similar to the `detach` command without blocking and waiting for the callback
* indicating that detach is finished.
* @csa{detach}
* @sa otThreadDetachGracefully
*/
if (aArgs[0] == "async")
{
SuccessOrExit(error = otThreadDetachGracefully(GetInstancePtr(), nullptr, nullptr));
}
else
{
SuccessOrExit(error =
otThreadDetachGracefully(GetInstancePtr(), &Interpreter::HandleDetachGracefullyResult, this));
SuccessOrExit(error = otThreadDetachGracefully(GetInstancePtr(), HandleDetachGracefullyResult, this));
error = OT_ERROR_PENDING;
}
@@ -2461,6 +2484,17 @@ exit:
return error;
}
void Interpreter::HandleDetachGracefullyResult(void *aContext)
{
static_cast<Interpreter *>(aContext)->HandleDetachGracefullyResult();
}
void Interpreter::HandleDetachGracefullyResult(void)
{
OutputLine("Finished detaching");
OutputResult(OT_ERROR_NONE);
}
/**
* @cli discover
* @code
@@ -7748,17 +7782,6 @@ void Interpreter::OutputChildTableEntry(uint8_t aIndentSize, const otNetworkDiag
}
#endif // OPENTHREAD_CONFIG_TMF_NETDIAG_CLIENT_ENABLE
void Interpreter::HandleDetachGracefullyResult(void *aContext)
{
static_cast<Interpreter *>(aContext)->HandleDetachGracefullyResult();
}
void Interpreter::HandleDetachGracefullyResult(void)
{
OutputLine("Finished detaching");
OutputResult(OT_ERROR_NONE);
}
#if OPENTHREAD_FTD
void Interpreter::HandleDiscoveryRequest(const otThreadDiscoveryRequestInfo *aInfo, void *aContext)
{