@@ -91,8 +91,10 @@ typedef struct otThreadDirectPeerInfo
9191 */
9292typedef enum otThreadDirectEvent
9393{
94- OT_THREAD_DIRECT_EVENT_LINK_FAILED = 0 , ///< Wake attempt failed (timeout or authentication failure).
95- OT_THREAD_DIRECT_EVENT_WAKE_RECEIVED = 1 , ///< WL received a TD Wake Command from a WI peer.
94+ OT_THREAD_DIRECT_EVENT_LINKED = 0 , ///< Thread Direct link successfully established.
95+ OT_THREAD_DIRECT_EVENT_LINK_FAILED = 1 , ///< Wake attempt failed (timeout or authentication failure).
96+ OT_THREAD_DIRECT_EVENT_UNLINKED = 2 , ///< Thread Direct link torn down (supervision timeout or teardown frame).
97+ OT_THREAD_DIRECT_EVENT_WAKE_RECEIVED = 3 , ///< WL received a TD Wake Command from a WI peer.
9698} otThreadDirectEvent ;
9799
98100/**
@@ -141,7 +143,8 @@ typedef enum
141143 * Transmits Wake Frames of type @p aWakeType at @p aIntervalUs for @p aDurationMs.
142144 * When @p aWakeType is OT_THREAD_DIRECT_WAKE_TYPE_LINK, a connection window is opened
143145 * after the burst; the registered event callback (see otThreadDirectSetEventCallback())
144- * fires OT_THREAD_DIRECT_EVENT_LINK_FAILED if the window expires without a response.
146+ * fires OT_THREAD_DIRECT_EVENT_LINKED on receipt of a TD Link Command, or
147+ * OT_THREAD_DIRECT_EVENT_LINK_FAILED if the window expires without a response.
145148 *
146149 * Pass @p aIntervalUs = 0 to use OPENTHREAD_CONFIG_THREAD_DIRECT_WAKE_INTERVAL_US.
147150 * Pass @p aDurationMs = 0 to use OPENTHREAD_CONFIG_THREAD_DIRECT_WAKE_DURATION_MS.
@@ -228,6 +231,127 @@ bool otThreadDirectIsWakeListenerEnabled(otInstance *aInstance);
228231 */
229232bool otThreadDirectIsWakeBurstActive (otInstance * aInstance );
230233
234+ /**
235+ * Configures the Scheduled Listen Window (SLW) period this device advertises to
236+ * its peer in the SCA LTV. Both WI and WL may call this function.
237+ *
238+ * Requires `OPENTHREAD_CONFIG_THREAD_DIRECT_WAKE_INITIATOR_ENABLE` or
239+ * `OPENTHREAD_CONFIG_THREAD_DIRECT_WAKE_LISTENER_ENABLE`.
240+ *
241+ * Phase is a dynamic, stack-computed value (time until the next SLW window at
242+ * frame-build time) and is not configurable by the application.
243+ *
244+ * Passing @p aSlwPeriodSlots = 0 clears the schedule and causes a teardown SCA LTV
245+ * (empty payload) to be sent in the next frame to each peer.
246+ *
247+ * @param[in] aInstance The OpenThread instance.
248+ * @param[in] aSlwPeriodSlots SLW period in 160 us slots (0 = clear schedule).
249+ *
250+ * @retval OT_ERROR_NONE Schedule updated.
251+ * @retval OT_ERROR_INVALID_ARGS @p aSlwPeriodSlots is non-zero and below the minimum.
252+ */
253+ otError otThreadDirectSetSlwSchedule (otInstance * aInstance , uint16_t aSlwPeriodSlots );
254+
255+ /**
256+ * Represents the Radio Availability Mask (RAM) parameters this device will
257+ * advertise in outgoing SCA LTVs.
258+ *
259+ * RAM Duration semantics (valid stored values):
260+ * 1 - device has no CoEx constraints (no bitmap transmitted); this is the default.
261+ * 2-31 - CoEx bitmap present; (mDuration + 1) bits are valid in mBits.
262+ *
263+ * Note: mDuration = 0 ("no change to prior RAM") is a wire-encoding sentinel and
264+ * is NOT a valid value for otThreadDirectSetRamOverride().
265+ */
266+ typedef struct otThreadDirectRamParams
267+ {
268+ int16_t mOffsetUs ; ///< RAM Offset in us, signed [-1024, 1023].
269+ uint8_t mDuration ; ///< RAM Duration code (1 = no constraints, 2-31 = CoEx bitmap).
270+ uint8_t mBits [4 ]; ///< RAM bitmap bytes (used when mDuration >= 2).
271+ } otThreadDirectRamParams ;
272+
273+ /**
274+ * Represents the full local SCA state as advertised in outgoing SCA LTVs.
275+ */
276+ typedef struct otThreadDirectLocalSca
277+ {
278+ uint16_t mSlwPeriodSlots ; ///< SLW period in 160 us slots (0 = not configured).
279+ otThreadDirectRamParams mRam ; ///< RAM parameters.
280+ } otThreadDirectLocalSca ;
281+
282+ /**
283+ * Overrides the RAM parameters this device advertises in outgoing SCA LTVs.
284+ *
285+ * Intended for testing and for platforms where the CoEx schedule is managed at
286+ * the application layer. When `OPENTHREAD_CONFIG_THREAD_DIRECT_COEX_ENABLE`
287+ * is enabled, the stack obtains RAM parameters from the platform radio driver
288+ * at SCA LTV build time; this override does not apply.
289+ *
290+ * Pass @p aParams->mDuration = 1 to explicitly clear CoEx constraints.
291+ * @p aParams->mDuration = 0 is invalid (wire-encoding sentinel; not storable).
292+ *
293+ * @param[in] aInstance The OpenThread instance.
294+ * @param[in] aParams RAM parameters to store.
295+ *
296+ * @retval OT_ERROR_NONE Parameters stored.
297+ * @retval OT_ERROR_INVALID_ARGS @p aParams is NULL, @p aParams->mDuration is 0,
298+ * @p aParams->mDuration is outside [1, 31], or
299+ * @p aParams->mOffsetUs is outside [-1024, 1023].
300+ */
301+ otError otThreadDirectSetRamOverride (otInstance * aInstance , const otThreadDirectRamParams * aParams );
302+
303+ /**
304+ * Gets the local SCA state (SLW schedule and RAM parameters) this device advertises.
305+ *
306+ * @param[in] aInstance The OpenThread instance.
307+ * @param[out] aLocalSca Populated with the local SCA state.
308+ *
309+ * @retval OT_ERROR_NONE @p aLocalSca populated.
310+ */
311+ otError otThreadDirectGetLocalSca (otInstance * aInstance , otThreadDirectLocalSca * aLocalSca );
312+
313+ /**
314+ * Returns the SLW link inactivity timeout in seconds.
315+ *
316+ * The timeout is the number of seconds without receiving a unicast frame from
317+ * a WI peer before the stack tears down the TD link and stops the SLW schedule.
318+ * 0 means the timeout has not been explicitly set and the default from
319+ * OPENTHREAD_CONFIG_THREAD_DIRECT_SLW_TIMEOUT applies.
320+ *
321+ * @param[in] aInstance The OpenThread instance.
322+ *
323+ * @returns The current SLW timeout in seconds.
324+ */
325+ uint32_t otThreadDirectGetSlwTimeout (otInstance * aInstance );
326+
327+ /**
328+ * Sets the SLW link inactivity timeout in seconds.
329+ *
330+ * @param[in] aInstance The OpenThread instance.
331+ * @param[in] aTimeout Timeout in seconds. 0 restores the compile-time
332+ * default (OPENTHREAD_CONFIG_THREAD_DIRECT_SLW_TIMEOUT).
333+ *
334+ * @retval OT_ERROR_NONE Timeout updated.
335+ * @retval OT_ERROR_INVALID_ARGS @p aTimeout exceeds
336+ * OPENTHREAD_CONFIG_THREAD_DIRECT_SLW_MAX_TIMEOUT.
337+ */
338+ otError otThreadDirectSetSlwTimeout (otInstance * aInstance , uint32_t aTimeout );
339+
340+ /**
341+ * Gets the current SLW schedule and link state of an established Thread Direct peer.
342+ *
343+ * @param[in] aInstance The OpenThread instance.
344+ * @param[in] aExtAddress Extended address of the peer.
345+ * @param[out] aPeerInfo Output structure populated with peer state.
346+ *
347+ * @retval OT_ERROR_NONE @p aPeerInfo populated.
348+ * @retval OT_ERROR_NOT_FOUND No established link to @p aExtAddress.
349+ * @retval OT_ERROR_NOT_IMPLEMENTED Feature is not implemented.
350+ */
351+ otError otThreadDirectGetPeerInfo (otInstance * aInstance ,
352+ const otExtAddress * aExtAddress ,
353+ otThreadDirectPeerInfo * aPeerInfo );
354+
231355/**
232356 * Adds or replaces a guest Wake Key at the given key index.
233357 *
@@ -243,6 +367,7 @@ bool otThreadDirectIsWakeBurstActive(otInstance *aInstance);
243367 * @retval OT_ERROR_INVALID_ARGS @p aKeyIndex is outside [130, 192].
244368 * @retval OT_ERROR_NO_BUFS Guest key table is full.
245369 * @retval OT_ERROR_DISABLED_FEATURE OPENTHREAD_CONFIG_THREAD_DIRECT_GUEST_WAKE_KEY_ENABLE = 0.
370+ * @retval OT_ERROR_NOT_IMPLEMENTED Feature is not implemented.
246371 */
247372otError otThreadDirectSetGuestWakeKey (otInstance * aInstance , uint8_t aKeyIndex , const otThreadDirectWakeKey * aKey );
248373
0 commit comments