mirror of
https://github.com/espressif/openthread.git
synced 2026-07-27 22:37:45 +00:00
[posix-app] get radio caps from NCP (#3021)
This commit is contained in:
@@ -617,6 +617,9 @@ NcpBase::PropertyHandler NcpBase::FindGetPropertyHandler(spinel_prop_key_t aKey)
|
||||
// Raw Link API Properties (Get Handler)
|
||||
|
||||
#if OPENTHREAD_RADIO || OPENTHREAD_ENABLE_RAW_LINK_API
|
||||
case SPINEL_PROP_RADIO_CAPS:
|
||||
handler = &NcpBase::HandlePropertyGet<SPINEL_PROP_RADIO_CAPS>;
|
||||
break;
|
||||
case SPINEL_PROP_MAC_SRC_MATCH_ENABLED:
|
||||
handler = &NcpBase::HandlePropertyGet<SPINEL_PROP_MAC_SRC_MATCH_ENABLED>;
|
||||
break;
|
||||
|
||||
@@ -177,6 +177,11 @@ exit:
|
||||
return;
|
||||
}
|
||||
|
||||
template <> otError NcpBase::HandlePropertyGet<SPINEL_PROP_RADIO_CAPS>(void)
|
||||
{
|
||||
return mEncoder.WriteUintPacked(otLinkRawGetCaps(mInstance));
|
||||
}
|
||||
|
||||
template <> otError NcpBase::HandlePropertyGet<SPINEL_PROP_MAC_SRC_MATCH_ENABLED>(void)
|
||||
{
|
||||
// TODO: Would be good to add an `otLinkRaw` API to give the the status of source match.
|
||||
|
||||
@@ -845,6 +845,16 @@ typedef enum {
|
||||
*/
|
||||
SPINEL_PROP_CHANNEL_MONITOR_CHANNEL_OCCUPANCY = SPINEL_PROP_PHY_EXT__BEGIN + 10,
|
||||
|
||||
/// Radio caps
|
||||
/** Format: `i` (read-only)
|
||||
*
|
||||
* Data per item is:
|
||||
*
|
||||
* `i`: Radio Capabilities.
|
||||
*
|
||||
*/
|
||||
SPINEL_PROP_RADIO_CAPS = SPINEL_PROP_PHY_EXT__BEGIN + 11,
|
||||
|
||||
SPINEL_PROP_PHY_EXT__END = 0x1300,
|
||||
|
||||
SPINEL_PROP_MAC__BEGIN = 0x30,
|
||||
|
||||
@@ -395,6 +395,12 @@ void RadioSpinel::Init(const char *aRadioFile, const char *aRadioConfig)
|
||||
VerifyOrExit(mIsReady, error = OT_ERROR_FAILED);
|
||||
SuccessOrExit(error = Get(SPINEL_PROP_HWADDR, SPINEL_DATATYPE_UINT64_S, &NODE_ID));
|
||||
|
||||
{
|
||||
unsigned int caps;
|
||||
SuccessOrExit(error = Get(SPINEL_PROP_RADIO_CAPS, SPINEL_DATATYPE_UINT_PACKED_S, &caps));
|
||||
mRadioCaps = static_cast<otRadioCaps>(caps);
|
||||
}
|
||||
|
||||
mRxRadioFrame.mPsdu = mRxPsdu;
|
||||
mTxRadioFrame.mPsdu = mTxPsdu;
|
||||
|
||||
@@ -1518,8 +1524,7 @@ int8_t otPlatRadioGetRssi(otInstance *aInstance)
|
||||
otRadioCaps otPlatRadioGetCaps(otInstance *aInstance)
|
||||
{
|
||||
OT_UNUSED_VARIABLE(aInstance);
|
||||
return static_cast<otRadioCaps>(OT_RADIO_CAPS_ACK_TIMEOUT | OT_RADIO_CAPS_TRANSMIT_RETRIES |
|
||||
OT_RADIO_CAPS_CSMA_BACKOFF);
|
||||
return sRadioSpinel.GetRadioCaps();
|
||||
}
|
||||
|
||||
bool otPlatRadioGetPromiscuous(otInstance *aInstance)
|
||||
|
||||
@@ -160,6 +160,14 @@ public:
|
||||
*/
|
||||
otError SetTransmitPower(int8_t aPower);
|
||||
|
||||
/**
|
||||
* This method returns the radio capabilities.
|
||||
*
|
||||
* @returns The radio capability bit vector.
|
||||
*
|
||||
*/
|
||||
otRadioCaps GetRadioCaps(void) const { return mRadioCaps; }
|
||||
|
||||
/**
|
||||
* This method returns the radio receive sensitivity value.
|
||||
*
|
||||
@@ -513,6 +521,7 @@ private:
|
||||
otExtAddress mExtendedAddress;
|
||||
uint16_t mShortAddress;
|
||||
uint16_t mPanid;
|
||||
otRadioCaps mRadioCaps;
|
||||
uint8_t mChannel;
|
||||
int8_t mRxSensitivity;
|
||||
uint8_t mTxState;
|
||||
|
||||
Reference in New Issue
Block a user