Permalink
Browse files

[posix-app] get radio caps from NCP (#3021)

  • Loading branch information...
bukepo authored and jwhui committed Sep 6, 2018
1 parent f227bbe commit b45cc3cd6358e89ebc8c01359e135d33b7175f10
@@ -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 @@ void NcpBase::LinkRawEnergyScanDone(int8_t aEnergyScanMaxRssi)
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.
View
@@ -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 @@ class RadioSpinel
*/
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 @@ class RadioSpinel
otExtAddress mExtendedAddress;
uint16_t mShortAddress;
uint16_t mPanid;
otRadioCaps mRadioCaps;
uint8_t mChannel;
int8_t mRxSensitivity;
uint8_t mTxState;

0 comments on commit b45cc3c

Please sign in to comment.