Skip to content

Commit

Permalink
net: openthread: add wake-up coordinator support
Browse files Browse the repository at this point in the history
Add Kconfig option `OPENTHREAD_WAKEUP_COORDINATOR` to enable
the Wake-up Coordinator role. Implement API to set Coordinated
Sampled Transmitting sample time and period for a driver that supports
`IEE802154_OPENTHREAD_HW_CST` capability.

The feature is be enabled on with ieee802154_nrf5 driver with option
by setting default value of CONFIG_IEEE802154_NRF5_CST_ENDPOINT.

Signed-off-by: Damian Krolik <[email protected]>
Signed-off-by: Andrzej Kuroś <[email protected]>
  • Loading branch information
ankuns committed Nov 12, 2024
1 parent 9fc3641 commit be05516
Show file tree
Hide file tree
Showing 4 changed files with 65 additions and 0 deletions.
1 change: 1 addition & 0 deletions drivers/ieee802154/Kconfig.nrf5
Original file line number Diff line number Diff line change
Expand Up @@ -96,6 +96,7 @@ config IEEE802154_NRF5_MULTIPLE_CCA

config IEEE802154_NRF5_CST_ENDPOINT
bool "Support for OpenThread CST Endpoint extension in the ieee802154_nrf5."
default y if OPENTHREAD_WAKEUP_COORDINATOR
help
Enable support for OpenThread CST (Coordinated Sampled Transmitter) Endpoint
with CST IE injection as an extension to ieee802154_nrf5 driver.
Expand Down
1 change: 1 addition & 0 deletions modules/openthread/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -128,6 +128,7 @@ kconfig_to_ot_option(CONFIG_OPENTHREAD_TX_QUEUE_STATISTICS OT_TX_QUEUE_STATS "En
kconfig_to_ot_option(CONFIG_OPENTHREAD_UDP_FORWARD OT_UDP_FORWARD "Enable UDP forward feature")
kconfig_to_ot_option(CONFIG_OPENTHREAD_UPTIME OT_UPTIME "Enable support for tracking OpenThread instance's uptime")
kconfig_to_ot_option(CONFIG_OPENTHREAD_VERHOEFF_CHECKSUM OT_VERHOEFF_CHECKSUM "Verhoeff checksum")
kconfig_to_ot_option(CONFIG_OPENTHREAD_WAKEUP_COORDINATOR OT_WAKEUP_COORDINATOR "Enable Wake-up Coordinator role")

if(CONFIG_OPENTHREAD_COPROCESSOR_VENDOR_HOOK_SOURCE)
set(OT_NCP_VENDOR_HOOK_SOURCE ${CONFIG_OPENTHREAD_COPROCESSOR_VENDOR_HOOK_SOURCE} CACHE STRING "NCP vendor hook source file name" FORCE)
Expand Down
4 changes: 4 additions & 0 deletions modules/openthread/Kconfig.features
Original file line number Diff line number Diff line change
Expand Up @@ -128,6 +128,10 @@ config OPENTHREAD_DEVICE_PROP_LEADER_WEIGHT
config OPENTHREAD_DATASET_UPDATER
bool "Dataset updater"

config OPENTHREAD_WAKEUP_COORDINATOR
bool "Wake-up Coordinator support"
select OPENTHREAD_CSL_RECEIVER

config OPENTHREAD_DHCP6_CLIENT
bool "DHCPv6 client support"

Expand Down
59 changes: 59 additions & 0 deletions modules/openthread/platform/radio.c
Original file line number Diff line number Diff line change
Expand Up @@ -1396,6 +1396,65 @@ void otPlatRadioUpdateCslSampleTime(otInstance *aInstance, uint32_t aCslSampleTi
}
#endif /* CONFIG_OPENTHREAD_CSL_RECEIVER */

#if defined(CONFIG_OPENTHREAD_WAKEUP_COORDINATOR)
otError otPlatRadioEnableCst(otInstance *aInstance, uint32_t aCstPeriod, otShortAddress aShortAddr,
const otExtAddress *aExtAddr)
{
struct ieee802154_config config;
int result;
uint8_t header_ie[OT_IE_HEADER_SIZE + OT_THREAD_IE_SIZE + OT_CST_IE_SIZE] = { 0 };
size_t index = 0;

ARG_UNUSED(aInstance);

/* Configure the CST period first to give drivers a chance to validate
* the IE for consistency if they wish to.
*/
config.cst_period = aCstPeriod;
result = radio_api->configure(radio_dev, IEEE802154_OPENTHREAD_CONFIG_CST_PERIOD, &config);
if (result) {
return OT_ERROR_FAILED;
}

/* Configure the CST IE. */
header_ie[index++] = OT_THREAD_IE_SIZE + OT_CST_IE_SIZE;
header_ie[index++] = 0;
sys_put_le24(THREAD_IE_VENDOR_OUI, &header_ie[index]);
index += 3;
header_ie[index++] = THREAD_IE_SUBTYPE_CST;
/* Leave CST Phase empty intentionally */
index += 2;
sys_put_le16(aCstPeriod, &header_ie[index]);
index += 2;

config.ack_ie.header_ie = aCstPeriod > 0 ? (struct ieee802154_header_ie *)header_ie : NULL;
config.ack_ie.short_addr = aShortAddr;
config.ack_ie.ext_addr = aExtAddr != NULL ? aExtAddr->m8 : NULL;
config.ack_ie.purge_ie = false;

result = radio_api->configure(radio_dev, IEEE802154_CONFIG_ENH_ACK_HEADER_IE, &config);

return result ? OT_ERROR_FAILED : OT_ERROR_NONE;
}

void otPlatRadioUpdateCstSampleTime(otInstance *aInstance, uint32_t aCstSampleTime)
{
int result;

ARG_UNUSED(aInstance);

struct ieee802154_config config = {
.expected_tx_time = convert_32bit_us_wrapped_to_64bit_ns(
aCstSampleTime - PHR_DURATION_US),
};

result = radio_api->configure(radio_dev, IEEE802154_OPENTHREAD_CONFIG_EXPECTED_TX_TIME,
&config);
__ASSERT_NO_MSG(result == 0);
(void)result;
}
#endif /* CONFIG_OPENTHREAD_WAKEUP_COORDINATOR */

uint8_t otPlatRadioGetCslAccuracy(otInstance *aInstance)
{
ARG_UNUSED(aInstance);
Expand Down

0 comments on commit be05516

Please sign in to comment.