4343#include " mac/mac_frame.hpp"
4444#include " mac/mac_types.hpp"
4545#include " mac/sub_mac.hpp"
46+
47+ #if OPENTHREAD_CONFIG_THREAD_DIRECT_WAKE_INITIATOR_ENABLE
4648#include " mac/wakeup_tx_scheduler.hpp"
4749#include " meshcop/dataset_manager.hpp"
50+ #endif
4851
4952#if OPENTHREAD_CONFIG_THREAD_DIRECT_WAKE_INITIATOR_ENABLE || OPENTHREAD_CONFIG_THREAD_DIRECT_WAKE_LISTENER_ENABLE
5053
@@ -55,14 +58,15 @@ void otThreadDirectSetEventCallback(otInstance *aInstance, otThreadDirectEventCa
5558 AsCoreType (aInstance).Get <Mac::Mac>().SetDirectEventCallback (aCallback, aContext);
5659}
5760
61+ #if OPENTHREAD_CONFIG_THREAD_DIRECT_WAKE_INITIATOR_ENABLE
62+
5863otError otThreadDirectWakeup (otInstance *aInstance,
5964 const otExtAddress *aExtAddress,
6065 otThreadDirectWakeType aWakeType,
6166 uint16_t aIntervalUs,
6267 uint16_t aDurationMs,
6368 uint8_t aKeyIndex)
6469{
65- #if OPENTHREAD_CONFIG_THREAD_DIRECT_WAKE_INITIATOR_ENABLE
6670 otError error = OT_ERROR_NONE ;
6771
6872 VerifyOrExit (aExtAddress != nullptr , error = OT_ERROR_INVALID_ARGS );
@@ -98,18 +102,15 @@ otError otThreadDirectWakeup(otInstance *aInstance,
98102
99103exit:
100104 return error;
101- #else
102- OT_UNUSED_VARIABLE (aInstance);
103- OT_UNUSED_VARIABLE (aExtAddress);
104- OT_UNUSED_VARIABLE (aWakeType);
105- OT_UNUSED_VARIABLE (aIntervalUs);
106- OT_UNUSED_VARIABLE (aDurationMs);
107- OT_UNUSED_VARIABLE (aKeyIndex);
105+ }
108106
109- return OT_ERROR_NOT_IMPLEMENTED ;
110- #endif
107+ bool otThreadDirectIsWakeBurstActive (otInstance *aInstance)
108+ {
109+ return AsCoreType (aInstance).Get <WakeupTxScheduler>().IsRunning ();
111110}
112111
112+ #endif // OPENTHREAD_CONFIG_THREAD_DIRECT_WAKE_INITIATOR_ENABLE
113+
113114otError otThreadDirectUnlink (otInstance *aInstance, const otExtAddress *aExtAddress)
114115{
115116 OT_UNUSED_VARIABLE (aInstance);
@@ -118,37 +119,19 @@ otError otThreadDirectUnlink(otInstance *aInstance, const otExtAddress *aExtAddr
118119 return OT_ERROR_NOT_IMPLEMENTED ;
119120}
120121
122+ #if OPENTHREAD_CONFIG_THREAD_DIRECT_WAKE_LISTENER_ENABLE
123+
121124otError otThreadDirectWakeListenerEnable (otInstance *aInstance, bool aEnable)
122125{
123- #if OPENTHREAD_CONFIG_THREAD_DIRECT_WAKE_LISTENER_ENABLE
124126 return AsCoreType (aInstance).Get <Mac::Mac>().SetWakeupListenEnabled (aEnable);
125- #else
126- OT_UNUSED_VARIABLE (aInstance);
127- OT_UNUSED_VARIABLE (aEnable);
128-
129- return OT_ERROR_NOT_IMPLEMENTED ;
130- #endif
131127}
132128
133129bool otThreadDirectIsWakeListenerEnabled (otInstance *aInstance)
134130{
135- #if OPENTHREAD_CONFIG_THREAD_DIRECT_WAKE_LISTENER_ENABLE
136131 return AsCoreType (aInstance).Get <Mac::Mac>().IsWakeupListenEnabled ();
137- #else
138- OT_UNUSED_VARIABLE (aInstance);
139- return false ;
140- #endif
141132}
142133
143- bool otThreadDirectIsWakeBurstActive (otInstance *aInstance)
144- {
145- #if OPENTHREAD_CONFIG_THREAD_DIRECT_WAKE_INITIATOR_ENABLE
146- return AsCoreType (aInstance).Get <WakeupTxScheduler>().IsRunning ();
147- #else
148- OT_UNUSED_VARIABLE (aInstance);
149- return false ;
150- #endif
151- }
134+ #endif // OPENTHREAD_CONFIG_THREAD_DIRECT_WAKE_LISTENER_ENABLE
152135
153136otError otThreadDirectSetSlwSchedule (otInstance *aInstance, uint16_t aSlwPeriodSlots)
154137{
@@ -165,6 +148,9 @@ otError otThreadDirectSetRamOverride(otInstance *aInstance, const otThreadDirect
165148 // a stored state since it has no meaning outside of a per-frame codec context.
166149 VerifyOrExit (aParams->mDuration >= 1 && aParams->mDuration <= Mac::ScaParams::kRamDurationMax ,
167150 error = OT_ERROR_INVALID_ARGS );
151+ VerifyOrExit (aParams->mOffsetUs >= Mac::ScaParams::kRamOffsetUsMin &&
152+ aParams->mOffsetUs <= Mac::ScaParams::kRamOffsetUsMax ,
153+ error = OT_ERROR_INVALID_ARGS );
168154
169155 params.mRamDuration = aParams->mDuration ;
170156 params.mRamOffsetUs = aParams->mOffsetUs ;
0 commit comments