[otns] emit device mode (#5268)

This commit allows OTNS to correctly visualize node mode when it
changes.
This commit is contained in:
Simon Lin
2020-07-21 23:09:18 -07:00
committed by GitHub
parent 5e9b2818eb
commit 2129b567b4
3 changed files with 18 additions and 0 deletions
+4
View File
@@ -778,6 +778,10 @@ otError Mle::SetDeviceMode(DeviceMode aDeviceMode)
VerifyOrExit(mDeviceMode != aDeviceMode, OT_NOOP);
mDeviceMode = aDeviceMode;
#if OPENTHREAD_CONFIG_OTNS_ENABLE
Get<Utils::Otns>().EmitDeviceMode(mDeviceMode);
#endif
otLogNoteMle("Mode 0x%02x -> 0x%02x [%s]", oldMode.Get(), mDeviceMode.Get(), mDeviceMode.ToString().AsCString());
IgnoreError(Store());
+6
View File
@@ -153,6 +153,12 @@ void Otns::EmitTransmit(const Mac::TxFrame &aFrame)
}
}
void Otns::EmitDeviceMode(Mle::DeviceMode aMode)
{
EmitStatus("mode=%s%s%s%s", aMode.IsRxOnWhenIdle() ? "r" : "", aMode.IsSecureDataRequest() ? "s" : "",
aMode.IsFullThreadDevice() ? "d" : "", aMode.IsFullNetworkData() ? "n" : "");
}
} // namespace Utils
} // namespace ot
+8
View File
@@ -132,6 +132,14 @@ public:
*/
static void EmitTransmit(const Mac::TxFrame &aFrame);
/**
* This function emits the device mode to OTNS.
*
* @param[in] aMode The device mode.
*
*/
static void EmitDeviceMode(Mle::DeviceMode aMode);
private:
static void EmitStatus(const char *aFmt, ...);