mirror of
https://github.com/espressif/openthread.git
synced 2026-08-01 16:47:47 +00:00
[posix] check the max number of RCP supported sleepy children (#10399)
This commit adds a diag command to rcp capbility diag module to check the max number of RCP supported sleepy children.
This commit is contained in:
@@ -8,6 +8,7 @@ This module provides diag commands for checking RCP capabilities.
|
||||
|
||||
- [capflags](#capflags)
|
||||
- [spinel](#spinel)
|
||||
- [srcmatchtable](#srcmatchtable)
|
||||
|
||||
## Command Details
|
||||
|
||||
@@ -112,3 +113,14 @@ PROP_VALUE_SET PHY_TX_POWER ------------------------------- OK
|
||||
PROP_VALUE_SET RADIO_COEX_ENABLE -------------------------- OK
|
||||
Done
|
||||
```
|
||||
|
||||
### srcmatchtable
|
||||
|
||||
Check the source match table size supported by the RCP.
|
||||
|
||||
```bash
|
||||
> diag rcpcaps srcmatchtable
|
||||
ShortSrcMatchTableSize ------------------------------------ 128
|
||||
ExtendedSrcMatchTableSize --------------------------------- 128
|
||||
Done
|
||||
```
|
||||
|
||||
@@ -457,6 +457,10 @@ otError RcpCapsDiag::DiagProcess(char *aArgs[], uint8_t aArgsLength)
|
||||
{
|
||||
ProcessCapabilityFlags();
|
||||
}
|
||||
else if (strcmp(aArgs[1], "srcmatchtable") == 0)
|
||||
{
|
||||
ProcessSrcMatchTable();
|
||||
}
|
||||
else if (strcmp(aArgs[1], "spinel") == 0)
|
||||
{
|
||||
ProcessSpinel();
|
||||
@@ -616,6 +620,66 @@ exit:
|
||||
return ret;
|
||||
}
|
||||
|
||||
void RcpCapsDiag::ProcessSrcMatchTable(void)
|
||||
{
|
||||
OutputShortSrcMatchTableSize();
|
||||
OutputExtendedSrcMatchTableSize();
|
||||
}
|
||||
|
||||
void RcpCapsDiag::OutputShortSrcMatchTableSize(void)
|
||||
{
|
||||
constexpr uint8_t kRouterIdOffset = 10;
|
||||
constexpr uint8_t kRouterId = 5;
|
||||
uint16_t num = 0;
|
||||
uint16_t shortAddress;
|
||||
|
||||
SuccessOrExit(mRadioSpinel.Set(SPINEL_PROP_MAC_SRC_MATCH_ENABLED, SPINEL_DATATYPE_BOOL_S, true /* aEnable */));
|
||||
SuccessOrExit(mRadioSpinel.Set(SPINEL_PROP_MAC_SRC_MATCH_SHORT_ADDRESSES, nullptr));
|
||||
|
||||
for (num = 0; num < kMaxNumChildren; num++)
|
||||
{
|
||||
shortAddress = num | (kRouterId << kRouterIdOffset);
|
||||
SuccessOrExit(
|
||||
mRadioSpinel.Insert(SPINEL_PROP_MAC_SRC_MATCH_SHORT_ADDRESSES, SPINEL_DATATYPE_UINT16_S, shortAddress));
|
||||
}
|
||||
|
||||
exit:
|
||||
if (num != 0)
|
||||
{
|
||||
IgnoreReturnValue(mRadioSpinel.Set(SPINEL_PROP_MAC_SRC_MATCH_SHORT_ADDRESSES, nullptr));
|
||||
IgnoreReturnValue(
|
||||
mRadioSpinel.Set(SPINEL_PROP_MAC_SRC_MATCH_ENABLED, SPINEL_DATATYPE_BOOL_S, false /* aEnable */));
|
||||
}
|
||||
|
||||
OutputFormat("ShortSrcMatchTableSize", num);
|
||||
}
|
||||
|
||||
void RcpCapsDiag::OutputExtendedSrcMatchTableSize(void)
|
||||
{
|
||||
otExtAddress extAddress = {0x11, 0x22, 0x33, 0x44, 0x55, 0x66, 0x77, 0x88};
|
||||
uint16_t num = 0;
|
||||
|
||||
SuccessOrExit(mRadioSpinel.Set(SPINEL_PROP_MAC_SRC_MATCH_ENABLED, SPINEL_DATATYPE_BOOL_S, true /* aEnable */));
|
||||
SuccessOrExit(mRadioSpinel.Set(SPINEL_PROP_MAC_SRC_MATCH_EXTENDED_ADDRESSES, nullptr));
|
||||
|
||||
for (num = 0; num < kMaxNumChildren; num++)
|
||||
{
|
||||
*reinterpret_cast<uint16_t *>(extAddress.m8) = num;
|
||||
SuccessOrExit(
|
||||
mRadioSpinel.Insert(SPINEL_PROP_MAC_SRC_MATCH_EXTENDED_ADDRESSES, SPINEL_DATATYPE_EUI64_S, extAddress.m8));
|
||||
}
|
||||
|
||||
exit:
|
||||
if (num != 0)
|
||||
{
|
||||
IgnoreReturnValue(mRadioSpinel.Set(SPINEL_PROP_MAC_SRC_MATCH_EXTENDED_ADDRESSES, nullptr));
|
||||
IgnoreReturnValue(
|
||||
mRadioSpinel.Set(SPINEL_PROP_MAC_SRC_MATCH_ENABLED, SPINEL_DATATYPE_BOOL_S, false /* aEnable */));
|
||||
}
|
||||
|
||||
OutputFormat("ExtendedSrcMatchTableSize", num);
|
||||
}
|
||||
|
||||
void RcpCapsDiag::OutputFormat(const char *aName, const char *aValue)
|
||||
{
|
||||
static constexpr uint8_t kMaxNameLength = 56;
|
||||
@@ -628,6 +692,15 @@ void RcpCapsDiag::OutputFormat(const char *aName, const char *aValue)
|
||||
Output("%.*s %s %s\r\n", kMaxNameLength, aName, &kPadding[paddingOffset], aValue);
|
||||
}
|
||||
|
||||
void RcpCapsDiag::OutputFormat(const char *aName, uint32_t aValue)
|
||||
{
|
||||
static constexpr uint16_t kValueLength = 11;
|
||||
char value[kValueLength];
|
||||
|
||||
snprintf(value, sizeof(value), "%u", aValue);
|
||||
OutputFormat(aName, value);
|
||||
}
|
||||
|
||||
void RcpCapsDiag::OutputResult(const SpinelEntry &aEntry, otError error)
|
||||
{
|
||||
static constexpr uint8_t kSpaceLength = 1;
|
||||
|
||||
@@ -108,8 +108,11 @@ private:
|
||||
RcpCapsDiag::SpinelCommandHandler mHandler;
|
||||
};
|
||||
|
||||
static constexpr uint16_t kMaxNumChildren = 512;
|
||||
|
||||
void ProcessSpinel(void);
|
||||
void ProcessCapabilityFlags(void);
|
||||
void ProcessSrcMatchTable(void);
|
||||
void TestSpinelCommands(Category aCategory);
|
||||
void TestRadioCapbilityFlags(void);
|
||||
void OutputRadioCapFlags(Category aCategory, uint32_t aRadioCaps, const uint32_t *aFlags, uint16_t aNumbFlags);
|
||||
@@ -120,7 +123,10 @@ private:
|
||||
const uint32_t *aFlags,
|
||||
uint16_t aNumbFlags);
|
||||
bool IsSpinelCapabilitySupported(const uint8_t *aCapsData, spinel_size_t aCapsLength, uint32_t aCapability);
|
||||
void OutputExtendedSrcMatchTableSize(void);
|
||||
void OutputShortSrcMatchTableSize(void);
|
||||
void OutputFormat(const char *aName, const char *aValue);
|
||||
void OutputFormat(const char *aName, uint32_t aValue);
|
||||
void OutputResult(const SpinelEntry &aEntry, otError error);
|
||||
void Output(const char *aFormat, ...);
|
||||
|
||||
|
||||
Reference in New Issue
Block a user