mirror of
https://github.com/espressif/openthread.git
synced 2026-08-23 10:49:51 +00:00
[otns] emit device mode (#5268)
This commit allows OTNS to correctly visualize node mode when it changes.
This commit is contained in:
@@ -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());
|
||||
|
||||
@@ -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
|
||||
|
||||
|
||||
@@ -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, ...);
|
||||
|
||||
|
||||
Reference in New Issue
Block a user