Skip to content

Commit

Permalink
net: openthread: Add support for HW CSMA CA
Browse files Browse the repository at this point in the history
Forward CSMA CA capability to OpenThread and use CSMA CA enabled
transfer if supported.

Signed-off-by: Robert Lubos <robert.lubos@nordicsemi.no>
  • Loading branch information
rlubos authored and hakehuang committed Apr 30, 2020
1 parent 42f5f34 commit 30150b4
Showing 1 changed file with 17 additions and 3 deletions.
20 changes: 17 additions & 3 deletions subsys/net/lib/openthread/platform/radio.c
Original file line number Diff line number Diff line change
Expand Up @@ -189,9 +189,18 @@ void platformRadioProcess(otInstance *aInstance)
radio_api->set_txpower(radio_dev, tx_power);

if (sTransmitFrame.mInfo.mTxInfo.mCsmaCaEnabled) {
if (radio_api->cca(radio_dev) ||
radio_api->tx(radio_dev, IEEE802154_TX_MODE_DIRECT,
tx_pkt, tx_payload)) {
if (radio_api->get_capabilities(radio_dev) &
IEEE802154_HW_CSMA) {
if (radio_api->tx(radio_dev,
IEEE802154_TX_MODE_CSMA_CA,
tx_pkt, tx_payload) != 0) {
result =
OT_ERROR_CHANNEL_ACCESS_FAILURE;
}
} else if (radio_api->cca(radio_dev) != 0 ||
radio_api->tx(radio_dev,
IEEE802154_TX_MODE_DIRECT,
tx_pkt, tx_payload) != 0) {
result = OT_ERROR_CHANNEL_ACCESS_FAILURE;
}
} else {
Expand Down Expand Up @@ -422,6 +431,11 @@ otRadioCaps otPlatRadioGetCaps(otInstance *aInstance)
caps |= OT_RADIO_CAPS_ENERGY_SCAN;
}

if (radio_caps & IEEE802154_HW_CSMA) {
caps |= OT_RADIO_CAPS_CSMA_BACKOFF |
OT_RADIO_CAPS_TRANSMIT_RETRIES;
}

return caps;
}

Expand Down

0 comments on commit 30150b4

Please sign in to comment.