diff --git a/src/posix/platform/radio_spinel.cpp b/src/posix/platform/radio_spinel.cpp index 8cd57df8a..33f93f53a 100644 --- a/src/posix/platform/radio_spinel.cpp +++ b/src/posix/platform/radio_spinel.cpp @@ -54,55 +54,8 @@ #include #include -enum -{ - IEEE802154_MIN_LENGTH = 5, - IEEE802154_MAX_LENGTH = 127, - IEEE802154_ACK_LENGTH = 5, - - IEEE802154_BROADCAST = 0xffff, - - IEEE802154_FRAME_TYPE_ACK = 2 << 0, - IEEE802154_FRAME_TYPE_MACCMD = 3 << 0, - IEEE802154_FRAME_TYPE_MASK = 7 << 0, - - IEEE802154_SECURITY_ENABLED = 1 << 3, - IEEE802154_FRAME_PENDING = 1 << 4, - IEEE802154_ACK_REQUEST = 1 << 5, - IEEE802154_PANID_COMPRESSION = 1 << 6, - - IEEE802154_DST_ADDR_NONE = 0 << 2, - IEEE802154_DST_ADDR_SHORT = 2 << 2, - IEEE802154_DST_ADDR_EXT = 3 << 2, - IEEE802154_DST_ADDR_MASK = 3 << 2, - - IEEE802154_SRC_ADDR_NONE = 0 << 6, - IEEE802154_SRC_ADDR_SHORT = 2 << 6, - IEEE802154_SRC_ADDR_EXT = 3 << 6, - IEEE802154_SRC_ADDR_MASK = 3 << 6, - - IEEE802154_DSN_OFFSET = 2, - IEEE802154_DSTPAN_OFFSET = 3, - IEEE802154_DSTADDR_OFFSET = 5, - - IEEE802154_SEC_LEVEL_MASK = 7 << 0, - - IEEE802154_KEY_ID_MODE_0 = 0 << 3, - IEEE802154_KEY_ID_MODE_1 = 1 << 3, - IEEE802154_KEY_ID_MODE_2 = 2 << 3, - IEEE802154_KEY_ID_MODE_3 = 3 << 3, - IEEE802154_KEY_ID_MODE_MASK = 3 << 3, - - IEEE802154_MACCMD_DATA_REQ = 4, -}; - static ot::PosixApp::RadioSpinel sRadioSpinel; -static inline bool isAckRequested(const uint8_t *frame) -{ - return (frame[0] & IEEE802154_ACK_REQUEST) != 0; -} - namespace ot { namespace PosixApp { @@ -206,7 +159,6 @@ RadioSpinel::RadioSpinel(void) , mWaitingKey(SPINEL_PROP_LAST_STATUS) , mRxSensitivity(0) , mState(kStateDisabled) - , mIsAckRequested(false) , mIsPromiscuous(false) , mIsReady(false) , mSupportsLogStream(false) @@ -725,7 +677,8 @@ void RadioSpinel::Process(const fd_set &aReadFdSet, const fd_set &aWriteFdSet) else #endif { - otPlatRadioTxDone(mInstance, mTransmitFrame, (mIsAckRequested ? &mAckRadioFrame : NULL), mTxError); + otPlatRadioTxDone(mInstance, mTransmitFrame, (mAckRadioFrame.mLength != 0) ? &mAckRadioFrame : NULL, + mTxError); } } @@ -1043,8 +996,6 @@ void RadioSpinel::RadioTransmit(void) otPlatRadioTxStarted(mInstance, mTransmitFrame); assert(mState == kStateTransmitPending); - mIsAckRequested = isAckRequested(mTransmitFrame->mPsdu) && !mIsPromiscuous; - error = Request(true, SPINEL_CMD_PROP_VALUE_SET, SPINEL_PROP_STREAM_RAW, SPINEL_DATATYPE_DATA_WLEN_S SPINEL_DATATYPE_UINT8_S SPINEL_DATATYPE_INT8_S, mTransmitFrame->mPsdu, mTransmitFrame->mLength, mTransmitFrame->mChannel, mTransmitFrame->mInfo.mRxInfo.mRssi); @@ -1189,11 +1140,14 @@ void RadioSpinel::HandleTransmitDone(uint32_t aCommand, aBuffer += unpacked; aLength -= static_cast(unpacked); - if (mIsAckRequested) + if (aLength > 0) { - VerifyOrExit(aLength > 0, error = OT_ERROR_FAILED); SuccessOrExit(error = ParseRadioFrame(mAckRadioFrame, aBuffer, aLength)); } + else + { + mAckRadioFrame.mLength = 0; + } } else { @@ -1567,7 +1521,8 @@ void ot::PosixApp::RadioSpinel::Process(const Event &aEvent) else #endif { - otPlatRadioTxDone(mInstance, mTransmitFrame, (mIsAckRequested ? &mAckRadioFrame : NULL), mTxError); + otPlatRadioTxDone(mInstance, mTransmitFrame, (mAckRadioFrame.mLength != 0) ? &mAckRadioFrame : NULL, + mTxError); } } diff --git a/src/posix/platform/radio_spinel.hpp b/src/posix/platform/radio_spinel.hpp index c7f7321ff..ce872ad5c 100644 --- a/src/posix/platform/radio_spinel.hpp +++ b/src/posix/platform/radio_spinel.hpp @@ -609,7 +609,6 @@ private: char mVersion[kVersionStringSize]; State mState; - bool mIsAckRequested : 1; ///< Ack requested. bool mIsPromiscuous : 1; ///< Promiscuous mode. bool mIsReady : 1; ///< NCP ready. bool mSupportsLogStream : 1; ///< RCP supports `LOG_STREAM` property with OpenThread log meta-data format.