mirror of
https://github.com/espressif/openthread.git
synced 2026-08-04 01:47:47 +00:00
[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:
@@ -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:
|
||||
|
||||
@@ -259,6 +259,7 @@ private:
|
||||
bool mIsAsyncSend : 1;
|
||||
bool mRepeatActive : 1;
|
||||
bool mDiagSendOn : 1;
|
||||
bool mIsSleepOn : 1;
|
||||
#endif
|
||||
|
||||
ReceiveConfig mReceiveConfig;
|
||||
|
||||
Reference in New Issue
Block a user