From 31e0fec12aeb07de3ac92a90afcf6ace6e027707 Mon Sep 17 00:00:00 2001 From: Yakun Xu Date: Thu, 19 Apr 2018 01:54:13 +0800 Subject: [PATCH] [link] fix link raw caps calculation (#2668) Allow software implementations of link layer features even when hardware supports. --- src/core/api/link_raw_api.cpp | 18 ++++++++++++------ 1 file changed, 12 insertions(+), 6 deletions(-) diff --git a/src/core/api/link_raw_api.cpp b/src/core/api/link_raw_api.cpp index 85f593148..e7bf8fc86 100644 --- a/src/core/api/link_raw_api.cpp +++ b/src/core/api/link_raw_api.cpp @@ -157,18 +157,24 @@ otRadioCaps LinkRaw::GetCaps(void) const // time included into the raw link-layer code. #if OPENTHREAD_CONFIG_ENABLE_SOFTWARE_ACK_TIMEOUT - assert((RadioCaps & OT_RADIO_CAPS_ACK_TIMEOUT) == 0); - RadioCaps = static_cast(RadioCaps | OT_RADIO_CAPS_ACK_TIMEOUT); + if ((RadioCaps & OT_RADIO_CAPS_ACK_TIMEOUT) == 0) + { + RadioCaps = static_cast(RadioCaps | OT_RADIO_CAPS_ACK_TIMEOUT); + } #endif // OPENTHREAD_CONFIG_ENABLE_SOFTWARE_ACK_TIMEOUT #if OPENTHREAD_CONFIG_ENABLE_SOFTWARE_RETRANSMIT - assert((RadioCaps & OT_RADIO_CAPS_TRANSMIT_RETRIES) == 0); - RadioCaps = static_cast(RadioCaps | OT_RADIO_CAPS_TRANSMIT_RETRIES); + if ((RadioCaps & OT_RADIO_CAPS_TRANSMIT_RETRIES) == 0) + { + RadioCaps = static_cast(RadioCaps | OT_RADIO_CAPS_TRANSMIT_RETRIES); + } #endif // OPENTHREAD_CONFIG_ENABLE_SOFTWARE_RETRANSMIT #if OPENTHREAD_CONFIG_ENABLE_SOFTWARE_ENERGY_SCAN - assert((RadioCaps & OT_RADIO_CAPS_ENERGY_SCAN) == 0); - RadioCaps = static_cast(RadioCaps | OT_RADIO_CAPS_ENERGY_SCAN); + if ((RadioCaps & OT_RADIO_CAPS_ENERGY_SCAN) == 0) + { + RadioCaps = static_cast(RadioCaps | OT_RADIO_CAPS_ENERGY_SCAN); + } #endif // OPENTHREAD_CONFIG_ENABLE_SOFTWARE_ENERGY_SCAN return RadioCaps;