diff --git a/examples/platform/posix/radio.cpp b/examples/platform/posix/radio.cpp index 7da633da2..785d539c6 100644 --- a/examples/platform/posix/radio.cpp +++ b/examples/platform/posix/radio.cpp @@ -463,6 +463,7 @@ ThreadError otPlatRadioHandleReceiveDone() } s_receive_frame->mPower = -20; + s_receive_frame->mLqi = kPhyNoLqi; // generate acknowledgment if (reinterpret_cast(s_receive_frame)->GetAckRequest()) diff --git a/include/openthread-types.h b/include/openthread-types.h index 2d9ed0842..2bccd7dfb 100644 --- a/include/openthread-types.h +++ b/include/openthread-types.h @@ -116,6 +116,7 @@ typedef struct otActiveScanResult uint16_t mPanId; ///< IEEE 802.15.4 PAN ID uint8_t mChannel; ///< IEEE 802.15.4 Channel int8_t mRssi; ///< RSSI (dBm) + uint8_t mLqi; ///< LQI uint8_t mVersion : 4; ///< Version bool mIsNative : 1; ///< Native Commissioner flag bool mIsJoinable : 1; ///< Joining Permitted flag diff --git a/include/platform/radio.h b/include/platform/radio.h index cff96d58a..fe6dbaee7 100644 --- a/include/platform/radio.h +++ b/include/platform/radio.h @@ -75,6 +75,8 @@ enum kPhyBitsPerOctet = 8, kPhyUsPerSymbol = ((kPhyBitsPerOctet / kPhySymbolsPerOctet) * 1000000) / kPhyBitRate, + + kPhyNoLqi = 0, ///< LQI measurement not supported }; /** @@ -97,6 +99,7 @@ typedef struct RadioPacket uint8_t mPsdu[kMaxPHYPacketSize]; ///< The PSDU. uint8_t mChannel; ///< Channel used to transmit/receive the frame. int8_t mPower; ///< Transmit/receive power in dBm. + uint8_t mLqi; ///< Link Quality Indicator for received frames. bool mSecurityValid; ///< Security Enabled flag is set and frame passes security checks. } RadioPacket; diff --git a/src/cli/cli.cpp b/src/cli/cli.cpp index 1bf96d7a8..e32a8180f 100644 --- a/src/cli/cli.cpp +++ b/src/cli/cli.cpp @@ -852,8 +852,8 @@ void Interpreter::ProcessScan(int argc, char *argv[]) } SuccessOrExit(error = otActiveScan(scanChannels, 0, &HandleActiveScanResult)); - sServer->OutputFormat("| J | Network Name | Extended PAN | PAN | MAC Address | Ch | dBm |\r\n"); - sServer->OutputFormat("+---+------------------+------------------+------+------------------+----+-----+\r\n"); + sServer->OutputFormat("| J | Network Name | Extended PAN | PAN | MAC Address | Ch | dBm | LQI |\r\n"); + sServer->OutputFormat("+---+------------------+------------------+------+------------------+----+-----+-----+\r\n"); return; @@ -898,8 +898,9 @@ void Interpreter::HandleActiveScanResult(otActiveScanResult *aResult) bytes = aResult->mExtAddress.m8; sServer->OutputFormat("| %02x%02x%02x%02x%02x%02x%02x%02x ", bytes[0], bytes[1], bytes[2], bytes[3], bytes[4], bytes[5], bytes[6], bytes[7]); - sServer->OutputFormat("| %02d ", aResult->mChannel); - sServer->OutputFormat("| %03d |\r\n", aResult->mRssi); + sServer->OutputFormat("| %2d ", aResult->mChannel); + sServer->OutputFormat("| %3d ", aResult->mRssi); + sServer->OutputFormat("| %3d |\r\n", aResult->mLqi); exit: return; diff --git a/src/cli/cli_serial.hpp b/src/cli/cli_serial.hpp index 3a76753e0..68f6a5d92 100644 --- a/src/cli/cli_serial.hpp +++ b/src/cli/cli_serial.hpp @@ -88,7 +88,7 @@ private: { kRxBufferSize = 128, kTxBufferSize = 512, - kMaxLineLength = 80, + kMaxLineLength = 128, }; static void ReceiveTask(void *aContext); diff --git a/src/core/mac/mac_frame.hpp b/src/core/mac/mac_frame.hpp index 9e7858463..8f67e2925 100644 --- a/src/core/mac/mac_frame.hpp +++ b/src/core/mac/mac_frame.hpp @@ -515,6 +515,22 @@ public: */ void SetPower(int8_t aPower) { mPower = aPower; } + /** + * This method returns the receive Link Quality Indicator. + * + * @returns The receive Link Quality Indicator. + * + */ + int8_t GetLqi(void) const { return mLqi; } + + /** + * This method sets the receive Link Quality Indicator. + * + * @param[in] aLqi The receive Link Quality Indicator. + * + */ + void SetLqi(int8_t aLqi) { mLqi = aLqi; } + /** * This method indicates whether or not frame security was enabled and passed security validation. * diff --git a/src/core/openthread.cpp b/src/core/openthread.cpp index ac816319e..4001bf235 100644 --- a/src/core/openthread.cpp +++ b/src/core/openthread.cpp @@ -508,6 +508,7 @@ void HandleActiveScanResult(void *aContext, Mac::Frame *aFrame) aFrame->GetSrcPanId(result.mPanId); result.mChannel = aFrame->GetChannel(); result.mRssi = aFrame->GetPower(); + result.mLqi = aFrame->GetLqi(); payloadLength = aFrame->GetPayloadLength(); beacon = reinterpret_cast(aFrame->GetPayload()); diff --git a/src/core/thread/mesh_forwarder.cpp b/src/core/thread/mesh_forwarder.cpp index 2cbc54aa6..ac093222d 100644 --- a/src/core/thread/mesh_forwarder.cpp +++ b/src/core/thread/mesh_forwarder.cpp @@ -1015,6 +1015,7 @@ void MeshForwarder::HandleReceivedFrame(Mac::Frame &aFrame, ThreadError aError) SuccessOrExit(aFrame.GetDstAddr(macDest)); messageInfo.mLinkMargin = aFrame.GetPower() - -100; + messageInfo.mLqi = aFrame.GetLqi(); messageInfo.mSecurityValid = aFrame.GetSecurityValid(); payload = aFrame.GetPayload(); diff --git a/src/core/thread/thread_netif.hpp b/src/core/thread/thread_netif.hpp index 79c49512d..b974d37b9 100644 --- a/src/core/thread/thread_netif.hpp +++ b/src/core/thread/thread_netif.hpp @@ -216,6 +216,7 @@ private: struct ThreadMessageInfo { uint8_t mLinkMargin; ///< The Link Margin for a received message in dBm. + uint8_t mLqi; ///< The Link Quality Indicator for a received message. bool mSecurityValid; ///< Link security on all received frames was enabled and passed validation. };