mirror of
https://github.com/espressif/openthread.git
synced 2026-08-29 21:39:54 +00:00
[cli] add targetpower command support (#11321)
This commit is contained in:
@@ -120,6 +120,7 @@ Done
|
||||
- [sntp](#sntp-query-sntp-server-ip-sntp-server-port)
|
||||
- [state](#state)
|
||||
- [srp](README_SRP.md)
|
||||
- [targetpower](#targetpower-channel-targetpower)
|
||||
- [tcat](README_TCAT.md)
|
||||
- [tcp](README_TCP.md)
|
||||
- [test](#test-tmforiginfilter-enabledisable)
|
||||
@@ -3809,6 +3810,18 @@ Try to switch to state `detached`, `child`, `router`.
|
||||
Done
|
||||
```
|
||||
|
||||
### targetpower \<channel\> \<targetpower\>
|
||||
|
||||
Set the target power.
|
||||
|
||||
- `channel` : Thread channel.
|
||||
- `targetpower` : The target power in the unit of 0.01dBm.
|
||||
|
||||
```bash
|
||||
> targetpower 12 1000
|
||||
Done
|
||||
```
|
||||
|
||||
### test tmforiginfilter \[enable|disable\]
|
||||
|
||||
Enable/disable filter that drops UDP messages sent to the TMF port from untrusted origin. Also get the current state of the filter if no argument is specified.
|
||||
|
||||
@@ -6698,6 +6698,35 @@ exit:
|
||||
return error;
|
||||
}
|
||||
|
||||
/**
|
||||
* @cli targetpower (set)
|
||||
* @code
|
||||
* targetpower 12 2000
|
||||
* Done
|
||||
* @endcode
|
||||
* @cparam targetpower @ca{channel} @ca{targetpower}
|
||||
* @par
|
||||
* Sets the target power in the unit of 0.01 dBm.
|
||||
* @sa otPlatRadioSetChannelTargetPower
|
||||
*/
|
||||
template <> otError Interpreter::Process<Cmd("targetpower")>(Arg aArgs[])
|
||||
{
|
||||
otError error = OT_ERROR_NONE;
|
||||
uint8_t channel;
|
||||
int16_t targetPower;
|
||||
uint32_t channelMask;
|
||||
|
||||
SuccessOrExit(error = aArgs[0].ParseAsUint8(channel));
|
||||
channelMask = otLinkGetSupportedChannelMask(GetInstancePtr());
|
||||
VerifyOrExit((1 << channel) & channelMask, error = OT_ERROR_INVALID_ARGS);
|
||||
SuccessOrExit(error = aArgs[1].ParseAsInt16(targetPower));
|
||||
|
||||
error = otPlatRadioSetChannelTargetPower(GetInstancePtr(), channel, targetPower);
|
||||
|
||||
exit:
|
||||
return error;
|
||||
}
|
||||
|
||||
/**
|
||||
* @cli debug
|
||||
* @par
|
||||
@@ -8338,6 +8367,7 @@ otError Interpreter::ProcessCommand(Arg aArgs[])
|
||||
CmdEntry("srp"),
|
||||
#endif
|
||||
CmdEntry("state"),
|
||||
CmdEntry("targetpower"),
|
||||
#if OPENTHREAD_CONFIG_BLE_TCAT_ENABLE && OPENTHREAD_CONFIG_CLI_BLE_SECURE_ENABLE
|
||||
CmdEntry("tcat"),
|
||||
#endif
|
||||
|
||||
@@ -364,3 +364,5 @@ extern "C" OT_TOOL_WEAK void otPlatRadioSetRxOnWhenIdle(otInstance *aInstance, b
|
||||
OT_UNUSED_VARIABLE(aInstance);
|
||||
OT_UNUSED_VARIABLE(aEnable);
|
||||
}
|
||||
|
||||
OT_TOOL_WEAK otError otPlatRadioSetChannelTargetPower(otInstance *, uint8_t, int16_t) { return kErrorNotImplemented; }
|
||||
|
||||
@@ -123,6 +123,15 @@ send "txpower\n"
|
||||
expect -- "-10 dBm"
|
||||
expect_line "Done"
|
||||
|
||||
send "targetpower 12 1000\n"
|
||||
expect_line "Done"
|
||||
|
||||
send "targetpower 12 -1000\n"
|
||||
expect_line "Done"
|
||||
|
||||
send "targetpower 10 1000\n"
|
||||
expect_line "Error 7: InvalidArgs"
|
||||
|
||||
send "thread version\n"
|
||||
expect_line "Done"
|
||||
|
||||
|
||||
Reference in New Issue
Block a user