Skip to content

Commit

Permalink
net: openthread: implement otPlatRadioSetRxOnWhenIdle
Browse files Browse the repository at this point in the history
Implement `otPlatRadioSetRxOnWhenIdle`  and add `IEEE802154_RX_ON_WHEN_IDLE` capability.

Signed-off-by: Eduardo Montoya <eduardo.montoya@nordicsemi.no>
  • Loading branch information
edmont committed Oct 31, 2023
1 parent 67676d8 commit 06d4cf7
Show file tree
Hide file tree
Showing 2 changed files with 49 additions and 1 deletion.
33 changes: 32 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 @@ -1036,6 +1039,31 @@ 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:

Check warning on line 1047 in include/zephyr/net/ieee802154_radio.h

View workflow job for this annotation

GitHub Actions / Run compliance checks on patch series (PR)

LONG_LINE_COMMENT

include/zephyr/net/ieee802154_radio.h:1047 line length of 102 exceeds 100 columns
* - Finalization of a regular frame reception task, provided that:

Check failure on line 1048 in include/zephyr/net/ieee802154_radio.h

View workflow job for this annotation

GitHub Actions / Run compliance checks on patch series (PR)

CODE_INDENT

include/zephyr/net/ieee802154_radio.h:1048 code indent should use tabs where possible

Check warning on line 1048 in include/zephyr/net/ieee802154_radio.h

View workflow job for this annotation

GitHub Actions / Run compliance checks on patch series (PR)

SPACE_BEFORE_TAB

include/zephyr/net/ieee802154_radio.h:1048 please, no space before tabs
* - The frame is received without errors and passes the filtering and it's not an spurious ACK.

Check warning on line 1049 in include/zephyr/net/ieee802154_radio.h

View workflow job for this annotation

GitHub Actions / Run compliance checks on patch series (PR)

LONG_LINE_COMMENT

include/zephyr/net/ieee802154_radio.h:1049 line length of 106 exceeds 100 columns

Check failure on line 1049 in include/zephyr/net/ieee802154_radio.h

View workflow job for this annotation

GitHub Actions / Run compliance checks on patch series (PR)

CODE_INDENT

include/zephyr/net/ieee802154_radio.h:1049 code indent should use tabs where possible

Check warning on line 1049 in include/zephyr/net/ieee802154_radio.h

View workflow job for this annotation

GitHub Actions / Run compliance checks on patch series (PR)

SPACE_BEFORE_TAB

include/zephyr/net/ieee802154_radio.h:1049 please, no space before tabs
* - ACK is not requested or transmission of ACK is not possible due to internal conditions.

Check warning on line 1050 in include/zephyr/net/ieee802154_radio.h

View workflow job for this annotation

GitHub Actions / Run compliance checks on patch series (PR)

LONG_LINE_COMMENT

include/zephyr/net/ieee802154_radio.h:1050 line length of 102 exceeds 100 columns

Check failure on line 1050 in include/zephyr/net/ieee802154_radio.h

View workflow job for this annotation

GitHub Actions / Run compliance checks on patch series (PR)

CODE_INDENT

include/zephyr/net/ieee802154_radio.h:1050 code indent should use tabs where possible

Check warning on line 1050 in include/zephyr/net/ieee802154_radio.h

View workflow job for this annotation

GitHub Actions / Run compliance checks on patch series (PR)

SPACE_BEFORE_TAB

include/zephyr/net/ieee802154_radio.h:1050 please, no space before tabs
* - Finalization of a frame transmission or transmission of an ACK frame, when ACK is not requested

Check warning on line 1051 in include/zephyr/net/ieee802154_radio.h

View workflow job for this annotation

GitHub Actions / Run compliance checks on patch series (PR)

LONG_LINE_COMMENT

include/zephyr/net/ieee802154_radio.h:1051 line length of 108 exceeds 100 columns

Check failure on line 1051 in include/zephyr/net/ieee802154_radio.h

View workflow job for this annotation

GitHub Actions / Run compliance checks on patch series (PR)

CODE_INDENT

include/zephyr/net/ieee802154_radio.h:1051 code indent should use tabs where possible

Check warning on line 1051 in include/zephyr/net/ieee802154_radio.h

View workflow job for this annotation

GitHub Actions / Run compliance checks on patch series (PR)

SPACE_BEFORE_TAB

include/zephyr/net/ieee802154_radio.h:1051 please, no space before tabs
in the transmitted frame.
* - Finalization of the reception operation of a requested ACK due to:

Check failure on line 1053 in include/zephyr/net/ieee802154_radio.h

View workflow job for this annotation

GitHub Actions / Run compliance checks on patch series (PR)

CODE_INDENT

include/zephyr/net/ieee802154_radio.h:1053 code indent should use tabs where possible

Check warning on line 1053 in include/zephyr/net/ieee802154_radio.h

View workflow job for this annotation

GitHub Actions / Run compliance checks on patch series (PR)

SPACE_BEFORE_TAB

include/zephyr/net/ieee802154_radio.h:1053 please, no space before tabs
* - ACK timeout expiration.

Check failure on line 1054 in include/zephyr/net/ieee802154_radio.h

View workflow job for this annotation

GitHub Actions / Run compliance checks on patch series (PR)

CODE_INDENT

include/zephyr/net/ieee802154_radio.h:1054 code indent should use tabs where possible

Check warning on line 1054 in include/zephyr/net/ieee802154_radio.h

View workflow job for this annotation

GitHub Actions / Run compliance checks on patch series (PR)

SPACE_BEFORE_TAB

include/zephyr/net/ieee802154_radio.h:1054 please, no space before tabs
* - Reception of an invalid ACK or not an ACK frame.

Check failure on line 1055 in include/zephyr/net/ieee802154_radio.h

View workflow job for this annotation

GitHub Actions / Run compliance checks on patch series (PR)

CODE_INDENT

include/zephyr/net/ieee802154_radio.h:1055 code indent should use tabs where possible
* - Reception of the proper ACK, unless the transmitted frame was a Data Request Command and the

Check failure on line 1056 in include/zephyr/net/ieee802154_radio.h

View workflow job for this annotation

GitHub Actions / Run compliance checks on patch series (PR)

CODE_INDENT

include/zephyr/net/ieee802154_radio.h:1056 code indent should use tabs where possible
* 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.

Check failure on line 1060 in include/zephyr/net/ieee802154_radio.h

View workflow job for this annotation

GitHub Actions / Run compliance checks on patch series (PR)

CODE_INDENT

include/zephyr/net/ieee802154_radio.h:1060 code indent should use tabs where possible
* - Finalization of a CCA operation with busy result during CSMA/CA procedure.

Check failure on line 1061 in include/zephyr/net/ieee802154_radio.h

View workflow job for this annotation

GitHub Actions / Run compliance checks on patch series (PR)

CODE_INDENT

include/zephyr/net/ieee802154_radio.h:1061 code indent should use tabs where possible
* - 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 @@ -1082,6 +1110,9 @@ struct ieee802154_config {
/** see @ref IEEE802154_CONFIG_PROMISCUOUS */
bool promiscuous;

/** see @ref ``IEEE802154_CONFIG_RX_ON_WHNE_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 @@ -895,9 +895,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

0 comments on commit 06d4cf7

Please sign in to comment.