diff --git a/include/openthread/types.h b/include/openthread/types.h index a683b517f..fae567c68 100644 --- a/include/openthread/types.h +++ b/include/openthread/types.h @@ -1007,6 +1007,8 @@ typedef struct otBufferInfo uint16_t mCoapBuffers; ///< The number of buffers in the CoAP send queue. uint16_t mCoapSecureMessages; ///< The number of messages in the CoAP secure send queue. uint16_t mCoapSecureBuffers; ///< The number of buffers in the CoAP secure send queue. + uint16_t mApplicationCoapMessages;///< The number of messages in the application CoAP send queue. + uint16_t mApplicationCoapBuffers; ///< The number of buffers in the application CoAP send queue. } otBufferInfo; /** diff --git a/src/cli/cli.cpp b/src/cli/cli.cpp index 5a266fbb6..721612e27 100644 --- a/src/cli/cli.cpp +++ b/src/cli/cli.cpp @@ -441,6 +441,8 @@ void Interpreter::ProcessBufferInfo(int argc, char *argv[]) mServer->OutputFormat("arp: %d %d\r\n", bufferInfo.mArpMessages, bufferInfo.mArpBuffers); mServer->OutputFormat("coap: %d %d\r\n", bufferInfo.mCoapMessages, bufferInfo.mCoapBuffers); mServer->OutputFormat("coap secure: %d %d\r\n", bufferInfo.mCoapSecureMessages, bufferInfo.mCoapSecureBuffers); + mServer->OutputFormat("application coap: %d %d\r\n", bufferInfo.mApplicationCoapMessages, + bufferInfo.mApplicationCoapBuffers); AppendResult(OT_ERROR_NONE); } diff --git a/src/core/api/message_api.cpp b/src/core/api/message_api.cpp index d104594bb..d1e5a1742 100644 --- a/src/core/api/message_api.cpp +++ b/src/core/api/message_api.cpp @@ -152,6 +152,8 @@ exit: void otMessageGetBufferInfo(otInstance *aInstance, otBufferInfo *aBufferInfo) { + uint16_t messages, buffers; + aBufferInfo->mTotalBuffers = OPENTHREAD_CONFIG_NUM_MESSAGE_BUFFERS; aBufferInfo->mFreeBuffers = aInstance->mMessagePool.GetFreeBufferCount(); @@ -176,4 +178,18 @@ void otMessageGetBufferInfo(otInstance *aInstance, otBufferInfo *aBufferInfo) aInstance->mThreadNetif.GetCoap().GetRequestMessages().GetInfo(aBufferInfo->mCoapMessages, aBufferInfo->mCoapBuffers); + aInstance->mThreadNetif.GetCoap().GetCachedResponses().GetInfo(messages, buffers); + aBufferInfo->mCoapMessages += messages; + aBufferInfo->mCoapBuffers += buffers; + +#if OPENTHREAD_ENABLE_APPLICATION_COAP + aInstance->mApplicationCoap.GetRequestMessages().GetInfo(aBufferInfo->mApplicationCoapMessages, + aBufferInfo->mApplicationCoapBuffers); + aInstance->mApplicationCoap.GetCachedResponses().GetInfo(messages, buffers); + aBufferInfo->mApplicationCoapMessages += messages; + aBufferInfo->mApplicationCoapBuffers += buffers; +#else + aBufferInfo->mApplicationCoapMessages = 0; + aBufferInfo->mApplicationCoapBuffers = 0; +#endif }