mirror of
https://github.com/espressif/openthread.git
synced 2026-08-09 04:07:47 +00:00
[ncp] fix issues when OPENTHREAD_ENABLE_RAW_LINK_API is disabled (#2093)
This commit ensues that some properties/methods which are defined under "raw-link-api" feature only are also `#ifdef`ed in the lookup entry table definitions. Another change is related to `HandleRawFrame()` method which is used/needed for packet capture independent of "raw-link-api" feature.
This commit is contained in:
committed by
Jonathan Hui
parent
444d2e4c84
commit
5c8a105f66
+69
-2
@@ -95,7 +95,6 @@ const NcpBase::GetPropertyHandlerEntry NcpBase::mGetPropertyHandlerTable[] =
|
||||
NCP_GET_PROP_HANDLER_ENTRY(INTERFACE_TYPE),
|
||||
NCP_GET_PROP_HANDLER_ENTRY(LAST_STATUS),
|
||||
NCP_GET_PROP_HANDLER_ENTRY(LOCK),
|
||||
NCP_GET_PROP_HANDLER_ENTRY(PHY_ENABLED),
|
||||
NCP_GET_PROP_HANDLER_ENTRY(PHY_CHAN),
|
||||
NCP_GET_PROP_HANDLER_ENTRY(PHY_RX_SENSITIVITY),
|
||||
NCP_GET_PROP_HANDLER_ENTRY(PHY_TX_POWER),
|
||||
@@ -103,13 +102,16 @@ const NcpBase::GetPropertyHandlerEntry NcpBase::mGetPropertyHandlerTable[] =
|
||||
NCP_GET_PROP_HANDLER_ENTRY(PROTOCOL_VERSION),
|
||||
NCP_GET_PROP_HANDLER_ENTRY(MAC_15_4_PANID),
|
||||
NCP_GET_PROP_HANDLER_ENTRY(MAC_15_4_LADDR),
|
||||
NCP_GET_PROP_HANDLER_ENTRY(MAC_15_4_SADDR),
|
||||
NCP_GET_PROP_HANDLER_ENTRY(MAC_RAW_STREAM_ENABLED),
|
||||
NCP_GET_PROP_HANDLER_ENTRY(MAC_PROMISCUOUS_MODE),
|
||||
NCP_GET_PROP_HANDLER_ENTRY(NCP_VERSION),
|
||||
NCP_GET_PROP_HANDLER_ENTRY(UNSOL_UPDATE_FILTER),
|
||||
NCP_GET_PROP_HANDLER_ENTRY(UNSOL_UPDATE_LIST),
|
||||
NCP_GET_PROP_HANDLER_ENTRY(VENDOR_ID),
|
||||
#if OPENTHREAD_ENABLE_RAW_LINK_API
|
||||
NCP_GET_PROP_HANDLER_ENTRY(PHY_ENABLED),
|
||||
NCP_GET_PROP_HANDLER_ENTRY(MAC_15_4_SADDR),
|
||||
#endif
|
||||
|
||||
#if OPENTHREAD_MTD || OPENTHREAD_FTD
|
||||
NCP_GET_PROP_HANDLER_ENTRY(MAC_DATA_POLL_PERIOD),
|
||||
@@ -862,6 +864,71 @@ void NcpBase::RegisterPeekPokeDelagates(otNcpDelegateAllowPeekPoke aAllowPeekDel
|
||||
}
|
||||
|
||||
#endif // OPENTHREAD_CONFIG_NCP_ENABLE_PEEK_POKE
|
||||
|
||||
// ----------------------------------------------------------------------------
|
||||
// MARK: Raw frame handling
|
||||
// ----------------------------------------------------------------------------
|
||||
|
||||
void NcpBase::HandleRawFrame(const otRadioFrame *aFrame, void *aContext)
|
||||
{
|
||||
static_cast<NcpBase *>(aContext)->HandleRawFrame(aFrame);
|
||||
}
|
||||
|
||||
void NcpBase::HandleRawFrame(const otRadioFrame *aFrame)
|
||||
{
|
||||
uint16_t flags = 0;
|
||||
uint8_t header = SPINEL_HEADER_FLAG | SPINEL_HEADER_IID_0;
|
||||
|
||||
if (!mIsRawStreamEnabled)
|
||||
{
|
||||
goto exit;
|
||||
}
|
||||
|
||||
SuccessOrExit(OutboundFrameBegin(header));
|
||||
|
||||
if (aFrame->mDidTX)
|
||||
{
|
||||
flags |= SPINEL_MD_FLAG_TX;
|
||||
}
|
||||
|
||||
// Append frame header and frame length
|
||||
SuccessOrExit(
|
||||
OutboundFrameFeedPacked(
|
||||
SPINEL_DATATYPE_COMMAND_PROP_S SPINEL_DATATYPE_UINT16_S,
|
||||
header,
|
||||
SPINEL_CMD_PROP_VALUE_IS,
|
||||
SPINEL_PROP_STREAM_RAW,
|
||||
aFrame->mLength
|
||||
));
|
||||
|
||||
// Append the frame contents
|
||||
SuccessOrExit(OutboundFrameFeedData(aFrame->mPsdu, aFrame->mLength));
|
||||
|
||||
// Append metadata (rssi, etc)
|
||||
SuccessOrExit(
|
||||
OutboundFrameFeedPacked(
|
||||
SPINEL_DATATYPE_INT8_S
|
||||
SPINEL_DATATYPE_INT8_S
|
||||
SPINEL_DATATYPE_UINT16_S
|
||||
SPINEL_DATATYPE_STRUCT_S( // PHY-data
|
||||
SPINEL_DATATYPE_NULL_S // Empty for now
|
||||
)
|
||||
SPINEL_DATATYPE_STRUCT_S( // Vendor-data
|
||||
SPINEL_DATATYPE_NULL_S // Empty for now
|
||||
),
|
||||
aFrame->mPower, // TX Power
|
||||
-128, // Noise Floor (Currently unused)
|
||||
flags // Flags
|
||||
|
||||
// Skip PHY and Vendor data for now
|
||||
));
|
||||
|
||||
SuccessOrExit(OutboundFrameSend());
|
||||
|
||||
exit:
|
||||
return;
|
||||
}
|
||||
|
||||
// ----------------------------------------------------------------------------
|
||||
// MARK: Property/Status Changed
|
||||
// ----------------------------------------------------------------------------
|
||||
|
||||
@@ -328,6 +328,9 @@ private:
|
||||
NcpFrameBuffer::Priority aPriority, NcpFrameBuffer *aNcpBuffer);
|
||||
void HandleFrameRemovedFromNcpBuffer(NcpFrameBuffer::FrameTag aFrameTag);
|
||||
|
||||
static void HandleRawFrame(const otRadioFrame *aFrame, void *aContext);
|
||||
void HandleRawFrame(const otRadioFrame *aFrame);
|
||||
|
||||
#if OPENTHREAD_ENABLE_RAW_LINK_API
|
||||
|
||||
static void LinkRawReceiveDone(otInstance *aInstance, otRadioFrame *aFrame, otError aError);
|
||||
@@ -339,8 +342,6 @@ private:
|
||||
static void LinkRawEnergyScanDone(otInstance *aInstance, int8_t aEnergyScanMaxRssi);
|
||||
void LinkRawEnergyScanDone(int8_t aEnergyScanMaxRssi);
|
||||
|
||||
static void HandleRawFrame(const otRadioFrame *aFrame, void *aContext);
|
||||
void HandleRawFrame(const otRadioFrame *aFrame);
|
||||
#endif // OPENTHREAD_ENABLE_RAW_LINK_API
|
||||
|
||||
#if OPENTHREAD_MTD || OPENTHREAD_FTD
|
||||
@@ -403,6 +404,7 @@ private:
|
||||
NCP_GET_PROP_HANDLER(PHY_RX_SENSITIVITY);
|
||||
NCP_GET_PROP_HANDLER(PHY_TX_POWER);
|
||||
NCP_SET_PROP_HANDLER(PHY_TX_POWER);
|
||||
NCP_GET_PROP_HANDLER(PHY_ENABLED);
|
||||
NCP_SET_PROP_HANDLER(PHY_CHAN);
|
||||
NCP_GET_PROP_HANDLER(PHY_CHAN);
|
||||
|
||||
@@ -437,7 +439,6 @@ private:
|
||||
NCP_INSERT_PROP_HANDLER(MAC_SRC_MATCH_EXTENDED_ADDRESSES);
|
||||
NCP_REMOVE_PROP_HANDLER(MAC_SRC_MATCH_EXTENDED_ADDRESSES);
|
||||
|
||||
NCP_GET_PROP_HANDLER(PHY_ENABLED);
|
||||
NCP_SET_PROP_HANDLER(PHY_ENABLED);
|
||||
NCP_SET_PROP_HANDLER(STREAM_RAW);
|
||||
#endif // OPENTHREAD_ENABLE_RAW_LINK_API
|
||||
|
||||
@@ -59,6 +59,8 @@
|
||||
namespace ot {
|
||||
namespace Ncp {
|
||||
|
||||
#if OPENTHREAD_ENABLE_RAW_LINK_API
|
||||
|
||||
static bool HasOnly1BitSet(uint32_t aValue)
|
||||
{
|
||||
return aValue != 0 && ((aValue & (aValue - 1)) == 0);
|
||||
@@ -76,6 +78,8 @@ static uint8_t IndexOfMSB(uint32_t aValue)
|
||||
return index;
|
||||
}
|
||||
|
||||
#endif // OPENTHREAD_ENABLE_RAW_LINK_API
|
||||
|
||||
static uint8_t BorderRouterConfigToFlagByte(const otBorderRouterConfig &aConfig)
|
||||
{
|
||||
uint8_t flags(0);
|
||||
|
||||
@@ -214,69 +214,6 @@ void NcpBase::LinkRawEnergyScanDone(int8_t aEnergyScanMaxRssi)
|
||||
);
|
||||
}
|
||||
|
||||
// ----------------------------------------------------------------------------
|
||||
// MARK: Raw frame handling
|
||||
// ----------------------------------------------------------------------------
|
||||
|
||||
void NcpBase::HandleRawFrame(const otRadioFrame *aFrame, void *aContext)
|
||||
{
|
||||
static_cast<NcpBase *>(aContext)->HandleRawFrame(aFrame);
|
||||
}
|
||||
|
||||
void NcpBase::HandleRawFrame(const otRadioFrame *aFrame)
|
||||
{
|
||||
uint16_t flags = 0;
|
||||
uint8_t header = SPINEL_HEADER_FLAG | SPINEL_HEADER_IID_0;
|
||||
|
||||
if (!mIsRawStreamEnabled)
|
||||
{
|
||||
goto exit;
|
||||
}
|
||||
|
||||
SuccessOrExit(OutboundFrameBegin(header));
|
||||
|
||||
if (aFrame->mDidTX)
|
||||
{
|
||||
flags |= SPINEL_MD_FLAG_TX;
|
||||
}
|
||||
|
||||
// Append frame header and frame length
|
||||
SuccessOrExit(
|
||||
OutboundFrameFeedPacked(
|
||||
SPINEL_DATATYPE_COMMAND_PROP_S SPINEL_DATATYPE_UINT16_S,
|
||||
header,
|
||||
SPINEL_CMD_PROP_VALUE_IS,
|
||||
SPINEL_PROP_STREAM_RAW,
|
||||
aFrame->mLength
|
||||
));
|
||||
|
||||
// Append the frame contents
|
||||
SuccessOrExit(OutboundFrameFeedData(aFrame->mPsdu, aFrame->mLength));
|
||||
|
||||
// Append metadata (rssi, etc)
|
||||
SuccessOrExit(
|
||||
OutboundFrameFeedPacked(
|
||||
SPINEL_DATATYPE_INT8_S
|
||||
SPINEL_DATATYPE_INT8_S
|
||||
SPINEL_DATATYPE_UINT16_S
|
||||
SPINEL_DATATYPE_STRUCT_S( // PHY-data
|
||||
SPINEL_DATATYPE_NULL_S // Empty for now
|
||||
)
|
||||
SPINEL_DATATYPE_STRUCT_S( // Vendor-data
|
||||
SPINEL_DATATYPE_NULL_S // Empty for now
|
||||
),
|
||||
aFrame->mPower, // TX Power
|
||||
-128, // Noise Floor (Currently unused)
|
||||
flags // Flags
|
||||
|
||||
// Skip PHY and Vendor data for now
|
||||
));
|
||||
|
||||
SuccessOrExit(OutboundFrameSend());
|
||||
|
||||
exit:
|
||||
return;
|
||||
}
|
||||
|
||||
otError NcpBase::SetPropertyHandler_MAC_SRC_MATCH_ENABLED(uint8_t aHeader, spinel_prop_key_t aKey,
|
||||
const uint8_t *aValuePtr, uint16_t aValueLen)
|
||||
|
||||
Reference in New Issue
Block a user