mirror of
https://github.com/espressif/openthread.git
synced 2026-08-09 04:07:47 +00:00
[cli] enhance buffer info (#5831)
This commit enhances buffer info when using heap for message buffers.
This commit is contained in:
@@ -174,7 +174,7 @@ void otMessageGetBufferInfo(otInstance *aInstance, otBufferInfo *aBufferInfo)
|
||||
uint16_t messages, buffers;
|
||||
Instance &instance = *static_cast<Instance *>(aInstance);
|
||||
|
||||
aBufferInfo->mTotalBuffers = OPENTHREAD_CONFIG_NUM_MESSAGE_BUFFERS;
|
||||
aBufferInfo->mTotalBuffers = instance.Get<MessagePool>().GetTotalBufferCount();
|
||||
|
||||
aBufferInfo->mFreeBuffers = instance.Get<MessagePool>().GetFreeBufferCount();
|
||||
|
||||
|
||||
@@ -42,6 +42,11 @@
|
||||
#include "net/ip6.hpp"
|
||||
|
||||
#if OPENTHREAD_MTD || OPENTHREAD_FTD
|
||||
|
||||
#if OPENTHREAD_CONFIG_MESSAGE_USE_HEAP_ENABLE && !OPENTHREAD_CONFIG_DTLS_ENABLE
|
||||
#error "OPENTHREAD_CONFIG_MESSAGE_USE_HEAP_ENABLE is strongly discouraged when OPENTHREAD_CONFIG_DTLS_ENABLE is off."
|
||||
#endif
|
||||
|
||||
namespace ot {
|
||||
|
||||
MessagePool::MessagePool(Instance &aInstance)
|
||||
@@ -169,6 +174,15 @@ uint16_t MessagePool::GetFreeBufferCount(void) const
|
||||
return rval;
|
||||
}
|
||||
|
||||
uint16_t MessagePool::GetTotalBufferCount(void) const
|
||||
{
|
||||
#if OPENTHREAD_CONFIG_MESSAGE_USE_HEAP_ENABLE
|
||||
return static_cast<uint16_t>(GetInstance().GetHeap().GetCapacity() / sizeof(Buffer));
|
||||
#else
|
||||
return OPENTHREAD_CONFIG_NUM_MESSAGE_BUFFERS;
|
||||
#endif
|
||||
}
|
||||
|
||||
const Message::Settings Message::Settings::kDefault(Message::kWithLinkSecurity, Message::kPriorityNormal);
|
||||
|
||||
Message::Settings::Settings(LinkSecurityMode aSecurityMode, Priority aPriority)
|
||||
|
||||
@@ -1468,6 +1468,14 @@ public:
|
||||
*/
|
||||
uint16_t GetFreeBufferCount(void) const;
|
||||
|
||||
/**
|
||||
* This method returns the total number of buffers.
|
||||
*
|
||||
* @returns The total number of buffers.
|
||||
*
|
||||
*/
|
||||
uint16_t GetTotalBufferCount(void) const;
|
||||
|
||||
private:
|
||||
Buffer *NewBuffer(Message::Priority aPriority);
|
||||
void FreeBuffers(Buffer *aBuffer);
|
||||
|
||||
@@ -546,13 +546,8 @@
|
||||
"(and OPENTHREAD_CONFIG_LOG_DEFINE_AS_MACRO_ONLY)"
|
||||
#endif
|
||||
|
||||
#if OPENTHREAD_CONFIG_MESSAGE_USE_HEAP_ENABLE
|
||||
#if !OPENTHREAD_CONFIG_DTLS_ENABLE
|
||||
#error "OPENTHREAD_CONFIG_MESSAGE_USE_HEAP_ENABLE is strongly discouraged when OPENTHREAD_CONFIG_DTLS_ENABLE is off."
|
||||
#endif
|
||||
#if OPENTHREAD_CONFIG_PLATFORM_MESSAGE_MANAGEMENT
|
||||
#if OPENTHREAD_CONFIG_MESSAGE_USE_HEAP_ENABLE && OPENTHREAD_CONFIG_PLATFORM_MESSAGE_MANAGEMENT
|
||||
#error "OPENTHREAD_CONFIG_MESSAGE_USE_HEAP_ENABLE conflicts with OPENTHREAD_CONFIG_PLATFORM_MESSAGE_MANAGEMENT."
|
||||
#endif
|
||||
#endif
|
||||
|
||||
#endif // OPENTHREAD_CORE_CONFIG_CHECK_H_
|
||||
|
||||
Reference in New Issue
Block a user