[posix-host] add otPlatRadioGetState() (#4504)

This commit implements otPlatRadioGetState() on POSIX platforms,
including simulation and posix-host app.

This is for debugging purpose.
This commit is contained in:
Yakun Xu
2020-01-23 10:45:15 -08:00
committed by Jonathan Hui
parent e5d4b971fe
commit e2800ed10d
3 changed files with 31 additions and 0 deletions
+7
View File
@@ -826,6 +826,13 @@ int8_t otPlatRadioGetReceiveSensitivity(otInstance *aInstance)
return POSIX_RECEIVE_SENSITIVITY;
}
otRadioState otPlatRadioGetState(otInstance *aInstance)
{
OT_UNUSED_VARIABLE(aInstance);
return sState;
}
#if OPENTHREAD_CONFIG_PLATFORM_RADIO_COEX_ENABLE
otError otPlatRadioSetCoexEnabled(otInstance *aInstance, bool aEnabled)
{
+16
View File
@@ -1598,6 +1598,16 @@ exit:
return channelMask;
}
otRadioState RadioSpinel::GetState(void) const
{
static const otRadioState sOtRadioStateMap[] = {
OT_RADIO_STATE_DISABLED, OT_RADIO_STATE_SLEEP, OT_RADIO_STATE_RECEIVE,
OT_RADIO_STATE_TRANSMIT, OT_RADIO_STATE_TRANSMIT,
};
return sOtRadioStateMap[mState];
}
} // namespace PosixApp
} // namespace ot
@@ -1963,3 +1973,9 @@ uint32_t otPlatRadioGetPreferredChannelMask(otInstance *aInstance)
OT_UNUSED_VARIABLE(aInstance);
return sRadioSpinel.GetRadioChannelMask(true);
}
otRadioState otPlatRadioGetState(otInstance *aInstance)
{
OT_UNUSED_VARIABLE(aInstance);
return sRadioSpinel.GetState();
}
+8
View File
@@ -227,6 +227,14 @@ public:
*/
int8_t GetReceiveSensitivity(void) const { return mRxSensitivity; }
/**
* This method gets current state of the radio.
*
* @return Current state of the radio.
*
*/
otRadioState GetState(void) const;
#if OPENTHREAD_CONFIG_PLATFORM_RADIO_COEX_ENABLE
/**
* Enable the radio coex.