Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

net: openthread: implement otPlatRadioSetRxOnWhenIdle #64193

Merged
merged 2 commits into from
Nov 15, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
37 changes: 36 additions & 1 deletion include/zephyr/net/ieee802154_radio.h
Original file line number Diff line number Diff line change
Expand Up @@ -515,13 +515,16 @@ enum ieee802154_hw_caps {
/** TX security supported (key management, encryption and authentication) */
IEEE802154_HW_TX_SEC = BIT(11),

/** RxOnWhenIdle handling supported */
IEEE802154_RX_ON_WHEN_IDLE = BIT(12),

/* Note: Update also IEEE802154_HW_CAPS_BITS_COMMON_COUNT when changing
* the ieee802154_hw_caps type.
*/
};

/** @brief Number of bits used by ieee802154_hw_caps type. */
#define IEEE802154_HW_CAPS_BITS_COMMON_COUNT (12)
#define IEEE802154_HW_CAPS_BITS_COMMON_COUNT (13)

/** @brief This and higher values are specific to the protocol- or driver-specific extensions. */
#define IEEE802154_HW_CAPS_BITS_PRIV_START IEEE802154_HW_CAPS_BITS_COMMON_COUNT
Expand Down Expand Up @@ -1057,6 +1060,35 @@ enum ieee802154_config_type {
*/
IEEE802154_CONFIG_ENH_ACK_HEADER_IE,

/**
* Enable/disable RxOnWhenIdle MAC PIB attribute (Table 8-94).
*
* Since there is no clear guidance in IEEE 802.15.4 specification about the definition of
* an "idle period", this implementation expects that drivers use the RxOnWhenIdle attribute
* to determine next radio state (false --> off, true --> receive) in the following
* scenarios:
* - Finalization of a regular frame reception task, provided that:
* - The frame is received without errors and passes the filtering and it's not an
* spurious ACK.
* - ACK is not requested or transmission of ACK is not possible due to internal
* conditions.
* - Finalization of a frame transmission or transmission of an ACK frame, when ACK is not
* requested in the transmitted frame.
* - Finalization of the reception operation of a requested ACK due to:
* - ACK timeout expiration.
* - Reception of an invalid ACK or not an ACK frame.
* - Reception of the proper ACK, unless the transmitted frame was a Data Request Command
* and the frame pending bit on the received ACK is set to true. In this case the radio
* platform implementation SHOULD keep the receiver on until a determined timeout which
* triggers an idle period start.
* - Finalization of a stand alone CCA task.
* - Finalization of a CCA operation with busy result during CSMA/CA procedure.
* - Finalization of an Energy Detection task.
* - Finalization of a scheduled radio reception window
* (see @ref IEEE802154_CONFIG_RX_SLOT).
*/
IEEE802154_CONFIG_RX_ON_WHEN_IDLE,

/** Number of types defined in ieee802154_config_type. */
IEEE802154_CONFIG_COMMON_COUNT,

Expand Down Expand Up @@ -1103,6 +1135,9 @@ struct ieee802154_config {
/** see @ref IEEE802154_CONFIG_PROMISCUOUS */
bool promiscuous;

/** see @ref IEEE802154_CONFIG_RX_ON_WHEN_IDLE */
bool rx_on_when_idle;

/** see @ref IEEE802154_CONFIG_EVENT_HANDLER */
ieee802154_event_cb_t event_handler;

Expand Down
17 changes: 17 additions & 0 deletions modules/openthread/platform/radio.c
Original file line number Diff line number Diff line change
Expand Up @@ -890,9 +890,26 @@ otRadioCaps otPlatRadioGetCaps(otInstance *aInstance)
caps |= OT_RADIO_CAPS_RECEIVE_TIMING;
}

if (radio_caps & IEEE802154_RX_ON_WHEN_IDLE) {
caps |= OT_RADIO_CAPS_RX_ON_WHEN_IDLE;
}

return caps;
}

void otPlatRadioSetRxOnWhenIdle(otInstance *aInstance, bool aRxOnWhenIdle)
{
struct ieee802154_config config = {
.rx_on_when_idle = aRxOnWhenIdle
};

ARG_UNUSED(aInstance);

LOG_DBG("RxOnWhenIdle=%d", aRxOnWhenIdle ? 1 : 0);

radio_api->configure(radio_dev, IEEE802154_CONFIG_RX_ON_WHEN_IDLE, &config);
}

bool otPlatRadioGetPromiscuous(otInstance *aInstance)
{
ARG_UNUSED(aInstance);
Expand Down
2 changes: 1 addition & 1 deletion west.yml
Original file line number Diff line number Diff line change
Expand Up @@ -301,7 +301,7 @@ manifest:
revision: 214f9fc1539f8e5937c0474cb6ee29b6dcb2d4b8
path: modules/lib/open-amp
- name: openthread
revision: 6edb06e4e0472411200ce2a084a783eaf3faffe3
revision: 193e77e40ec2387d458eaebd1e03902d86f484a5
path: modules/lib/openthread
- name: percepio
path: modules/debug/percepio
Expand Down
Loading