Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[cli] add docs for detach command #9303

Merged
merged 1 commit into from
Jul 21, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
20 changes: 20 additions & 0 deletions src/cli/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -41,6 +41,7 @@ Done
- [csl](#csl)
- [dataset](README_DATASET.md)
- [delaytimermin](#delaytimermin)
- [detach](#detach)
- [deviceprops](#deviceprops)
- [diag](#diag)
- [discover](#discover-channel)
Expand Down Expand Up @@ -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.
Expand Down
49 changes: 36 additions & 13 deletions src/cli/cli.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -2442,25 +2442,59 @@ template <> otError Interpreter::Process<Cmd("delaytimermin")>(Arg aArgs[])
}
#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
Vyrastas marked this conversation as resolved.
Show resolved Hide resolved
* @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
*/
abtink marked this conversation as resolved.
Show resolved Hide resolved
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;
}

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
Expand Down Expand Up @@ -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)
{
Expand Down
Loading