mirror of
https://github.com/espressif/openthread.git
synced 2026-08-29 21:39:54 +00:00
Cleanup device role names. (#1820)
This commit is contained in:
@@ -364,7 +364,7 @@ typedef enum _OTLWF_NOTIF_TYPE
|
||||
OTLWF_CTL_CODE(139, METHOD_BUFFERED, FILE_READ_DATA | FILE_WRITE_DATA)
|
||||
// GUID - InterfaceGuid
|
||||
// otDeviceRole - aRole
|
||||
// otMleAttachFilter - aFilter (only for kDeviceRoleChild)
|
||||
// otMleAttachFilter - aFilter (only for OT_DEVICE_ROLE_CHILD)
|
||||
|
||||
#define IOCTL_OTLWF_OT_CHILD_INFO_BY_ID \
|
||||
OTLWF_CTL_CODE(140, METHOD_BUFFERED, FILE_READ_DATA)
|
||||
|
||||
@@ -2788,7 +2788,7 @@ otThreadBecomeDetached(
|
||||
)
|
||||
{
|
||||
if (aInstance == nullptr) return OT_ERROR_INVALID_ARGS;
|
||||
return DwordToThreadError(SetIOCTL(aInstance, IOCTL_OTLWF_OT_DEVICE_ROLE, (uint8_t)kDeviceRoleDetached));
|
||||
return DwordToThreadError(SetIOCTL(aInstance, IOCTL_OTLWF_OT_DEVICE_ROLE, (uint8_t)OT_DEVICE_ROLE_DETACHED));
|
||||
}
|
||||
|
||||
OTAPI
|
||||
@@ -2799,7 +2799,7 @@ otThreadBecomeChild(
|
||||
)
|
||||
{
|
||||
if (aInstance == nullptr) return OT_ERROR_INVALID_ARGS;
|
||||
return DwordToThreadError(SetIOCTL(aInstance, IOCTL_OTLWF_OT_DEVICE_ROLE, (uint8_t)kDeviceRoleChild));
|
||||
return DwordToThreadError(SetIOCTL(aInstance, IOCTL_OTLWF_OT_DEVICE_ROLE, (uint8_t)OT_DEVICE_ROLE_CHILD));
|
||||
}
|
||||
|
||||
OTAPI
|
||||
@@ -2810,7 +2810,7 @@ otThreadBecomeRouter(
|
||||
)
|
||||
{
|
||||
if (aInstance == nullptr) return OT_ERROR_INVALID_ARGS;
|
||||
return DwordToThreadError(SetIOCTL(aInstance, IOCTL_OTLWF_OT_DEVICE_ROLE, (uint8_t)kDeviceRoleRouter));
|
||||
return DwordToThreadError(SetIOCTL(aInstance, IOCTL_OTLWF_OT_DEVICE_ROLE, (uint8_t)OT_DEVICE_ROLE_ROUTER));
|
||||
}
|
||||
|
||||
OTAPI
|
||||
@@ -2821,7 +2821,7 @@ otThreadBecomeLeader(
|
||||
)
|
||||
{
|
||||
if (aInstance == nullptr) return OT_ERROR_INVALID_ARGS;
|
||||
return DwordToThreadError(SetIOCTL(aInstance, IOCTL_OTLWF_OT_DEVICE_ROLE, (uint8_t)kDeviceRoleLeader));
|
||||
return DwordToThreadError(SetIOCTL(aInstance, IOCTL_OTLWF_OT_DEVICE_ROLE, (uint8_t)OT_DEVICE_ROLE_LEADER));
|
||||
}
|
||||
|
||||
OTAPI
|
||||
@@ -2988,7 +2988,7 @@ otThreadGetDeviceRole(
|
||||
_In_ otInstance *aInstance
|
||||
)
|
||||
{
|
||||
uint8_t Result = kDeviceRoleOffline;
|
||||
uint8_t Result = OT_DEVICE_ROLE_DISABLED;
|
||||
if (aInstance) (void)QueryIOCTL(aInstance, IOCTL_OTLWF_OT_DEVICE_ROLE, &Result);
|
||||
return (otDeviceRole)Result;
|
||||
}
|
||||
|
||||
@@ -773,7 +773,7 @@ otLwfEventWorkerThread(
|
||||
pFilter->otInstanceSize -= sizeof(PMS_FILTER);
|
||||
|
||||
// Initialize the OpenThread library
|
||||
pFilter->otCachedRole = kDeviceRoleDisabled;
|
||||
pFilter->otCachedRole = OT_DEVICE_ROLE_DISABLED;
|
||||
pFilter->otCtx = otInstanceInit(pFilter->otInstanceBuffer + sizeof(PMS_FILTER), &pFilter->otInstanceSize);
|
||||
NT_ASSERT(pFilter->otCtx);
|
||||
if (pFilter->otCtx == NULL)
|
||||
|
||||
@@ -574,7 +574,7 @@ otLwfIoCtl_otThread(
|
||||
}
|
||||
else if (*OutBufferLength >= sizeof(BOOLEAN))
|
||||
{
|
||||
*(BOOLEAN*)OutBuffer = (otThreadGetDeviceRole(pFilter->otCtx) > kDeviceRoleDisabled) ? TRUE : FALSE;
|
||||
*(BOOLEAN*)OutBuffer = (otThreadGetDeviceRole(pFilter->otCtx) > OT_DEVICE_ROLE_DISABLED) ? TRUE : FALSE;
|
||||
*OutBufferLength = sizeof(BOOLEAN);
|
||||
status = STATUS_SUCCESS;
|
||||
}
|
||||
@@ -3759,25 +3759,25 @@ otLwfIoCtl_otDeviceRole(
|
||||
InBufferLength -= sizeof(uint8_t);
|
||||
InBuffer = InBuffer + sizeof(uint8_t);
|
||||
|
||||
if (role == kDeviceRoleLeader)
|
||||
if (role == OT_DEVICE_ROLE_LEADER)
|
||||
{
|
||||
status = ThreadErrorToNtstatus(
|
||||
otThreadBecomeLeader(pFilter->otCtx)
|
||||
);
|
||||
}
|
||||
else if (role == kDeviceRoleRouter)
|
||||
else if (role == OT_DEVICE_ROLE_ROUTER)
|
||||
{
|
||||
status = ThreadErrorToNtstatus(
|
||||
otThreadBecomeRouter(pFilter->otCtx)
|
||||
);
|
||||
}
|
||||
else if (role == kDeviceRoleChild)
|
||||
else if (role == OT_DEVICE_ROLE_CHILD)
|
||||
{
|
||||
status = ThreadErrorToNtstatus(
|
||||
otThreadBecomeChild(pFilter->otCtx)
|
||||
);
|
||||
}
|
||||
else if (role == kDeviceRoleDetached)
|
||||
else if (role == OT_DEVICE_ROLE_DETACHED)
|
||||
{
|
||||
status = ThreadErrorToNtstatus(
|
||||
otThreadBecomeDetached(pFilter->otCtx)
|
||||
@@ -3819,13 +3819,13 @@ otLwfTunIoCtl_otDeviceRole(
|
||||
|
||||
switch (role)
|
||||
{
|
||||
case kDeviceRoleChild:
|
||||
case OT_DEVICE_ROLE_CHILD:
|
||||
spinel_role = SPINEL_NET_ROLE_CHILD;
|
||||
break;
|
||||
case kDeviceRoleRouter:
|
||||
case OT_DEVICE_ROLE_ROUTER:
|
||||
spinel_role = SPINEL_NET_ROLE_ROUTER;
|
||||
break;
|
||||
case kDeviceRoleLeader:
|
||||
case OT_DEVICE_ROLE_LEADER:
|
||||
spinel_role = SPINEL_NET_ROLE_LEADER;
|
||||
break;
|
||||
}
|
||||
@@ -3878,16 +3878,16 @@ otLwfTunIoCtl_otDeviceRole_Handler(
|
||||
{
|
||||
default:
|
||||
case SPINEL_NET_ROLE_DETACHED:
|
||||
*(uint8_t*)OutBuffer = kDeviceRoleDetached;
|
||||
*(uint8_t*)OutBuffer = OT_DEVICE_ROLE_DETACHED;
|
||||
break;
|
||||
case SPINEL_NET_ROLE_CHILD:
|
||||
*(uint8_t*)OutBuffer = kDeviceRoleChild;
|
||||
*(uint8_t*)OutBuffer = OT_DEVICE_ROLE_CHILD;
|
||||
break;
|
||||
case SPINEL_NET_ROLE_ROUTER:
|
||||
*(uint8_t*)OutBuffer = kDeviceRoleRouter;
|
||||
*(uint8_t*)OutBuffer = OT_DEVICE_ROLE_ROUTER;
|
||||
break;
|
||||
case SPINEL_NET_ROLE_LEADER:
|
||||
*(uint8_t*)OutBuffer = kDeviceRoleLeader;
|
||||
*(uint8_t*)OutBuffer = OT_DEVICE_ROLE_LEADER;
|
||||
break;
|
||||
}
|
||||
|
||||
|
||||
@@ -74,7 +74,7 @@ otPlatReset(
|
||||
pFilter->otPendingMacOffloadEnabled = FALSE;
|
||||
|
||||
// Reinitialize the OpenThread library
|
||||
pFilter->otCachedRole = kDeviceRoleDisabled;
|
||||
pFilter->otCachedRole = OT_DEVICE_ROLE_DISABLED;
|
||||
pFilter->otCtx = otInstanceInit(pFilter->otInstanceBuffer + sizeof(PMS_FILTER), &pFilter->otInstanceSize);
|
||||
ASSERT(pFilter->otCtx);
|
||||
|
||||
|
||||
@@ -44,7 +44,7 @@ __inline PMS_FILTER otCtxToFilter(_In_ otInstance* otCtx)
|
||||
// Helper function to indicate if a role means it is attached or not
|
||||
_inline BOOLEAN IsAttached(_In_ otDeviceRole role)
|
||||
{
|
||||
return role > kDeviceRoleDetached;
|
||||
return role > OT_DEVICE_ROLE_DETACHED;
|
||||
}
|
||||
|
||||
//
|
||||
|
||||
@@ -332,13 +332,12 @@ const char* otDeviceRoleToString(otDeviceRole role)
|
||||
{
|
||||
switch (role)
|
||||
{
|
||||
case kDeviceRoleOffline: return "offline";
|
||||
case kDeviceRoleDisabled: return "disabled";
|
||||
case kDeviceRoleDetached: return "detached";
|
||||
case kDeviceRoleChild: return "child";
|
||||
case kDeviceRoleRouter: return "router";
|
||||
case kDeviceRoleLeader: return "leader";
|
||||
default: return "invalid";
|
||||
case OT_DEVICE_ROLE_DISABLED: return "disabled";
|
||||
case OT_DEVICE_ROLE_DETACHED: return "detached";
|
||||
case OT_DEVICE_ROLE_CHILD: return "child";
|
||||
case OT_DEVICE_ROLE_ROUTER: return "router";
|
||||
case OT_DEVICE_ROLE_LEADER: return "leader";
|
||||
default: return "invalid";
|
||||
}
|
||||
}
|
||||
|
||||
@@ -392,7 +391,7 @@ PingHandlerRecvCallback(
|
||||
memcmp(RecvDest, &RealmLocalAllRoutersAddress, sizeof(IN6_ADDR)) == 0)
|
||||
{
|
||||
auto Role = otThreadGetDeviceRole(aPingHandler->mParentNode->mInstance);
|
||||
if (Role != kDeviceRoleLeader && Role != kDeviceRoleRouter)
|
||||
if (Role != OT_DEVICE_ROLE_LEADER && Role != OT_DEVICE_ROLE_ROUTER)
|
||||
shouldReply = false;
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user