[cli] add validation of targetpower channel (#11326)

This commit is contained in:
Jonathan Hui
2025-03-05 18:14:13 -08:00
committed by GitHub
parent a470e8bf0d
commit 555454c973
+3
View File
@@ -6717,8 +6717,11 @@ template <> otError Interpreter::Process<Cmd("targetpower")>(Arg aArgs[])
uint32_t channelMask;
SuccessOrExit(error = aArgs[0].ParseAsUint8(channel));
VerifyOrExit(channel < BitSizeOf(channelMask), error = OT_ERROR_INVALID_ARGS);
channelMask = otLinkGetSupportedChannelMask(GetInstancePtr());
VerifyOrExit((1 << channel) & channelMask, error = OT_ERROR_INVALID_ARGS);
SuccessOrExit(error = aArgs[1].ParseAsInt16(targetPower));
error = otPlatRadioSetChannelTargetPower(GetInstancePtr(), channel, targetPower);