diff --git a/src/src/alarm.c b/src/src/alarm.c index 21476bd2..e943d6ba 100644 --- a/src/src/alarm.c +++ b/src/src/alarm.c @@ -32,7 +32,6 @@ * */ -#include #include #include #include @@ -40,6 +39,7 @@ #include #include #include +#include "common/debug.hpp" #include "common/logging.hpp" #include "platform-efr32.h" @@ -89,7 +89,7 @@ uint32_t otPlatAlarmMilliGetNow(void) ticks = sl_sleeptimer_get_tick_count64(); status = sl_sleeptimer_tick64_to_ms(ticks, &now); - assert(status == SL_STATUS_OK); + OT_ASSERT(status == SL_STATUS_OK); return (uint32_t)now; } @@ -131,7 +131,7 @@ void otPlatAlarmMilliStartAt(otInstance *aInstance, uint32_t aT0, uint32_t aDt) NULL, 0, SL_SLEEPTIMER_NO_HIGH_PRECISION_HF_CLOCKS_REQUIRED_FLAG); - assert(status == SL_STATUS_OK); + OT_ASSERT(status == SL_STATUS_OK); } } @@ -261,7 +261,7 @@ void otPlatAlarmMicroStartAt(otInstance *aInstance, uint32_t aT0, uint32_t aDt) else { status = RAIL_SetMultiTimer(&rail_timer, remaining, RAIL_TIME_DELAY, radioTimerExpired, NULL); - assert(status == RAIL_STATUS_NO_ERROR); + OT_ASSERT(status == RAIL_STATUS_NO_ERROR); } } diff --git a/src/src/diag.c b/src/src/diag.c index 12dd636f..631fb6cd 100644 --- a/src/src/diag.c +++ b/src/src/diag.c @@ -43,6 +43,7 @@ #include #include #include "common/code_utils.hpp" +#include "common/debug.hpp" #include "common/logging.hpp" #include "diag.h" @@ -232,7 +233,9 @@ static RAIL_Status_t stopTxStream(void) // Since start transmit stream turn off the radio state, // call the RAIL_StartRx to turn on radio IgnoreError(RAIL_GetChannel(gRailHandle, ¤tChannel)); - assert(RAIL_StartRx(gRailHandle, currentChannel, &rxSchedulerInfo) == RAIL_STATUS_NO_ERROR); + + status = RAIL_StartRx(gRailHandle, currentChannel, &rxSchedulerInfo); + OT_ASSERT(status == RAIL_STATUS_NO_ERROR); exit: return status; diff --git a/src/src/ieee802154-packet-utils.cpp b/src/src/ieee802154-packet-utils.cpp index f1ac34e2..89c4bb5f 100644 --- a/src/src/ieee802154-packet-utils.cpp +++ b/src/src/ieee802154-packet-utils.cpp @@ -39,7 +39,6 @@ #include "sl_packet_utils.h" #include "sli_protocol_crypto.h" -#include #include "common/code_utils.hpp" #include "common/debug.hpp" #include "crypto/aes_ccm.hpp" diff --git a/src/src/radio.c b/src/src/radio.c index fa394768..e9060426 100644 --- a/src/src/radio.c +++ b/src/src/radio.c @@ -32,7 +32,6 @@ * */ -#include #include #include #include @@ -41,6 +40,7 @@ #include #include #include +#include "common/debug.hpp" #include "common/logging.hpp" #include "utils/code_utils.h" @@ -286,6 +286,8 @@ static otRadioIeInfo sTransmitIeInfo; #define CCA_THRESHOLD_UNINIT 127 #define CCA_THRESHOLD_DEFAULT -75 // dBm - default for 2.4GHz 802.15.4 +#define UNINITIALIZED_CHANNEL 0xFF + static bool sPromiscuous = false; static efr32CommonConfig sCommonConfig; static efr32BandConfig sBandConfig; @@ -308,7 +310,6 @@ static RAIL_IEEE802154_RxChannelSwitchingCfg_t sChannelSwitchingCfg; static RAIL_IEEE802154_RX_CHANNEL_SWITCHING_BUF_ALIGNMENT_TYPE sChannelSwitchingBuffer[RAIL_IEEE802154_RX_CHANNEL_SWITCHING_BUF_BYTES / RAIL_IEEE802154_RX_CHANNEL_SWITCHING_BUF_ALIGNMENT]; -#define UNINITIALIZED_CHANNEL 0xFF static bool isMultiChannel(void) { @@ -444,8 +445,8 @@ static void sli_get_default_and_max_powers_across_iids(int8_t *defaultTxPower, int8_t *txPowerFromTable, uint16_t channel) { - assert(txPowerFromTable != NULL); - assert(defaultTxPower != NULL); + OT_ASSERT(txPowerFromTable != NULL); + OT_ASSERT(defaultTxPower != NULL); for (uint8_t iid = 0U; iid < RADIO_INTERFACE_COUNT; iid++) { @@ -713,7 +714,7 @@ static otError radioProcessTransmitSecurity(otRadioFrame *aFrame, uint8_t iid) otEXPECT(otMacFrameIsSecurityEnabled(aFrame) && otMacFrameIsKeyIdMode1(aFrame) && !aFrame->mInfo.mTxInfo.mIsSecurityProcessed); - assert(panIndex != INVALID_VALUE); + OT_ASSERT(panIndex != INVALID_VALUE); if (otMacFrameIsAck(aFrame)) { @@ -783,7 +784,7 @@ static uint8_t readInitialPacketData(RAIL_RxPacketInfo_t *packetInfo, uint8_t packetBytesRead = 0; // Check if we have enough buffer - assert((buffer_len >= expected_data_bytes_max) || (packetInfo != NULL)); + OT_ASSERT((buffer_len >= expected_data_bytes_max) || (packetInfo != NULL)); // Read the packet info RAIL_GetRxIncomingPacketInfo(gRailHandle, packetInfo); @@ -884,7 +885,7 @@ static void updateEvents(RAIL_Events_t mask, RAIL_Events_t values) { currentEventConfig = newEventConfig; status = RAIL_ConfigEvents(gRailHandle, mask, values); - assert(status == RAIL_STATUS_NO_ERROR); + OT_ASSERT(status == RAIL_STATUS_NO_ERROR); } } @@ -904,7 +905,7 @@ static void updateEvents(RAIL_Events_t mask, RAIL_Events_t values) { RAIL_Status_t status; status = RAIL_ConfigEvents(gRailHandle, mask, values); - assert(status == RAIL_STATUS_NO_ERROR); + OT_ASSERT(status == RAIL_STATUS_NO_ERROR); } #define handlePhyStackEvent(event, supplement) 0 @@ -971,18 +972,18 @@ static otError radioSetRx(uint8_t aChannel) { // Calling RAIL_StartRx with a channel not listed in the channel // switching config is a bug. - assert(fastChannelIndex(aChannel) != INVALID_VALUE); + OT_ASSERT(fastChannelIndex(aChannel) != INVALID_VALUE); radioSetIdle(); status = RAIL_IEEE802154_ConfigRxChannelSwitching(gRailHandle, &sChannelSwitchingCfg); - assert(status == RAIL_STATUS_NO_ERROR); + OT_ASSERT(status == RAIL_STATUS_NO_ERROR); status = RAIL_ConfigRxOptions(gRailHandle, RAIL_RX_OPTION_CHANNEL_SWITCHING, RAIL_RX_OPTION_CHANNEL_SWITCHING); - assert(status == RAIL_STATUS_NO_ERROR); + OT_ASSERT(status == RAIL_STATUS_NO_ERROR); } else { status = RAIL_ConfigRxOptions(gRailHandle, RAIL_RX_OPTION_CHANNEL_SWITCHING, RAIL_RX_OPTIONS_NONE); - assert(status == RAIL_STATUS_NO_ERROR); + OT_ASSERT(status == RAIL_STATUS_NO_ERROR); } #endif @@ -1040,10 +1041,10 @@ static void configureTxPower(RAIL_TxPowerConfig_t *aTxPowerConfig, int8_t aTxPow } status = RAIL_ConfigTxPower(gRailHandle, aTxPowerConfig); - assert(status == RAIL_STATUS_NO_ERROR); + OT_ASSERT(status == RAIL_STATUS_NO_ERROR); status = RAIL_SetTxPowerDbm(gRailHandle, tx_power_dbm); - assert(status == RAIL_STATUS_NO_ERROR); + OT_ASSERT(status == RAIL_STATUS_NO_ERROR); } //------------------------------------------------------------------------------ @@ -1054,41 +1055,41 @@ static RAIL_Handle_t efr32RailInit(efr32CommonConfig *aCommonConfig) RAIL_Handle_t handle; #if !OPENTHREAD_RADIO - assert(DEVICE_CAPABILITY_MCU_EN); + OT_ASSERT(DEVICE_CAPABILITY_MCU_EN); #endif handle = RAIL_Init(&aCommonConfig->mRailConfig, NULL); - assert(handle != NULL); + OT_ASSERT(handle != NULL); #if defined(SL_CATALOG_POWER_MANAGER_PRESENT) status = RAIL_InitPowerManager(); - assert(status == RAIL_STATUS_NO_ERROR); + OT_ASSERT(status == RAIL_STATUS_NO_ERROR); #endif // SL_CATALOG_POWER_MANAGER_PRESENT status = RAIL_ConfigCal(handle, RAIL_CAL_ALL); - assert(status == RAIL_STATUS_NO_ERROR); + OT_ASSERT(status == RAIL_STATUS_NO_ERROR); status = RAIL_SetPtiProtocol(handle, RAIL_PTI_PROTOCOL_THREAD); - assert(status == RAIL_STATUS_NO_ERROR); + OT_ASSERT(status == RAIL_STATUS_NO_ERROR); status = RAIL_IEEE802154_Init(handle, &sRailIeee802154Config); - assert(status == RAIL_STATUS_NO_ERROR); + OT_ASSERT(status == RAIL_STATUS_NO_ERROR); #if (OPENTHREAD_CONFIG_THREAD_VERSION >= OT_THREAD_VERSION_1_2) // Enhanced Frame Pending status = RAIL_IEEE802154_EnableEarlyFramePending(handle, true); - assert(status == RAIL_STATUS_NO_ERROR); + OT_ASSERT(status == RAIL_STATUS_NO_ERROR); status = RAIL_IEEE802154_EnableDataFramePending(handle, true); - assert(status == RAIL_STATUS_NO_ERROR); + OT_ASSERT(status == RAIL_STATUS_NO_ERROR); // Copies of MAC keys for encrypting at the radio layer memset(sMacKeys, 0, sizeof(sMacKeys)); #endif // (OPENTHREAD_CONFIG_THREAD_VERSION >= OT_THREAD_VERSION_1_2) - uint16_t actualLength = - RAIL_SetTxFifo(handle, aCommonConfig->mRailTxFifo.fifo, 0, sizeof(aCommonConfig->mRailTxFifo.fifo)); - assert(actualLength == sizeof(aCommonConfig->mRailTxFifo.fifo)); + uint16_t actualLength = 0; + actualLength = RAIL_SetTxFifo(handle, aCommonConfig->mRailTxFifo.fifo, 0, sizeof(aCommonConfig->mRailTxFifo.fifo)); + OT_ASSERT(actualLength == sizeof(aCommonConfig->mRailTxFifo.fifo)); // Enable RAIL multi-timer RAIL_ConfigMultiTimer(true); @@ -1106,15 +1107,16 @@ static void efr32RailConfigLoad(efr32BandConfig *aBandConfig, int8_t aTxPower) if (aBandConfig->mChannelConfig != NULL) { status = RAIL_IEEE802154_SetPtiRadioConfig(gRailHandle, RAIL_IEEE802154_PTI_RADIO_CONFIG_915MHZ_R23_NA_EXT); - assert(status == RAIL_STATUS_NO_ERROR); + OT_ASSERT(status == RAIL_STATUS_NO_ERROR); - uint16_t firstChannel = RAIL_ConfigChannels(gRailHandle, aBandConfig->mChannelConfig, NULL); - assert(firstChannel == aBandConfig->mChannelMin); + uint16_t firstChannel = UNINITIALIZED_CHANNEL; + firstChannel = RAIL_ConfigChannels(gRailHandle, aBandConfig->mChannelConfig, NULL); + OT_ASSERT(firstChannel == aBandConfig->mChannelMin); txPowerConfig.mode = SL_RAIL_UTIL_PA_SELECTION_SUBGHZ; status = RAIL_IEEE802154_ConfigGOptions(gRailHandle, RAIL_IEEE802154_G_OPTION_GB868, RAIL_IEEE802154_G_OPTION_GB868); - assert(status == RAIL_STATUS_NO_ERROR); + OT_ASSERT(status == RAIL_STATUS_NO_ERROR); } else { @@ -1123,7 +1125,7 @@ static void efr32RailConfigLoad(efr32BandConfig *aBandConfig, int8_t aTxPower) #else status = RAIL_IEEE802154_Config2p4GHzRadio(gRailHandle); #endif // SL_CATALOG_RAIL_UTIL_IEEE802154_PHY_SELECT_PRESENT - assert(status == RAIL_STATUS_NO_ERROR); + OT_ASSERT(status == RAIL_STATUS_NO_ERROR); } #if (OPENTHREAD_CONFIG_THREAD_VERSION >= OT_THREAD_VERSION_1_2) @@ -1146,7 +1148,7 @@ static void efr32RadioSetTxPower(int8_t aPowerDbm) RAIL_Status_t status; status = RAIL_SetTxPowerDbm(gRailHandle, ((RAIL_TxPower_t)aPowerDbm) * 10); - assert(status == RAIL_STATUS_NO_ERROR); + OT_ASSERT(status == RAIL_STATUS_NO_ERROR); } static efr32BandConfig *efr32RadioGetBandConfig(uint8_t aChannel) @@ -1187,7 +1189,7 @@ static void efr32ConfigInit(void (*aEventCallback)(RAIL_Handle_t railHandle, RAI memset(sDefaultTxPower, SL_INVALID_TX_POWER, sizeof(sDefaultTxPower)); gRailHandle = efr32RailInit(&sCommonConfig); - assert(gRailHandle != NULL); + OT_ASSERT(gRailHandle != NULL); updateEvents(RAIL_EVENTS_ALL, (0 | RAIL_EVENT_RX_ACK_TIMEOUT | RAIL_EVENT_RX_PACKET_RECEIVED @@ -1214,16 +1216,16 @@ void efr32RadioInit(void) RAIL_Status_t status; // check if RAIL_TX_FIFO_SIZE is power of two.. - assert((RAIL_TX_FIFO_SIZE & (RAIL_TX_FIFO_SIZE - 1)) == 0); + OT_ASSERT((RAIL_TX_FIFO_SIZE & (RAIL_TX_FIFO_SIZE - 1)) == 0); // check the limits of the RAIL_TX_FIFO_SIZE. - assert((RAIL_TX_FIFO_SIZE >= 64) || (RAIL_TX_FIFO_SIZE <= 4096)); + OT_ASSERT((RAIL_TX_FIFO_SIZE >= 64) || (RAIL_TX_FIFO_SIZE <= 4096)); efr32ConfigInit(RAILCb_Generic); setInternalFlag(FLAG_RADIO_INIT_DONE, true); status = RAIL_ConfigSleep(gRailHandle, RAIL_SLEEP_CONFIG_TIMERSYNC_ENABLED); - assert(status == RAIL_STATUS_NO_ERROR); + OT_ASSERT(status == RAIL_STATUS_NO_ERROR); memset(&sReceivePacket, 0x00, sizeof(sReceivePacket)); @@ -1247,13 +1249,14 @@ void efr32RadioInit(void) otLinkMetricsInit(EFR32_RECEIVE_SENSITIVITY); #endif sCurrentBandConfig = efr32RadioGetBandConfig(OPENTHREAD_CONFIG_DEFAULT_CHANNEL); - assert(sCurrentBandConfig != NULL); + OT_ASSERT(sCurrentBandConfig != NULL); sl_rail_util_pa_init(); efr32RadioSetTxPower(OPENTHREAD_CONFIG_DEFAULT_TRANSMIT_POWER); - assert(RAIL_ConfigRxOptions(gRailHandle, RAIL_RX_OPTION_TRACK_ABORTED_FRAMES, RAIL_RX_OPTION_TRACK_ABORTED_FRAMES) - == RAIL_STATUS_NO_ERROR); + status = + RAIL_ConfigRxOptions(gRailHandle, RAIL_RX_OPTION_TRACK_ABORTED_FRAMES, RAIL_RX_OPTION_TRACK_ABORTED_FRAMES); + OT_ASSERT(status == RAIL_STATUS_NO_ERROR); efr32PhyStackInit(); efr32RadioSetCcaMode(SL_OPENTHREAD_RADIO_CCA_MODE); @@ -1277,7 +1280,7 @@ void efr32RadioDeinit(void) RAIL_Idle(gRailHandle, RAIL_IDLE_ABORT, true); status = RAIL_ConfigEvents(gRailHandle, RAIL_EVENTS_ALL, 0); - assert(status == RAIL_STATUS_NO_ERROR); + OT_ASSERT(status == RAIL_STATUS_NO_ERROR); sCurrentBandConfig = NULL; } @@ -1372,12 +1375,12 @@ void otPlatRadioSetPanId(otInstance *aInstance, uint16_t aPanId) uint8_t iid = otNcpPlatGetCurCommandIid(); uint8_t panIndex = getPanIndexFromIid(iid); - assert(panIndex != INVALID_VALUE); + OT_ASSERT(panIndex != INVALID_VALUE); otLogInfoPlat("PANID=%X index=%u IID=%d", aPanId, panIndex, iid); utilsSoftSrcMatchSetPanId(iid, aPanId); status = RAIL_IEEE802154_SetPanId(gRailHandle, aPanId, panIndex); - assert(status == RAIL_STATUS_NO_ERROR); + OT_ASSERT(status == RAIL_STATUS_NO_ERROR); #if OPENTHREAD_RADIO && OPENTHREAD_CONFIG_MULTIPAN_RCP_ENABLE == 1 // We already have IID 0 enabled in filtermask to track BCAST Packets, so @@ -1395,7 +1398,7 @@ void otPlatRadioSetExtendedAddress(otInstance *aInstance, const otExtAddress *aA uint8_t panIndex = getPanIndexFromIid(otNcpPlatGetCurCommandIid()); OT_UNUSED_VARIABLE(aInstance); - assert(panIndex != INVALID_VALUE); + OT_ASSERT(panIndex != INVALID_VALUE); for (size_t i = 0; i < sizeof(*aAddress); i++) { @@ -1414,7 +1417,7 @@ void otPlatRadioSetExtendedAddress(otInstance *aInstance, const otExtAddress *aA panIndex); status = RAIL_IEEE802154_SetLongAddress(gRailHandle, (uint8_t *)aAddress->m8, panIndex); - assert(status == RAIL_STATUS_NO_ERROR); + OT_ASSERT(status == RAIL_STATUS_NO_ERROR); } void otPlatRadioSetShortAddress(otInstance *aInstance, uint16_t aAddress) @@ -1424,11 +1427,11 @@ void otPlatRadioSetShortAddress(otInstance *aInstance, uint16_t aAddress) RAIL_Status_t status; uint8_t panIndex = getPanIndexFromIid(otNcpPlatGetCurCommandIid()); - assert(panIndex != INVALID_VALUE); + OT_ASSERT(panIndex != INVALID_VALUE); otLogInfoPlat("ShortAddr=%X index=%u", aAddress, panIndex); status = RAIL_IEEE802154_SetShortAddress(gRailHandle, aAddress, panIndex); - assert(status == RAIL_STATUS_NO_ERROR); + OT_ASSERT(status == RAIL_STATUS_NO_ERROR); } otRadioState otPlatRadioGetState(otInstance *aInstance) @@ -1516,7 +1519,7 @@ otError otPlatRadioReceive(otInstance *aInstance, uint8_t aChannel) #if FAST_CHANNEL_SWITCHING_SUPPORT uint8_t index = getPanIndexFromIid(otNcpPlatGetCurCommandIid()); - assert(index < RAIL_IEEE802154_RX_CHANNEL_SWITCHING_NUM_CHANNELS); + OT_ASSERT(index < RAIL_IEEE802154_RX_CHANNEL_SWITCHING_NUM_CHANNELS); sChannelSwitchingCfg.channels[index] = aChannel; #endif @@ -1616,8 +1619,8 @@ otError otPlatRadioTransmit(otInstance *aInstance, otRadioFrame *aFrame) efr32RadioSetTxPower(txPower); } - assert(!getInternalFlag(FLAG_ONGOING_TX_DATA)); - assert(aFrame == &sTransmitFrame); + OT_ASSERT(!getInternalFlag(FLAG_ONGOING_TX_DATA)); + OT_ASSERT(aFrame == &sTransmitFrame); setInternalFlag(RADIO_TX_EVENTS, false); sTxFrame = aFrame; @@ -1667,7 +1670,7 @@ otError otPlatRadioTransmit(otInstance *aInstance, otRadioFrame *aFrame) #if OPENTHREAD_CONFIG_THREAD_VERSION >= OT_THREAD_VERSION_1_2 void updateIeInfoTxFrame(uint32_t shrTxTime) { - assert(sTxFrame != NULL); + OT_ASSERT(sTxFrame != NULL); #if OPENTHREAD_CONFIG_MAC_HEADER_IE_SUPPORT && OPENTHREAD_CONFIG_TIME_SYNC_ENABLE // Seek the time sync offset and update the rendezvous time @@ -1701,8 +1704,8 @@ void updateIeInfoTxFrame(uint32_t shrTxTime) void txCurrentPacket(void) { - assert(getInternalFlag(FLAG_ONGOING_TX_DATA)); - assert(sTxFrame != NULL); + OT_ASSERT(getInternalFlag(FLAG_ONGOING_TX_DATA)); + OT_ASSERT(sTxFrame != NULL); RAIL_TxOptions_t txOptions = RAIL_TX_OPTIONS_DEFAULT; RAIL_Status_t status = RAIL_STATUS_INVALID_STATE; @@ -1712,7 +1715,7 @@ void txCurrentPacket(void) #if RADIO_CONFIG_DEBUG_COUNTERS_SUPPORT railDebugCounters.mRailPlatTxTriggered++; #endif - // signalling this event earlier, as this event can assert REQ (expecially for a + // signalling this event earlier, as this event can OT_ASSERT REQ (expecially for a // non-CSMA transmit) giving the Coex master a little more time to grant or deny. if (getInternalFlag(FLAG_CURRENT_TX_USE_CSMA)) { @@ -1887,7 +1890,7 @@ int8_t otPlatRadioGetRssi(otInstance *aInstance) #if FAST_CHANNEL_SWITCHING_SUPPORT uint8_t index = getPanIndexFromIid(otNcpPlatGetCurCommandIid()); - assert(index < RAIL_IEEE802154_RX_CHANNEL_SWITCHING_NUM_CHANNELS); + OT_ASSERT(index < RAIL_IEEE802154_RX_CHANNEL_SWITCHING_NUM_CHANNELS); if (sChannelSwitchingCfg.channels[index] != UNINITIALIZED_CHANNEL) { aChannel = sChannelSwitchingCfg.channels[index]; @@ -1937,7 +1940,7 @@ void otPlatRadioSetPromiscuous(otInstance *aInstance, bool aEnable) sPromiscuous = aEnable; status = RAIL_IEEE802154_SetPromiscuousMode(gRailHandle, aEnable); - assert(status == RAIL_STATUS_NO_ERROR); + OT_ASSERT(status == RAIL_STATUS_NO_ERROR); } void otPlatRadioEnableSrcMatch(otInstance *aInstance, bool aEnable) @@ -1976,7 +1979,7 @@ otError otPlatRadioSetTransmitPower(otInstance *aInstance, int8_t aPower) // RAIL_SetTxPowerDbm() takes power in units of deci-dBm (0.1dBm) // Divide by 10 because aPower is supposed be in units dBm status = RAIL_SetTxPowerDbm(gRailHandle, ((RAIL_TxPower_t)maxTxPower) * 10); - assert(status == RAIL_STATUS_NO_ERROR); + OT_ASSERT(status == RAIL_STATUS_NO_ERROR); return OT_ERROR_NONE; } @@ -2055,7 +2058,7 @@ void otPlatRadioSetMacKey(otInstance *aInstance, OT_UNUSED_VARIABLE(aKeyIdMode); OT_UNUSED_VARIABLE(aKeyType); - assert(aPrevKey != NULL && aCurrKey != NULL && aNextKey != NULL); + OT_ASSERT(aPrevKey != NULL && aCurrKey != NULL && aNextKey != NULL); sMacKeys[iid].keyId = aKeyId; memcpy(&sMacKeys[iid].keys[MAC_KEY_PREV], aPrevKey, sizeof(otMacKeyMaterial)); @@ -2063,25 +2066,27 @@ void otPlatRadioSetMacKey(otInstance *aInstance, memcpy(&sMacKeys[iid].keys[MAC_KEY_NEXT], aNextKey, sizeof(otMacKeyMaterial)); #if defined(_SILICON_LABS_32B_SERIES_2) && (OPENTHREAD_CONFIG_CRYPTO_LIB == OPENTHREAD_CONFIG_CRYPTO_LIB_PSA) - size_t aKeyLen = 0; + size_t aKeyLen = 0; + otError error = OT_ERROR_NONE; + + error = otPlatCryptoExportKey(sMacKeys[iid].keys[MAC_KEY_PREV].mKeyMaterial.mKeyRef, + sMacKeys[iid].keys[MAC_KEY_PREV].mKeyMaterial.mKey.m8, + sizeof(sMacKeys[iid].keys[MAC_KEY_PREV]), + &aKeyLen); + OT_ASSERT(error == OT_ERROR_NONE); - assert(otPlatCryptoExportKey(sMacKeys[iid].keys[MAC_KEY_PREV].mKeyMaterial.mKeyRef, - sMacKeys[iid].keys[MAC_KEY_PREV].mKeyMaterial.mKey.m8, - sizeof(sMacKeys[iid].keys[MAC_KEY_PREV]), - &aKeyLen) - == OT_ERROR_NONE); + error = otPlatCryptoExportKey(sMacKeys[iid].keys[MAC_KEY_CURRENT].mKeyMaterial.mKeyRef, + sMacKeys[iid].keys[MAC_KEY_CURRENT].mKeyMaterial.mKey.m8, + sizeof(sMacKeys[iid].keys[MAC_KEY_CURRENT]), + &aKeyLen); + OT_ASSERT(error == OT_ERROR_NONE); - assert(otPlatCryptoExportKey(sMacKeys[iid].keys[MAC_KEY_CURRENT].mKeyMaterial.mKeyRef, - sMacKeys[iid].keys[MAC_KEY_CURRENT].mKeyMaterial.mKey.m8, - sizeof(sMacKeys[iid].keys[MAC_KEY_CURRENT]), - &aKeyLen) - == OT_ERROR_NONE); + error = otPlatCryptoExportKey(sMacKeys[iid].keys[MAC_KEY_NEXT].mKeyMaterial.mKeyRef, + sMacKeys[iid].keys[MAC_KEY_NEXT].mKeyMaterial.mKey.m8, + sizeof(sMacKeys[iid].keys[MAC_KEY_NEXT]), + &aKeyLen); + OT_ASSERT(error == OT_ERROR_NONE); - assert(otPlatCryptoExportKey(sMacKeys[iid].keys[MAC_KEY_NEXT].mKeyMaterial.mKeyRef, - sMacKeys[iid].keys[MAC_KEY_NEXT].mKeyMaterial.mKey.m8, - sizeof(sMacKeys[iid].keys[MAC_KEY_NEXT]), - &aKeyLen) - == OT_ERROR_NONE); #endif } @@ -2492,7 +2497,7 @@ static void dataRequestCommandCallback(RAIL_Handle_t aRailHandle) } else { - assert(status == RAIL_STATUS_NO_ERROR); + OT_ASSERT(status == RAIL_STATUS_NO_ERROR); } } @@ -2703,8 +2708,8 @@ static void txFailedCallback(bool isAck, uint32_t status) static void ackTimeoutCallback(void) { - assert(txWaitingForAck()); - assert(getInternalFlag(FLAG_WAITING_FOR_ACK)); + OT_ASSERT(txWaitingForAck()); + OT_ASSERT(getInternalFlag(FLAG_WAITING_FOR_ACK)); setInternalFlag(EVENT_TX_NO_ACK, true); setInternalFlag(FLAG_ONGOING_TX_DATA, false); @@ -2731,7 +2736,7 @@ static void schedulerEventCallback(RAIL_Handle_t aRailHandle) RAIL_SchedulerStatus_t status = RAIL_GetSchedulerStatus(aRailHandle); bool transmitBusy = getInternalFlag(FLAG_ONGOING_TX_DATA); - assert(status != RAIL_SCHEDULER_STATUS_INTERNAL_ERROR); + OT_ASSERT(status != RAIL_SCHEDULER_STATUS_INTERNAL_ERROR); if (status == RAIL_SCHEDULER_STATUS_CCA_CSMA_TX_FAIL || status == RAIL_SCHEDULER_STATUS_SINGLE_TX_FAIL || status == RAIL_SCHEDULER_STATUS_SCHEDULED_TX_FAIL @@ -2964,7 +2969,7 @@ static void RAILCb_Generic(RAIL_Handle_t aRailHandle, RAIL_Events_t aEvents) status = RAIL_Calibrate(aRailHandle, NULL, RAIL_CAL_ALL_PENDING); // TODO: Non-RTOS DMP case fails #if (!defined(SL_CATALOG_BLUETOOTH_PRESENT) || defined(SL_CATALOG_KERNEL_PRESENT)) - assert(status == RAIL_STATUS_NO_ERROR); + OT_ASSERT(status == RAIL_STATUS_NO_ERROR); #else OT_UNUSED_VARIABLE(status); #endif @@ -3051,7 +3056,7 @@ static void updateRxFrameDetails(RAIL_RxPacketDetails_t *pPacketDetails, uint8_t iid) { OT_UNUSED_VARIABLE(iid); - assert(pPacketDetails != NULL); + OT_ASSERT(pPacketDetails != NULL); // Current time > sync-receive timestamp // Therefore lower 32 bits of current time should always be greater than lower 32 bits @@ -3388,7 +3393,7 @@ void efr32AntennaConfigInit(void) RAIL_Status_t status; sl_rail_util_ant_div_init(); status = sl_rail_util_ant_div_update_antenna_config(); - assert(status == RAIL_STATUS_NO_ERROR); + OT_ASSERT(status == RAIL_STATUS_NO_ERROR); } #endif // SL_CATALOG_RAIL_UTIL_ANT_DIV_PRESENT @@ -3466,10 +3471,10 @@ static void emRadioEnablePta(bool enable) // When PTA is enabled, we want to negate PTA_REQ as soon as an incoming // frame is aborted, e.g. due to filtering. To do that we must turn off // the TRACKABFRAME feature that's normally on to benefit sniffing on PTI. - assert(RAIL_ConfigRxOptions(gRailHandle, - RAIL_RX_OPTION_TRACK_ABORTED_FRAMES, - (enable ? RAIL_RX_OPTIONS_NONE : RAIL_RX_OPTION_TRACK_ABORTED_FRAMES)) - == RAIL_STATUS_NO_ERROR); + RAIL_Status_t status = RAIL_ConfigRxOptions(gRailHandle, + RAIL_RX_OPTION_TRACK_ABORTED_FRAMES, + (enable ? RAIL_RX_OPTIONS_NONE : RAIL_RX_OPTION_TRACK_ABORTED_FRAMES)); + OT_ASSERT(status == RAIL_STATUS_NO_ERROR); } static void efr32CoexInit(void) @@ -3505,7 +3510,7 @@ static void onPtaGrantTx(sl_rail_util_coex_req_t ptaStatus) } ptaGntEventReported = true; - assert(ptaStatus == SL_RAIL_UTIL_COEX_REQCB_GRANTED); + OT_ASSERT(ptaStatus == SL_RAIL_UTIL_COEX_REQCB_GRANTED); // PTA is telling us we've gotten GRANT and should send ASAP *without* CSMA setInternalFlag(FLAG_CURRENT_TX_USE_CSMA, false); txCurrentPacket(); @@ -3513,7 +3518,7 @@ static void onPtaGrantTx(sl_rail_util_coex_req_t ptaStatus) static void tryTxCurrentPacket(void) { - assert(getInternalFlag(FLAG_ONGOING_TX_DATA)); + OT_ASSERT(getInternalFlag(FLAG_ONGOING_TX_DATA)); ptaGntEventReported = false; sl_rail_util_ieee802154_stack_event_t ptaStatus = @@ -3550,7 +3555,7 @@ static void setCcaThreshold(void) { thresholddBm = RAIL_RSSI_INVALID_DBM; } - assert(RAIL_SetCcaThreshold(gRailHandle, thresholddBm) == RAIL_STATUS_NO_ERROR); + OT_ASSERT(RAIL_SetCcaThreshold(gRailHandle, thresholddBm) == RAIL_STATUS_NO_ERROR); } CORE_EXIT_ATOMIC(); } diff --git a/src/src/sl_rcp_gp_interface.c b/src/src/sl_rcp_gp_interface.c index 13d9daaa..71005f9e 100644 --- a/src/src/sl_rcp_gp_interface.c +++ b/src/src/sl_rcp_gp_interface.c @@ -37,9 +37,9 @@ #include "sl_packet_utils.h" #include "sl_rcp_gp_interface_config.h" #include "sl_status.h" -#include #include #include +#include "common/debug.hpp" #include "common/logging.hpp" #include "utils/mac_frame.h" diff --git a/src/src/sleep.c b/src/src/sleep.c index 49ea22df..3788083c 100644 --- a/src/src/sleep.c +++ b/src/src/sleep.c @@ -39,9 +39,9 @@ #include "em_core.h" #include "platform-efr32.h" #include "sl_component_catalog.h" -#include #include #include +#include "common/debug.hpp" #if defined(SL_CATALOG_POWER_MANAGER_PRESENT) #include "sl_power_manager.h" diff --git a/src/src/soft_source_match_table.c b/src/src/soft_source_match_table.c index 4b7cd4e8..0e3ae414 100644 --- a/src/src/soft_source_match_table.c +++ b/src/src/soft_source_match_table.c @@ -36,9 +36,9 @@ #include "soft_source_match_table.h" -#include #include #include +#include "common/debug.hpp" #include @@ -52,7 +52,7 @@ extern uint8_t otNcpPlatGetCurCommandIid(void); static inline uint8_t getPanIndex(uint8_t iid) { // Assert if iid=0 (broadcast iid) - assert(iid != 0); + OT_ASSERT(iid != 0); return iid - 1; } #else // !OPENTHREAD_CONFIG_MULTIPAN_RCP_ENABLE diff --git a/src/src/system.c b/src/src/system.c index e7e4ec1c..69348de4 100644 --- a/src/src/system.c +++ b/src/src/system.c @@ -32,8 +32,8 @@ * This file includes the platform-specific initializers. */ -#include #include +#include "common/debug.hpp" #include #include