[diag] go back to sleep after transmission (#11181)

When "diag radio sleep" is followed by "diag send" or "diag
repeat", the radio switches to and stays in the receive mode
after a transmission. Normally, the MAC layer is responsible
for putting the radio back to sleep but the MAC layer is
bypassed when using the diag commands.

Make sure that the radio goes back to sleep after
a transmission when the sleep mode is on. This helps command
like "diag repeat" work more reliably as the transmission
is less likely to be interferred with the accidental frame
reception.

Signed-off-by: Damian Krolik <[email protected]>
This commit is contained in:
Damian Królik
2025-01-22 13:48:53 -08:00
committed by GitHub
parent 436f1f0dd6
commit f8a3e51db6
2 changed files with 13 additions and 1 deletions
+12 -1
View File
@@ -343,8 +343,12 @@ Error Diags::ProcessChannel(uint8_t aArgsLength, char *aArgs[])
VerifyOrExit(IsChannelValid(channel), error = kErrorInvalidArgs);
mChannel = channel;
IgnoreError(Get<Radio>().Receive(mChannel));
otPlatDiagChannelSet(mChannel);
if (!mIsSleepOn)
{
IgnoreError(Get<Radio>().Receive(mChannel));
}
}
exit:
@@ -620,6 +624,7 @@ Error Diags::RadioReceive(void)
SuccessOrExit(error = Get<Radio>().SetTransmitPower(mTxPower));
otPlatDiagChannelSet(mChannel);
otPlatDiagTxPowerSet(mTxPower);
mIsSleepOn = false;
exit:
return error;
@@ -634,6 +639,7 @@ Error Diags::ProcessRadio(uint8_t aArgsLength, char *aArgs[])
if (StringMatch(aArgs[0], "sleep"))
{
SuccessOrExit(error = Get<Radio>().Sleep());
mIsSleepOn = true;
}
else if (StringMatch(aArgs[0], "receive"))
{
@@ -861,6 +867,11 @@ void Diags::TransmitDone(Error aError)
VerifyOrExit(mDiagSendOn);
mDiagSendOn = false;
if (mIsSleepOn)
{
IgnoreError(Get<Radio>().Sleep());
}
switch (aError)
{
case kErrorNone:
+1
View File
@@ -259,6 +259,7 @@ private:
bool mIsAsyncSend : 1;
bool mRepeatActive : 1;
bool mDiagSendOn : 1;
bool mIsSleepOn : 1;
#endif
ReceiveConfig mReceiveConfig;