[cli] add targetpower command support (#11321)

This commit is contained in:
Zhanglong Xia
2025-03-04 21:47:45 -08:00
committed by GitHub
parent b1ca77aae9
commit a470e8bf0d
4 changed files with 54 additions and 0 deletions
+13
View File
@@ -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.
+30
View File
@@ -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
+2
View File
@@ -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; }
+9
View File
@@ -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"