[diag] set rx_when_idle mode when diag start/stop (#11035)

This commit fixes an issue related to #9554 where a new radio
capability is introduced: RX_ON_WHEN_IDLE.

In this commit, we set `rx_on_when_idle` to be true when calling `diag
start`, and false when calling `diag stop` for devices which support
`rx_on_when_idle`.

This fix ensures that packets can still be received if `diag` is used
after `ifconfig down`.
This commit is contained in:
yanquantan
2024-12-12 22:11:02 -08:00
committed by GitHub
parent d83ddf7137
commit d539ad3226
+2
View File
@@ -495,6 +495,7 @@ Error Diags::ProcessStart(uint8_t aArgsLength, char *aArgs[])
IgnoreError(Get<Radio>().Enable());
Get<Radio>().SetPromiscuous(true);
Get<Mac::SubMac>().SetRxOnWhenIdle(true);
otPlatAlarmMilliStop(&GetInstance());
SuccessOrExit(error = Get<Radio>().Receive(mChannel));
SuccessOrExit(error = Get<Radio>().SetTransmitPower(mTxPower));
@@ -546,6 +547,7 @@ Error Diags::ProcessStop(uint8_t aArgsLength, char *aArgs[])
otPlatAlarmMilliStop(&GetInstance());
otPlatDiagModeSet(false);
Get<Radio>().SetPromiscuous(false);
Get<Mac::SubMac>().SetRxOnWhenIdle(false);
Output("received packets: %d\r\nsent packets: %d\r\n"
"first received packet: rssi=%d, lqi=%d\r\n"