Skip to content

Commit e35d46a

Browse files
committed
[thread-direct] add platform API for Thread Direct wake key registration
Introduces `otPlatRadioSetWakeKey()` and related constants. Thread Direct connections are ephemeral and wake keys do not rotate within a session, so no prev/curr/next window is needed. Wake frames share the standard MAC frame counter; therefore no separate wake frame counter platform API has been introduced. This PR is for design review, callers arrive in this or the next PR based on community input.
1 parent 4296c0b commit e35d46a

4 files changed

Lines changed: 57 additions & 1 deletion

File tree

examples/platforms/simulation/radio.c

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1161,6 +1161,15 @@ void otPlatRadioSetMacFrameCounter(otInstance *aInstance, uint32_t aMacFrameCoun
11611161
sRadioContext.mMacFrameCounter = aMacFrameCounter;
11621162
}
11631163

1164+
#if OPENTHREAD_CONFIG_THREAD_DIRECT_WAKE_INITIATOR_ENABLE || OPENTHREAD_CONFIG_THREAD_DIRECT_WAKE_LISTENER_ENABLE
1165+
void otPlatRadioSetWakeKey(otInstance *aInstance, uint8_t aKeyIndex, const otMacKeyMaterial *aWakeKey)
1166+
{
1167+
OT_UNUSED_VARIABLE(aInstance);
1168+
OT_UNUSED_VARIABLE(aKeyIndex);
1169+
OT_UNUSED_VARIABLE(aWakeKey);
1170+
}
1171+
#endif
1172+
11641173
otError otPlatRadioSetChannelMaxTransmitPower(otInstance *aInstance, uint8_t aChannel, int8_t aMaxPower)
11651174
{
11661175
OT_UNUSED_VARIABLE(aInstance);

include/openthread/instance.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -52,7 +52,7 @@ extern "C" {
5252
*
5353
* @note This number versions both OpenThread platform and user APIs.
5454
*/
55-
#define OPENTHREAD_API_VERSION (607)
55+
#define OPENTHREAD_API_VERSION (608)
5656

5757
/**
5858
* @addtogroup api-instance

include/openthread/platform/radio.h

Lines changed: 38 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -744,6 +744,44 @@ void otPlatRadioSetMacFrameCounter(otInstance *aInstance, uint32_t aMacFrameCoun
744744
*/
745745
void otPlatRadioSetMacFrameCounterIfLarger(otInstance *aInstance, uint32_t aMacFrameCounter);
746746

747+
/**
748+
* IEEE 802.15.4 key index reserved for the default Thread Direct Wake Key (network-derived).
749+
*
750+
* This value (129) is outside the range used for standard Thread MAC keys (1-128). It is
751+
* carried in the key index field of TD Wake Frames that use the network-derived wake key.
752+
*/
753+
#define OT_MAC_FRAME_WAKE_KEY_INDEX 129
754+
755+
/**
756+
* Lowest key index valid for a Thread Direct guest Wake Key.
757+
*/
758+
#define OT_MAC_FRAME_GUEST_WAKE_KEY_INDEX_MIN 130
759+
760+
/**
761+
* Highest key index valid for a Thread Direct guest Wake Key.
762+
*/
763+
#define OT_MAC_FRAME_GUEST_WAKE_KEY_INDEX_MAX 192
764+
765+
/**
766+
* Registers or removes a Thread Direct Wake Key at the given key index.
767+
*
768+
* Is used when radio provides `OT_RADIO_CAPS_TRANSMIT_SEC` capability. When the platform
769+
* processes a TX frame whose key index matches `aKeyIndex`, it uses `aWakeKey` to perform
770+
* AES-CCM encryption rather than the standard Thread MAC key set registered via
771+
* `otPlatRadioSetMacKey`.
772+
*
773+
* `aKeyIndex` must be `OT_MAC_FRAME_WAKE_KEY_INDEX` (129) for the default network-derived
774+
* wake key, or in [`OT_MAC_FRAME_GUEST_WAKE_KEY_INDEX_MIN`,
775+
* `OT_MAC_FRAME_GUEST_WAKE_KEY_INDEX_MAX`] (130-192) for a guest wake key.
776+
*
777+
* Passing `aWakeKey` as NULL removes any previously registered key at `aKeyIndex`.
778+
*
779+
* @param[in] aInstance A pointer to an OpenThread instance.
780+
* @param[in] aKeyIndex Key index (129 for default, 130-192 for guest keys).
781+
* @param[in] aWakeKey Key material to register, or NULL to remove.
782+
*/
783+
void otPlatRadioSetWakeKey(otInstance *aInstance, uint8_t aKeyIndex, const otMacKeyMaterial *aWakeKey);
784+
747785
/**
748786
* Get the current time in microseconds referenced to a continuous monotonic
749787
* local radio clock (64 bits width).

src/core/radio/radio_platform.cpp

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -386,3 +386,12 @@ extern "C" OT_TOOL_WEAK void otPlatRadioSetRxOnWhenIdle(otInstance *aInstance, b
386386
}
387387

388388
OT_TOOL_WEAK otError otPlatRadioSetChannelTargetPower(otInstance *, uint8_t, int16_t) { return kErrorNotImplemented; }
389+
390+
extern "C" OT_TOOL_WEAK void otPlatRadioSetWakeKey(otInstance *aInstance,
391+
uint8_t aKeyIndex,
392+
const otMacKeyMaterial *aWakeKey)
393+
{
394+
OT_UNUSED_VARIABLE(aInstance);
395+
OT_UNUSED_VARIABLE(aKeyIndex);
396+
OT_UNUSED_VARIABLE(aWakeKey);
397+
}

0 commit comments

Comments
 (0)