mirror of
https://github.com/espressif/openthread.git
synced 2026-09-17 22:50:07 +00:00
cli: Add parent priority set cli (#1923)
This commit is contained in:
@@ -694,8 +694,13 @@ typedef struct otCommissionConfig
|
||||
// GUID - InterfaceGuid
|
||||
// otPSKc - aPSKc
|
||||
|
||||
#define IOCTL_OTLWF_OT_PARENT_PRIORITY \
|
||||
OTLWF_CTL_CODE(196, METHOD_BUFFERED, FILE_READ_DATA | FILE_WRITE_DATA)
|
||||
// GUID - InterfaceGuid
|
||||
// int8_t - aParentPriority
|
||||
|
||||
// OpenThread function IOCTL codes
|
||||
#define MIN_OTLWF_IOCTL_FUNC_CODE 100
|
||||
#define MAX_OTLWF_IOCTL_FUNC_CODE 195
|
||||
#define MAX_OTLWF_IOCTL_FUNC_CODE 196
|
||||
|
||||
#endif //__OTLWFIOCTL_H__
|
||||
|
||||
@@ -3843,3 +3843,27 @@ otJoinerStop(
|
||||
if (aInstance == nullptr) return OT_ERROR_INVALID_ARGS;
|
||||
return DwordToThreadError(SetIOCTL(aInstance, IOCTL_OTLWF_OT_JOINER_STOP));
|
||||
}
|
||||
|
||||
OTAPI
|
||||
int8_t
|
||||
OTCALL
|
||||
otThreadGetParentPriority(
|
||||
_In_ otInstance *aInstance
|
||||
)
|
||||
{
|
||||
int8_t Result = 0;
|
||||
if (aInstance) (void)QueryIOCTL(aInstance, IOCTL_OTLWF_OT_PARENT_PRIORITY, &Result);
|
||||
return Result;
|
||||
}
|
||||
|
||||
OTAPI
|
||||
otError
|
||||
OTCALL
|
||||
otThreadSetParentPriority(
|
||||
_In_ otInstance *aInstance,
|
||||
int8_t aParentPriority
|
||||
)
|
||||
{
|
||||
if (aInstance == nullptr) return OT_ERROR_INVALID_ARGS;
|
||||
return DwordToThreadError(SetIOCTL(aInstance, IOCTL_OTLWF_OT_PARENT_PRIORITY, aParentPriority));
|
||||
}
|
||||
|
||||
@@ -141,6 +141,7 @@ OTLWF_IOCTL_HANDLER IoCtls[] =
|
||||
{ "IOCTL_OTLWF_OT_THREAD_AUTO_START", REF_IOCTL_FUNC(otThreadAutoStart) },
|
||||
{ "IOCTL_OTLWF_OT_PREFERRED_ROUTER_ID", REF_IOCTL_FUNC(otThreadPreferredRouterId) },
|
||||
{ "IOCTL_OTLWF_OT_PSKC", REF_IOCTL_FUNC_WITH_TUN(otPSKc) },
|
||||
{ "IOCTL_OTLWF_OT_PARENT_PRIORITY", REF_IOCTL_FUNC(otParentPriority) },
|
||||
};
|
||||
|
||||
static_assert(ARRAYSIZE(IoCtls) == (MAX_OTLWF_IOCTL_FUNC_CODE - MIN_OTLWF_IOCTL_FUNC_CODE) + 1,
|
||||
@@ -6225,3 +6226,38 @@ otLwfIoCtl_otThreadPreferredRouterId(
|
||||
|
||||
return status;
|
||||
}
|
||||
|
||||
_IRQL_requires_max_(PASSIVE_LEVEL)
|
||||
NTSTATUS
|
||||
otLwfIoCtl_otParentPriority(
|
||||
_In_ PMS_FILTER pFilter,
|
||||
_In_reads_bytes_(InBufferLength)
|
||||
PUCHAR InBuffer,
|
||||
_In_ ULONG InBufferLength,
|
||||
_Out_writes_bytes_(*OutBufferLength)
|
||||
PVOID OutBuffer,
|
||||
_Inout_ PULONG OutBufferLength
|
||||
)
|
||||
{
|
||||
NTSTATUS status = STATUS_INVALID_PARAMETER;
|
||||
|
||||
if (InBufferLength >= sizeof(int8_t))
|
||||
{
|
||||
otThreadSetParentPriority(pFilter->otCtx, *(int8_t*)InBuffer);
|
||||
status = STATUS_SUCCESS;
|
||||
*OutBufferLength = 0;
|
||||
}
|
||||
else if (*OutBufferLength >= sizeof(int8_t))
|
||||
{
|
||||
*(uint16_t*)OutBuffer = otThreadGetParentPriority(pFilter->otCtx);
|
||||
status = STATUS_SUCCESS;
|
||||
*OutBufferLength = sizeof(int8_t);
|
||||
}
|
||||
else
|
||||
{
|
||||
*OutBufferLength = 0;
|
||||
}
|
||||
|
||||
return status;
|
||||
}
|
||||
|
||||
|
||||
@@ -227,5 +227,6 @@ DECL_IOCTL_FUNC(otFactoryReset);
|
||||
DECL_IOCTL_FUNC(otThreadAutoStart);
|
||||
DECL_IOCTL_FUNC(otThreadPreferredRouterId);
|
||||
DECL_IOCTL_FUNC_WITH_TUN2(otPSKc);
|
||||
DECL_IOCTL_FUNC(otParentPriority);
|
||||
|
||||
#endif // _IOCONTROL_H
|
||||
|
||||
Reference in New Issue
Block a user