[diag] check state before entering diagnostic mode (#5908)

This commit restrict diagnostic mode only when network stack is not up,
which prevents some issues caused by switching to diag mode after the
device was attached. For example, timers may not be triggered properly
after returnning from diagnostic mode.
This commit is contained in:
Yakun Xu
2020-12-02 23:16:08 -08:00
committed by GitHub
parent 63b9f3ebb4
commit a8b5b07849
2 changed files with 5 additions and 0 deletions
+2
View File
@@ -288,6 +288,8 @@ otError Diags::ProcessStart(uint8_t aArgsLength, char *aArgs[], char *aOutput, s
otError error = OT_ERROR_NONE;
VerifyOrExit(!Get<ThreadNetif>().IsUp(), error = OT_ERROR_INVALID_STATE);
otPlatDiagChannelSet(mChannel);
otPlatDiagTxPowerSet(mTxPower);
+3
View File
@@ -164,4 +164,7 @@ expect "0:0:0:0::/64 s low"
send "route remove ::/64\n"
expect "Done"
send "diag start\n"
expect ": InvalidState"
dispose_all