mirror of
https://github.com/espressif/openthread.git
synced 2026-08-23 18:59:51 +00:00
[mac filter] add rssfilter support and integrate whitelist/blacklist to AddressFilter (#1967)
* [mac filter] add rssfilter support and integrate whitelist/blacklist - provide RssIn filter function to fix the received signal strength for test purpose. - provide Address filter function which integrates whitelist and blacklist, save (~300B) RAM. - update cli and spinel-cli to reflect new otLinkFilterX() APIs. - keep whitelist/blacklist spinel properties the same as before while implemented with new otLinkFilterX() APIs. - THCI: add setOutBoundLinkQuality() API for DEV-1530 - THCI: update Allow/Block relative APIs - update some test scripts due to new OT_ERROR_ALEADY when adding duplicate address to whitelist * update for comments * add MAC_FIXED_RSS spinel property * rebase and apply new OutboundFrameBegin(aHeader) * update OpenThread.py
This commit is contained in:
@@ -1069,7 +1069,7 @@ OTNODEAPI int32_t OTCALL otNodeClearWhitelist(otNode* aNode)
|
||||
otLogFuncEntryMsg("[%d]", aNode->mId);
|
||||
printf("%d: whitelist clear\r\n", aNode->mId);
|
||||
|
||||
otLinkClearWhitelist(aNode->mInstance);
|
||||
otLinkFilterClearAddresses(aNode->mInstance);
|
||||
otLogFuncExit();
|
||||
return 0;
|
||||
}
|
||||
@@ -1079,9 +1079,9 @@ OTNODEAPI int32_t OTCALL otNodeEnableWhitelist(otNode* aNode)
|
||||
otLogFuncEntryMsg("[%d]", aNode->mId);
|
||||
printf("%d: whitelist enable\r\n", aNode->mId);
|
||||
|
||||
otLinkSetWhitelistEnabled(aNode->mInstance, true);
|
||||
otError error = otLinkFilterSetAddressMode(aNode->mInstance, OT_MAC_FILTER_ADDRESS_MODE_WHITELIST);
|
||||
otLogFuncExit();
|
||||
return 0;
|
||||
return error;
|
||||
}
|
||||
|
||||
OTNODEAPI int32_t OTCALL otNodeDisableWhitelist(otNode* aNode)
|
||||
@@ -1089,31 +1089,36 @@ OTNODEAPI int32_t OTCALL otNodeDisableWhitelist(otNode* aNode)
|
||||
otLogFuncEntryMsg("[%d]", aNode->mId);
|
||||
printf("%d: whitelist disable\r\n", aNode->mId);
|
||||
|
||||
otLinkSetWhitelistEnabled(aNode->mInstance, false);
|
||||
otError error = otLinkFilterSetAddressMode(aNode->mInstance, OT_MAC_FILTER_ADDRESS_MODE_DISABLED);
|
||||
otLogFuncExit();
|
||||
return 0;
|
||||
return error;
|
||||
}
|
||||
|
||||
OTNODEAPI int32_t OTCALL otNodeAddWhitelist(otNode* aNode, const char *aExtAddr, int8_t aRssi)
|
||||
OTNODEAPI int32_t OTCALL otNodeAddWhitelist(otNode* aNode,
|
||||
const char *aExtAddr, int8_t aRssi = OT_MAC_FILTER_FIXED_RSS_DISABLED)
|
||||
{
|
||||
otLogFuncEntryMsg("[%d]", aNode->mId);
|
||||
if (aRssi == 0)
|
||||
printf("%d: whitelist add %s\r\n", aNode->mId, aExtAddr);
|
||||
else printf("%d: whitelist add %s %d\r\n", aNode->mId, aExtAddr, aRssi);
|
||||
otError error = OT_ERROR_NONE;
|
||||
|
||||
uint8_t extAddr[8];
|
||||
if (Hex2Bin(aExtAddr, extAddr, sizeof(extAddr)) != sizeof(extAddr))
|
||||
otExtAddress extAddress;
|
||||
if (Hex2Bin(aExtAddr, extAddress.m8, OT_EXT_ADDRESS_SIZE) != OT_EXT_ADDRESS_SIZE)
|
||||
return OT_ERROR_PARSE;
|
||||
|
||||
otError error;
|
||||
if (aRssi == 0)
|
||||
printf("%d: whitelist add %s", aNode->mId, aExtAddr);
|
||||
|
||||
error = otLinkFilterAddAddress(aNode->mInstance, &extAddress);
|
||||
|
||||
if (error == OT_ERROR_NONE || error == OT_ERROR_ALREADY)
|
||||
{
|
||||
error = otLinkAddWhitelist(aNode->mInstance, extAddr);
|
||||
}
|
||||
else
|
||||
{
|
||||
error = otLinkAddWhitelistRssi(aNode->mInstance, extAddr, aRssi);
|
||||
if (aRssi != OT_MAC_FILTER_FIXED_RSS_DISABLED)
|
||||
{
|
||||
error = otLinkFilterAddRssIn(aNode->mInstance, &extAddress, aRssi);
|
||||
printf(" %d", aRssi);
|
||||
}
|
||||
}
|
||||
|
||||
printf("\r\n");
|
||||
|
||||
otLogFuncExit();
|
||||
return error;
|
||||
}
|
||||
@@ -1123,13 +1128,13 @@ OTNODEAPI int32_t OTCALL otNodeRemoveWhitelist(otNode* aNode, const char *aExtAd
|
||||
otLogFuncEntryMsg("[%d]", aNode->mId);
|
||||
printf("%d: whitelist remove %s\r\n", aNode->mId, aExtAddr);
|
||||
|
||||
uint8_t extAddr[8];
|
||||
if (Hex2Bin(aExtAddr, extAddr, sizeof(extAddr)) != sizeof(extAddr))
|
||||
return OT_ERROR_INVALID_ARGS;
|
||||
otExtAddress extAddress;
|
||||
if (Hex2Bin(aExtAddr, extAddress.m8, OT_EXT_ADDRESS_SIZE) != OT_EXT_ADDRESS_SIZE)
|
||||
return OT_ERROR_PARSE;
|
||||
|
||||
otLinkRemoveWhitelist(aNode->mInstance, extAddr);
|
||||
otError error = otLinkFilterRemoveAddress(aNode->mInstance, &extAddress);
|
||||
otLogFuncExit();
|
||||
return 0;
|
||||
return error;
|
||||
}
|
||||
|
||||
OTNODEAPI uint16_t OTCALL otNodeGetAddr16(otNode* aNode)
|
||||
|
||||
Reference in New Issue
Block a user