diff --git a/examples/platforms/cc1352/misc.c b/examples/platforms/cc1352/misc.c index 4b35235cd..ead3803c9 100644 --- a/examples/platforms/cc1352/misc.c +++ b/examples/platforms/cc1352/misc.c @@ -53,10 +53,10 @@ void otPlatReset(otInstance *aInstance) */ otPlatResetReason otPlatGetResetReason(otInstance *aInstance) { - otPlatResetReason ret; - OT_UNUSED_VARIABLE(aInstance); + otPlatResetReason ret; + switch (SysCtrlResetSourceGet()) { case RSTSRC_PWR_ON: diff --git a/examples/platforms/cc1352/radio.c b/examples/platforms/cc1352/radio.c index 1cf93874e..e49984448 100644 --- a/examples/platforms/cc1352/radio.c +++ b/examples/platforms/cc1352/radio.c @@ -1207,10 +1207,10 @@ void cc1352RadioInit(void) */ otError otPlatRadioEnable(otInstance *aInstance) { - otError error = OT_ERROR_BUSY; - OT_UNUSED_VARIABLE(aInstance); + otError error = OT_ERROR_BUSY; + if (sState == cc1352_stateSleep) { error = OT_ERROR_NONE; @@ -1259,6 +1259,7 @@ exit: bool otPlatRadioIsEnabled(otInstance *aInstance) { OT_UNUSED_VARIABLE(aInstance); + return (sState != cc1352_stateDisabled); } @@ -1267,10 +1268,10 @@ bool otPlatRadioIsEnabled(otInstance *aInstance) */ otError otPlatRadioDisable(otInstance *aInstance) { - otError error = OT_ERROR_BUSY; - OT_UNUSED_VARIABLE(aInstance); + otError error = OT_ERROR_BUSY; + if (sState == cc1352_stateDisabled) { error = OT_ERROR_NONE; @@ -1294,10 +1295,10 @@ otError otPlatRadioDisable(otInstance *aInstance) */ otError otPlatRadioEnergyScan(otInstance *aInstance, uint8_t aScanChannel, uint16_t aScanDuration) { - otError error = OT_ERROR_BUSY; - OT_UNUSED_VARIABLE(aInstance); + otError error = OT_ERROR_BUSY; + if (sState == cc1352_stateSleep) { sState = cc1352_stateEdScan; @@ -1314,10 +1315,10 @@ exit: */ otError otPlatRadioGetTransmitPower(otInstance *aInstance, int8_t *aPower) { - otError error = OT_ERROR_NONE; - OT_UNUSED_VARIABLE(aInstance); + otError error = OT_ERROR_NONE; + otEXPECT_ACTION(aPower != NULL, error = OT_ERROR_INVALID_ARGS); *aPower = sCurrentOutputPower->dbm; @@ -1330,11 +1331,11 @@ exit: */ otError otPlatRadioSetTransmitPower(otInstance *aInstance, int8_t aPower) { + OT_UNUSED_VARIABLE(aInstance); + unsigned int i; output_config_t const *powerCfg = &(rgOutputPower[0]); - OT_UNUSED_VARIABLE(aInstance); - for (i = 1; i < OUTPUT_CONFIG_COUNT; i++) { if (rgOutputPower[i].dbm >= aPower) @@ -1357,10 +1358,10 @@ otError otPlatRadioSetTransmitPower(otInstance *aInstance, int8_t aPower) */ otError otPlatRadioReceive(otInstance *aInstance, uint8_t aChannel) { - otError error = OT_ERROR_BUSY; - OT_UNUSED_VARIABLE(aInstance); + otError error = OT_ERROR_BUSY; + if (sState == cc1352_stateSleep) { sState = cc1352_stateReceive; @@ -1411,10 +1412,10 @@ exit: */ otError otPlatRadioSleep(otInstance *aInstance) { - otError error = OT_ERROR_BUSY; - OT_UNUSED_VARIABLE(aInstance); + otError error = OT_ERROR_BUSY; + if (sState == cc1352_stateSleep) { error = OT_ERROR_NONE; @@ -1440,6 +1441,7 @@ otError otPlatRadioSleep(otInstance *aInstance) otRadioFrame *otPlatRadioGetTransmitBuffer(otInstance *aInstance) { OT_UNUSED_VARIABLE(aInstance); + return &sTransmitFrame; } @@ -1473,6 +1475,7 @@ exit: int8_t otPlatRadioGetRssi(otInstance *aInstance) { OT_UNUSED_VARIABLE(aInstance); + return sRfStats.maxRssi; } @@ -1482,6 +1485,7 @@ int8_t otPlatRadioGetRssi(otInstance *aInstance) otRadioCaps otPlatRadioGetCaps(otInstance *aInstance) { OT_UNUSED_VARIABLE(aInstance); + return OT_RADIO_CAPS_ACK_TIMEOUT | OT_RADIO_CAPS_ENERGY_SCAN | OT_RADIO_CAPS_TRANSMIT_RETRIES; } @@ -1509,11 +1513,11 @@ void otPlatRadioEnableSrcMatch(otInstance *aInstance, bool aEnable) */ otError otPlatRadioAddSrcMatchShortEntry(otInstance *aInstance, const uint16_t aShortAddress) { + OT_UNUSED_VARIABLE(aInstance); + otError error = OT_ERROR_NONE; uint8_t idx = rfCoreFindShortSrcMatchIdx(aShortAddress); - OT_UNUSED_VARIABLE(aInstance); - if (idx == CC1352_SRC_MATCH_NONE) { /* the entry does not exist already, add it */ @@ -1543,11 +1547,11 @@ exit: */ otError otPlatRadioClearSrcMatchShortEntry(otInstance *aInstance, const uint16_t aShortAddress) { + OT_UNUSED_VARIABLE(aInstance); + otError error = OT_ERROR_NONE; uint8_t idx; - OT_UNUSED_VARIABLE(aInstance); - otEXPECT_ACTION((idx = rfCoreFindShortSrcMatchIdx(aShortAddress)) != CC1352_SRC_MATCH_NONE, error = OT_ERROR_NO_ADDRESS); @@ -1573,11 +1577,11 @@ exit: */ otError otPlatRadioAddSrcMatchExtEntry(otInstance *aInstance, const otExtAddress *aExtAddress) { + OT_UNUSED_VARIABLE(aInstance); + otError error = OT_ERROR_NONE; uint8_t idx = rfCoreFindExtSrcMatchIdx((uint64_t *)aExtAddress); - OT_UNUSED_VARIABLE(aInstance); - if (idx == CC1352_SRC_MATCH_NONE) { /* the entry does not exist already, add it */ @@ -1606,11 +1610,11 @@ exit: */ otError otPlatRadioClearSrcMatchExtEntry(otInstance *aInstance, const otExtAddress *aExtAddress) { + OT_UNUSED_VARIABLE(aInstance); + otError error = OT_ERROR_NONE; uint8_t idx; - OT_UNUSED_VARIABLE(aInstance); - otEXPECT_ACTION((idx = rfCoreFindExtSrcMatchIdx((uint64_t *)aExtAddress)) != CC1352_SRC_MATCH_NONE, error = OT_ERROR_NO_ADDRESS); @@ -1690,6 +1694,7 @@ exit: bool otPlatRadioGetPromiscuous(otInstance *aInstance) { OT_UNUSED_VARIABLE(aInstance); + /* we are promiscuous if we are not filtering */ return sReceiveCmd.frameFiltOpt.frameFiltEn == 0; } @@ -1720,11 +1725,11 @@ void otPlatRadioSetPromiscuous(otInstance *aInstance, bool aEnable) */ void otPlatRadioGetIeeeEui64(otInstance *aInstance, uint8_t *aIeeeEui64) { + OT_UNUSED_VARIABLE(aInstance); + uint8_t * eui64; unsigned int i; - OT_UNUSED_VARIABLE(aInstance); - /* * The IEEE MAC address can be stored two places. We check the Customer * Configuration was not set before defaulting to the Factory @@ -1997,5 +2002,6 @@ void cc1352RadioProcess(otInstance *aInstance) int8_t otPlatRadioGetReceiveSensitivity(otInstance *aInstance) { OT_UNUSED_VARIABLE(aInstance); + return CC1352_RECEIVE_SENSITIVITY; } diff --git a/examples/platforms/cc2538/alarm.c b/examples/platforms/cc2538/alarm.c index 9de3dafad..4821792f8 100644 --- a/examples/platforms/cc2538/alarm.c +++ b/examples/platforms/cc2538/alarm.c @@ -75,6 +75,7 @@ void otPlatAlarmMilliStartAt(otInstance *aInstance, uint32_t t0, uint32_t dt) void otPlatAlarmMilliStop(otInstance *aInstance) { OT_UNUSED_VARIABLE(aInstance); + sIsRunning = false; } diff --git a/examples/platforms/cc2538/radio.c b/examples/platforms/cc2538/radio.c index 5946b045a..bade66e06 100644 --- a/examples/platforms/cc2538/radio.c +++ b/examples/platforms/cc2538/radio.c @@ -188,6 +188,8 @@ void setTxPower(int8_t aTxPower) void otPlatRadioGetIeeeEui64(otInstance *aInstance, uint8_t *aIeeeEui64) { + OT_UNUSED_VARIABLE(aInstance); + // EUI64 is in a mixed-endian format. Split in two halves, each 32-bit // half is in little-endian format (machine endian). However, the // most significant part of the EUI64 comes first, so we can't cheat @@ -197,8 +199,6 @@ void otPlatRadioGetIeeeEui64(otInstance *aInstance, uint8_t *aIeeeEui64) volatile uint32_t *eui64 = &HWREG(IEEE_EUI64); - OT_UNUSED_VARIABLE(aInstance); - // Read first 32-bits uint32_t part = eui64[0]; for (uint8_t i = 0; i < (OT_EXT_ADDRESS_SIZE / 2); i++) @@ -283,6 +283,7 @@ void cc2538RadioInit(void) bool otPlatRadioIsEnabled(otInstance *aInstance) { OT_UNUSED_VARIABLE(aInstance); + return (sState != OT_RADIO_STATE_DISABLED) ? true : false; } @@ -310,10 +311,10 @@ otError otPlatRadioDisable(otInstance *aInstance) otError otPlatRadioSleep(otInstance *aInstance) { - otError error = OT_ERROR_INVALID_STATE; - OT_UNUSED_VARIABLE(aInstance); + otError error = OT_ERROR_INVALID_STATE; + if (sState == OT_RADIO_STATE_SLEEP || sState == OT_RADIO_STATE_RECEIVE) { otLogDebgPlat("State=OT_RADIO_STATE_SLEEP", NULL); @@ -327,10 +328,10 @@ otError otPlatRadioSleep(otInstance *aInstance) otError otPlatRadioReceive(otInstance *aInstance, uint8_t aChannel) { - otError error = OT_ERROR_INVALID_STATE; - OT_UNUSED_VARIABLE(aInstance); + otError error = OT_ERROR_INVALID_STATE; + if (sState != OT_RADIO_STATE_DISABLED) { otLogDebgPlat("State=OT_RADIO_STATE_RECEIVE", NULL); @@ -371,10 +372,10 @@ static void setupTransmit(otRadioFrame *aFrame) otError otPlatRadioTransmit(otInstance *aInstance, otRadioFrame *aFrame) { - otError error = OT_ERROR_INVALID_STATE; - OT_UNUSED_VARIABLE(aInstance); + otError error = OT_ERROR_INVALID_STATE; + if (sState == OT_RADIO_STATE_RECEIVE) { int i; @@ -464,24 +465,28 @@ exit: otRadioFrame *otPlatRadioGetTransmitBuffer(otInstance *aInstance) { OT_UNUSED_VARIABLE(aInstance); + return &sTransmitFrame; } int8_t otPlatRadioGetRssi(otInstance *aInstance) { OT_UNUSED_VARIABLE(aInstance); + return 0; } otRadioCaps otPlatRadioGetCaps(otInstance *aInstance) { OT_UNUSED_VARIABLE(aInstance); + return OT_RADIO_CAPS_NONE; } bool otPlatRadioGetPromiscuous(otInstance *aInstance) { OT_UNUSED_VARIABLE(aInstance); + return (HWREG(RFCORE_XREG_FRMFILT0) & RFCORE_XREG_FRMFILT0_FRAME_FILTER_EN) == 0; } @@ -805,12 +810,12 @@ void otPlatRadioEnableSrcMatch(otInstance *aInstance, bool aEnable) otError otPlatRadioAddSrcMatchShortEntry(otInstance *aInstance, const uint16_t aShortAddress) { + OT_UNUSED_VARIABLE(aInstance); + otError error = OT_ERROR_NONE; int8_t entry = findSrcMatchAvailEntry(true); uint32_t *addr = (uint32_t *)RFCORE_FFSM_SRCADDRESS_TABLE; - OT_UNUSED_VARIABLE(aInstance); - otLogDebgPlat("Add ShortAddr entry: %d", entry); otEXPECT_ACTION(entry >= 0, error = OT_ERROR_NO_BUFS); @@ -830,12 +835,12 @@ exit: otError otPlatRadioAddSrcMatchExtEntry(otInstance *aInstance, const otExtAddress *aExtAddress) { + OT_UNUSED_VARIABLE(aInstance); + otError error = OT_ERROR_NONE; int8_t entry = findSrcMatchAvailEntry(false); uint32_t *addr = (uint32_t *)RFCORE_FFSM_SRCADDRESS_TABLE; - OT_UNUSED_VARIABLE(aInstance); - otLogDebgPlat("Add ExtAddr entry: %d", entry); otEXPECT_ACTION(entry >= 0, error = OT_ERROR_NO_BUFS); @@ -855,11 +860,11 @@ exit: otError otPlatRadioClearSrcMatchShortEntry(otInstance *aInstance, const uint16_t aShortAddress) { + OT_UNUSED_VARIABLE(aInstance); + otError error = OT_ERROR_NONE; int8_t entry = findSrcMatchShortEntry(aShortAddress); - OT_UNUSED_VARIABLE(aInstance); - otLogDebgPlat("Clear ShortAddr entry: %d", entry); otEXPECT_ACTION(entry >= 0, error = OT_ERROR_NO_ADDRESS); @@ -872,11 +877,11 @@ exit: otError otPlatRadioClearSrcMatchExtEntry(otInstance *aInstance, const otExtAddress *aExtAddress) { + OT_UNUSED_VARIABLE(aInstance); + otError error = OT_ERROR_NONE; int8_t entry = findSrcMatchExtEntry(aExtAddress); - OT_UNUSED_VARIABLE(aInstance); - otLogDebgPlat("Clear ExtAddr entry: %d", entry); otEXPECT_ACTION(entry >= 0, error = OT_ERROR_NO_ADDRESS); @@ -889,11 +894,11 @@ exit: void otPlatRadioClearSrcMatchShortEntries(otInstance *aInstance) { + OT_UNUSED_VARIABLE(aInstance); + uint32_t *addrEn = (uint32_t *)RFCORE_XREG_SRCSHORTEN0; uint32_t *addrAutoPendEn = (uint32_t *)RFCORE_FFSM_SRCSHORTPENDEN0; - OT_UNUSED_VARIABLE(aInstance); - otLogDebgPlat("Clear ShortAddr entries", NULL); for (uint8_t i = 0; i < RFCORE_XREG_SRCMATCH_ENABLE_STATUS_SIZE; i++) @@ -905,11 +910,11 @@ void otPlatRadioClearSrcMatchShortEntries(otInstance *aInstance) void otPlatRadioClearSrcMatchExtEntries(otInstance *aInstance) { + OT_UNUSED_VARIABLE(aInstance); + uint32_t *addrEn = (uint32_t *)RFCORE_XREG_SRCEXTEN0; uint32_t *addrAutoPendEn = (uint32_t *)RFCORE_FFSM_SRCEXTPENDEN0; - OT_UNUSED_VARIABLE(aInstance); - otLogDebgPlat("Clear ExtAddr entries", NULL); for (uint8_t i = 0; i < RFCORE_XREG_SRCMATCH_ENABLE_STATUS_SIZE; i++) @@ -924,15 +929,16 @@ otError otPlatRadioEnergyScan(otInstance *aInstance, uint8_t aScanChannel, uint1 OT_UNUSED_VARIABLE(aInstance); OT_UNUSED_VARIABLE(aScanChannel); OT_UNUSED_VARIABLE(aScanDuration); + return OT_ERROR_NOT_IMPLEMENTED; } otError otPlatRadioGetTransmitPower(otInstance *aInstance, int8_t *aPower) { - otError error = OT_ERROR_NONE; - OT_UNUSED_VARIABLE(aInstance); + otError error = OT_ERROR_NONE; + otEXPECT_ACTION(aPower != NULL, error = OT_ERROR_INVALID_ARGS); *aPower = sTxPower; @@ -943,6 +949,7 @@ exit: otError otPlatRadioSetTransmitPower(otInstance *aInstance, int8_t aPower) { OT_UNUSED_VARIABLE(aInstance); + setTxPower(aPower); return OT_ERROR_NONE; } @@ -950,5 +957,6 @@ otError otPlatRadioSetTransmitPower(otInstance *aInstance, int8_t aPower) int8_t otPlatRadioGetReceiveSensitivity(otInstance *aInstance) { OT_UNUSED_VARIABLE(aInstance); + return CC2538_RECEIVE_SENSITIVITY; } diff --git a/examples/platforms/cc2650/radio.c b/examples/platforms/cc2650/radio.c index 4cb6a4e52..7bce10b1b 100644 --- a/examples/platforms/cc2650/radio.c +++ b/examples/platforms/cc2650/radio.c @@ -1152,10 +1152,10 @@ void cc2650RadioInit(void) */ otError otPlatRadioEnable(otInstance *aInstance) { - otError error = OT_ERROR_BUSY; - OT_UNUSED_VARIABLE(aInstance); + otError error = OT_ERROR_BUSY; + if (sState == cc2650_stateSleep) { error = OT_ERROR_NONE; @@ -1192,10 +1192,10 @@ bool otPlatRadioIsEnabled(otInstance *aInstance) */ otError otPlatRadioDisable(otInstance *aInstance) { - otError error = OT_ERROR_BUSY; - OT_UNUSED_VARIABLE(aInstance); + otError error = OT_ERROR_BUSY; + if (sState == cc2650_stateDisabled) { error = OT_ERROR_NONE; @@ -1219,10 +1219,10 @@ otError otPlatRadioDisable(otInstance *aInstance) */ otError otPlatRadioEnergyScan(otInstance *aInstance, uint8_t aScanChannel, uint16_t aScanDuration) { - otError error = OT_ERROR_BUSY; - OT_UNUSED_VARIABLE(aInstance); + otError error = OT_ERROR_BUSY; + if (sState == cc2650_stateSleep) { sState = cc2650_stateEdScan; @@ -1239,10 +1239,10 @@ exit: */ otError otPlatRadioGetTransmitPower(otInstance *aInstance, int8_t *aPower) { - otError error = OT_ERROR_NONE; - OT_UNUSED_VARIABLE(aInstance); + otError error = OT_ERROR_NONE; + otEXPECT_ACTION(aPower != NULL, error = OT_ERROR_INVALID_ARGS); *aPower = sCurrentOutputPower->dbm; @@ -1255,11 +1255,11 @@ exit: */ otError otPlatRadioSetTransmitPower(otInstance *aInstance, int8_t aPower) { + OT_UNUSED_VARIABLE(aInstance); + unsigned int i; output_config_t const *powerCfg = &(rgOutputPower[0]); - OT_UNUSED_VARIABLE(aInstance); - for (i = 1; i < OUTPUT_CONFIG_COUNT; i++) { if (rgOutputPower[i].dbm >= aPower) @@ -1282,10 +1282,10 @@ otError otPlatRadioSetTransmitPower(otInstance *aInstance, int8_t aPower) */ otError otPlatRadioReceive(otInstance *aInstance, uint8_t aChannel) { - otError error = OT_ERROR_BUSY; - OT_UNUSED_VARIABLE(aInstance); + otError error = OT_ERROR_BUSY; + if (sState == cc2650_stateSleep) { sState = cc2650_stateReceive; @@ -1334,10 +1334,10 @@ exit: */ otError otPlatRadioSleep(otInstance *aInstance) { - otError error = OT_ERROR_BUSY; - OT_UNUSED_VARIABLE(aInstance); + otError error = OT_ERROR_BUSY; + if (sState == cc2650_stateSleep) { error = OT_ERROR_NONE; @@ -1432,11 +1432,11 @@ void otPlatRadioEnableSrcMatch(otInstance *aInstance, bool aEnable) */ otError otPlatRadioAddSrcMatchShortEntry(otInstance *aInstance, const uint16_t aShortAddress) { + OT_UNUSED_VARIABLE(aInstance); + otError error = OT_ERROR_NONE; uint8_t idx = rfCoreFindShortSrcMatchIdx(aShortAddress); - OT_UNUSED_VARIABLE(aInstance); - if (idx == CC2650_SRC_MATCH_NONE) { /* the entry does not exist already, add it */ @@ -1466,11 +1466,11 @@ exit: */ otError otPlatRadioClearSrcMatchShortEntry(otInstance *aInstance, const uint16_t aShortAddress) { + OT_UNUSED_VARIABLE(aInstance); + otError error = OT_ERROR_NONE; uint8_t idx; - OT_UNUSED_VARIABLE(aInstance); - otEXPECT_ACTION((idx = rfCoreFindShortSrcMatchIdx(aShortAddress)) != CC2650_SRC_MATCH_NONE, error = OT_ERROR_NO_ADDRESS); @@ -1496,11 +1496,11 @@ exit: */ otError otPlatRadioAddSrcMatchExtEntry(otInstance *aInstance, const otExtAddress *aExtAddress) { + OT_UNUSED_VARIABLE(aInstance); + otError error = OT_ERROR_NONE; uint8_t idx = rfCoreFindExtSrcMatchIdx((uint64_t *)aExtAddress); - OT_UNUSED_VARIABLE(aInstance); - if (idx == CC2650_SRC_MATCH_NONE) { /* the entry does not exist already, add it */ @@ -1529,11 +1529,11 @@ exit: */ otError otPlatRadioClearSrcMatchExtEntry(otInstance *aInstance, const otExtAddress *aExtAddress) { + OT_UNUSED_VARIABLE(aInstance); + otError error = OT_ERROR_NONE; uint8_t idx; - OT_UNUSED_VARIABLE(aInstance); - otEXPECT_ACTION((idx = rfCoreFindExtSrcMatchIdx((uint64_t *)aExtAddress)) != CC2650_SRC_MATCH_NONE, error = OT_ERROR_NO_ADDRESS); diff --git a/examples/platforms/cc2652/alarm.c b/examples/platforms/cc2652/alarm.c index 9c3733bd3..08e375525 100644 --- a/examples/platforms/cc2652/alarm.c +++ b/examples/platforms/cc2652/alarm.c @@ -95,6 +95,7 @@ void otPlatAlarmMilliStartAt(otInstance *aInstance, uint32_t aT0, uint32_t aDt) void otPlatAlarmMilliStop(otInstance *aInstance) { OT_UNUSED_VARIABLE(aInstance); + sIsRunning = false; } diff --git a/examples/platforms/cc2652/misc.c b/examples/platforms/cc2652/misc.c index 04f3e6c42..d38102205 100644 --- a/examples/platforms/cc2652/misc.c +++ b/examples/platforms/cc2652/misc.c @@ -44,6 +44,7 @@ void otPlatReset(otInstance *aInstance) { OT_UNUSED_VARIABLE(aInstance); + SysCtrlSystemReset(); } @@ -52,10 +53,10 @@ void otPlatReset(otInstance *aInstance) */ otPlatResetReason otPlatGetResetReason(otInstance *aInstance) { - otPlatResetReason ret; - OT_UNUSED_VARIABLE(aInstance); + otPlatResetReason ret; + switch (SysCtrlResetSourceGet()) { case RSTSRC_PWR_ON: diff --git a/examples/platforms/cc2652/radio.c b/examples/platforms/cc2652/radio.c index 85c1e401b..371eaf253 100644 --- a/examples/platforms/cc2652/radio.c +++ b/examples/platforms/cc2652/radio.c @@ -1206,10 +1206,10 @@ void cc2652RadioInit(void) */ otError otPlatRadioEnable(otInstance *aInstance) { - otError error = OT_ERROR_BUSY; - OT_UNUSED_VARIABLE(aInstance); + otError error = OT_ERROR_BUSY; + if (sState == cc2652_stateSleep) { error = OT_ERROR_NONE; @@ -1239,6 +1239,7 @@ exit: bool otPlatRadioIsEnabled(otInstance *aInstance) { OT_UNUSED_VARIABLE(aInstance); + return (sState != cc2652_stateDisabled); } @@ -1247,10 +1248,10 @@ bool otPlatRadioIsEnabled(otInstance *aInstance) */ otError otPlatRadioDisable(otInstance *aInstance) { - otError error = OT_ERROR_BUSY; - OT_UNUSED_VARIABLE(aInstance); + otError error = OT_ERROR_BUSY; + if (sState == cc2652_stateDisabled) { error = OT_ERROR_NONE; @@ -1274,10 +1275,10 @@ otError otPlatRadioDisable(otInstance *aInstance) */ otError otPlatRadioEnergyScan(otInstance *aInstance, uint8_t aScanChannel, uint16_t aScanDuration) { - otError error = OT_ERROR_BUSY; - OT_UNUSED_VARIABLE(aInstance); + otError error = OT_ERROR_BUSY; + if (sState == cc2652_stateSleep) { sState = cc2652_stateEdScan; @@ -1294,10 +1295,10 @@ exit: */ otError otPlatRadioGetTransmitPower(otInstance *aInstance, int8_t *aPower) { - otError error = OT_ERROR_NONE; - OT_UNUSED_VARIABLE(aInstance); + otError error = OT_ERROR_NONE; + otEXPECT_ACTION(aPower != NULL, error = OT_ERROR_INVALID_ARGS); *aPower = sCurrentOutputPower->dbm; @@ -1310,11 +1311,11 @@ exit: */ otError otPlatRadioSetTransmitPower(otInstance *aInstance, int8_t aPower) { + OT_UNUSED_VARIABLE(aInstance); + unsigned int i; output_config_t const *powerCfg = &(rgOutputPower[0]); - OT_UNUSED_VARIABLE(aInstance); - for (i = 1; i < OUTPUT_CONFIG_COUNT; i++) { if (rgOutputPower[i].dbm >= aPower) @@ -1337,10 +1338,10 @@ otError otPlatRadioSetTransmitPower(otInstance *aInstance, int8_t aPower) */ otError otPlatRadioReceive(otInstance *aInstance, uint8_t aChannel) { - otError error = OT_ERROR_BUSY; - OT_UNUSED_VARIABLE(aInstance); + otError error = OT_ERROR_BUSY; + if (sState == cc2652_stateSleep) { sState = cc2652_stateReceive; @@ -1391,10 +1392,10 @@ exit: */ otError otPlatRadioSleep(otInstance *aInstance) { - otError error = OT_ERROR_BUSY; - OT_UNUSED_VARIABLE(aInstance); + otError error = OT_ERROR_BUSY; + if (sState == cc2652_stateSleep) { error = OT_ERROR_NONE; @@ -1420,6 +1421,7 @@ otError otPlatRadioSleep(otInstance *aInstance) otRadioFrame *otPlatRadioGetTransmitBuffer(otInstance *aInstance) { OT_UNUSED_VARIABLE(aInstance); + return &sTransmitFrame; } @@ -1453,6 +1455,7 @@ exit: int8_t otPlatRadioGetRssi(otInstance *aInstance) { OT_UNUSED_VARIABLE(aInstance); + return sRfStats.maxRssi; } @@ -1462,6 +1465,7 @@ int8_t otPlatRadioGetRssi(otInstance *aInstance) otRadioCaps otPlatRadioGetCaps(otInstance *aInstance) { OT_UNUSED_VARIABLE(aInstance); + return OT_RADIO_CAPS_ACK_TIMEOUT | OT_RADIO_CAPS_ENERGY_SCAN | OT_RADIO_CAPS_TRANSMIT_RETRIES; } @@ -1489,11 +1493,11 @@ void otPlatRadioEnableSrcMatch(otInstance *aInstance, bool aEnable) */ otError otPlatRadioAddSrcMatchShortEntry(otInstance *aInstance, const uint16_t aShortAddress) { + OT_UNUSED_VARIABLE(aInstance); + otError error = OT_ERROR_NONE; uint8_t idx = rfCoreFindShortSrcMatchIdx(aShortAddress); - OT_UNUSED_VARIABLE(aInstance); - if (idx == CC2652_SRC_MATCH_NONE) { /* the entry does not exist already, add it */ @@ -1523,11 +1527,11 @@ exit: */ otError otPlatRadioClearSrcMatchShortEntry(otInstance *aInstance, const uint16_t aShortAddress) { + OT_UNUSED_VARIABLE(aInstance); + otError error = OT_ERROR_NONE; uint8_t idx; - OT_UNUSED_VARIABLE(aInstance); - otEXPECT_ACTION((idx = rfCoreFindShortSrcMatchIdx(aShortAddress)) != CC2652_SRC_MATCH_NONE, error = OT_ERROR_NO_ADDRESS); @@ -1553,11 +1557,11 @@ exit: */ otError otPlatRadioAddSrcMatchExtEntry(otInstance *aInstance, const otExtAddress *aExtAddress) { + OT_UNUSED_VARIABLE(aInstance); + otError error = OT_ERROR_NONE; uint8_t idx = rfCoreFindExtSrcMatchIdx((uint64_t *)aExtAddress); - OT_UNUSED_VARIABLE(aInstance); - if (idx == CC2652_SRC_MATCH_NONE) { /* the entry does not exist already, add it */ @@ -1586,11 +1590,11 @@ exit: */ otError otPlatRadioClearSrcMatchExtEntry(otInstance *aInstance, const otExtAddress *aExtAddress) { + OT_UNUSED_VARIABLE(aInstance); + otError error = OT_ERROR_NONE; uint8_t idx; - OT_UNUSED_VARIABLE(aInstance); - otEXPECT_ACTION((idx = rfCoreFindExtSrcMatchIdx((uint64_t *)aExtAddress)) != CC2652_SRC_MATCH_NONE, error = OT_ERROR_NO_ADDRESS); @@ -1670,6 +1674,7 @@ exit: bool otPlatRadioGetPromiscuous(otInstance *aInstance) { OT_UNUSED_VARIABLE(aInstance); + /* we are promiscuous if we are not filtering */ return sReceiveCmd.frameFiltOpt.frameFiltEn == 0; } @@ -1700,11 +1705,11 @@ void otPlatRadioSetPromiscuous(otInstance *aInstance, bool aEnable) */ void otPlatRadioGetIeeeEui64(otInstance *aInstance, uint8_t *aIeeeEui64) { + OT_UNUSED_VARIABLE(aInstance); + uint8_t * eui64; unsigned int i; - OT_UNUSED_VARIABLE(aInstance); - /* * The IEEE MAC address can be stored two places. We check the Customer * Configuration was not set before defaulting to the Factory @@ -1978,5 +1983,6 @@ void cc2652RadioProcess(otInstance *aInstance) int8_t otPlatRadioGetReceiveSensitivity(otInstance *aInstance) { OT_UNUSED_VARIABLE(aInstance); + return CC2652_RECEIVE_SENSITIVITY; } diff --git a/examples/platforms/da15000/alarm.c b/examples/platforms/da15000/alarm.c index b0d848c63..e7ded312e 100644 --- a/examples/platforms/da15000/alarm.c +++ b/examples/platforms/da15000/alarm.c @@ -90,6 +90,7 @@ void otPlatAlarmMilliStartAt(otInstance *aInstance, uint32_t t0, uint32_t dt) void otPlatAlarmMilliStop(otInstance *aInstance) { OT_UNUSED_VARIABLE(aInstance); + sIsRunning = false; hw_timer0_freeze(); } diff --git a/examples/platforms/da15000/misc.c b/examples/platforms/da15000/misc.c index cb9785fc1..e324f8efc 100644 --- a/examples/platforms/da15000/misc.c +++ b/examples/platforms/da15000/misc.c @@ -36,12 +36,14 @@ void otPlatReset(otInstance *aInstance) { OT_UNUSED_VARIABLE(aInstance); + hw_cpm_reboot_system(); } otPlatResetReason otPlatGetResetReason(otInstance *aInstance) { OT_UNUSED_VARIABLE(aInstance); + return OT_PLAT_RESET_REASON_POWER_ON; } diff --git a/examples/platforms/da15000/radio.c b/examples/platforms/da15000/radio.c index 87e727080..69f15983f 100644 --- a/examples/platforms/da15000/radio.c +++ b/examples/platforms/da15000/radio.c @@ -146,6 +146,7 @@ void da15000RadioInit(void) void otPlatRadioGetIeeeEui64(otInstance *aInstance, uint8_t *aIeeeEui64) { OT_UNUSED_VARIABLE(aInstance); + memcpy(aIeeeEui64, sEui64, RADIO_EUI64_TABLE_SIZE); } @@ -220,6 +221,7 @@ otError otPlatRadioDisable(otInstance *aInstance) bool otPlatRadioIsEnabled(otInstance *aInstance) { OT_UNUSED_VARIABLE(aInstance); + return (sRadioState != OT_RADIO_STATE_DISABLED); } @@ -406,6 +408,7 @@ void otPlatRadioClearSrcMatchExtEntries(otInstance *aInstance) otRadioFrame *otPlatRadioGetTransmitBuffer(otInstance *aInstance) { OT_UNUSED_VARIABLE(aInstance); + return &sTransmitFrame; } @@ -431,18 +434,21 @@ exit: int8_t otPlatRadioGetRssi(otInstance *aInstance) { OT_UNUSED_VARIABLE(aInstance); + return sRssiReal; } otRadioCaps otPlatRadioGetCaps(otInstance *aInstance) { OT_UNUSED_VARIABLE(aInstance); + return OT_RADIO_CAPS_ACK_TIMEOUT | OT_RADIO_CAPS_TRANSMIT_RETRIES | OT_RADIO_CAPS_CSMA_BACKOFF; } bool otPlatRadioGetPromiscuous(otInstance *aInstance) { OT_UNUSED_VARIABLE(aInstance); + return sRadioPromiscuous; } @@ -465,9 +471,10 @@ otError otPlatRadioEnergyScan(otInstance *aInstance, uint8_t aScanChannel, uint1 otError otPlatRadioGetTransmitPower(otInstance *aInstance, int8_t *aPower) { - otError error = OT_ERROR_NONE; OT_UNUSED_VARIABLE(aInstance); + otError error = OT_ERROR_NONE; + otEXPECT_ACTION(aPower != NULL, error = OT_ERROR_INVALID_ARGS); *aPower = sTxPower; @@ -609,5 +616,6 @@ exit: int8_t otPlatRadioGetReceiveSensitivity(otInstance *aInstance) { OT_UNUSED_VARIABLE(aInstance); + return DA15000_RECEIVE_SENSITIVITY; } diff --git a/examples/platforms/efr32/alarm.c b/examples/platforms/efr32/alarm.c index c0bf952df..9f5717321 100644 --- a/examples/platforms/efr32/alarm.c +++ b/examples/platforms/efr32/alarm.c @@ -94,6 +94,7 @@ uint32_t otPlatTimeGetXtalAccuracy(void) void otPlatAlarmMilliStartAt(otInstance *aInstance, uint32_t t0, uint32_t dt) { OT_UNUSED_VARIABLE(aInstance); + sAlarmT0 = t0; sAlarmDt = dt; sIsRunning = true; @@ -102,6 +103,7 @@ void otPlatAlarmMilliStartAt(otInstance *aInstance, uint32_t t0, uint32_t dt) void otPlatAlarmMilliStop(otInstance *aInstance) { OT_UNUSED_VARIABLE(aInstance); + sIsRunning = false; } diff --git a/examples/platforms/efr32/misc.c b/examples/platforms/efr32/misc.c index 901e861f7..23c1510fb 100644 --- a/examples/platforms/efr32/misc.c +++ b/examples/platforms/efr32/misc.c @@ -55,10 +55,10 @@ void otPlatReset(otInstance *aInstance) otPlatResetReason otPlatGetResetReason(otInstance *aInstance) { - otPlatResetReason reason; - OT_UNUSED_VARIABLE(aInstance); + otPlatResetReason reason; + if (sResetCause & RMU_RSTCAUSE_PORST) { reason = OT_PLAT_RESET_REASON_POWER_ON; diff --git a/examples/platforms/efr32/radio.c b/examples/platforms/efr32/radio.c index 144ee4e43..92210bec5 100644 --- a/examples/platforms/efr32/radio.c +++ b/examples/platforms/efr32/radio.c @@ -207,11 +207,11 @@ void efr32RadioDeinit(void) void otPlatRadioGetIeeeEui64(otInstance *aInstance, uint8_t *aIeeeEui64) { + OT_UNUSED_VARIABLE(aInstance); + uint64_t eui64; uint8_t *eui64Ptr = NULL; - OT_UNUSED_VARIABLE(aInstance); - eui64 = SYSTEM_GetUnique(); eui64Ptr = (uint8_t *)&eui64; @@ -223,10 +223,10 @@ void otPlatRadioGetIeeeEui64(otInstance *aInstance, uint8_t *aIeeeEui64) void otPlatRadioSetPanId(otInstance *aInstance, uint16_t aPanId) { - RAIL_Status_t status; - OT_UNUSED_VARIABLE(aInstance); + RAIL_Status_t status; + otLogInfoPlat("PANID=%X", aPanId); sPanId = aPanId; @@ -236,10 +236,10 @@ void otPlatRadioSetPanId(otInstance *aInstance, uint16_t aPanId) void otPlatRadioSetExtendedAddress(otInstance *aInstance, const otExtAddress *aAddress) { - RAIL_Status_t status; - OT_UNUSED_VARIABLE(aInstance); + RAIL_Status_t status; + otLogInfoPlat("ExtAddr=%X%X%X%X%X%X%X%X", aAddress->m8[7], aAddress->m8[6], aAddress->m8[5], aAddress->m8[4], aAddress->m8[3], aAddress->m8[2], aAddress->m8[1], aAddress->m8[0]); @@ -249,10 +249,10 @@ void otPlatRadioSetExtendedAddress(otInstance *aInstance, const otExtAddress *aA void otPlatRadioSetShortAddress(otInstance *aInstance, uint16_t aAddress) { - RAIL_Status_t status; - OT_UNUSED_VARIABLE(aInstance); + RAIL_Status_t status; + otLogInfoPlat("ShortAddr=%X", aAddress); status = RAIL_IEEE802154_SetShortAddress(sRailHandle, aAddress, 0); @@ -262,6 +262,7 @@ void otPlatRadioSetShortAddress(otInstance *aInstance, uint16_t aAddress) bool otPlatRadioIsEnabled(otInstance *aInstance) { OT_UNUSED_VARIABLE(aInstance); + return (sState != OT_RADIO_STATE_DISABLED); } @@ -289,10 +290,10 @@ exit: otError otPlatRadioSleep(otInstance *aInstance) { - otError error = OT_ERROR_NONE; - OT_UNUSED_VARIABLE(aInstance); + otError error = OT_ERROR_NONE; + otEXPECT_ACTION((sState != OT_RADIO_STATE_TRANSMIT) && (sState != OT_RADIO_STATE_DISABLED), error = OT_ERROR_INVALID_STATE); @@ -307,11 +308,11 @@ exit: otError otPlatRadioReceive(otInstance *aInstance, uint8_t aChannel) { + OT_UNUSED_VARIABLE(aInstance); + otError error = OT_ERROR_NONE; RAIL_Status_t status; - OT_UNUSED_VARIABLE(aInstance); - otEXPECT_ACTION(sState != OT_RADIO_STATE_DISABLED, error = OT_ERROR_INVALID_STATE); status = RAIL_StartRx(sRailHandle, aChannel, NULL); @@ -366,33 +367,37 @@ exit: otRadioFrame *otPlatRadioGetTransmitBuffer(otInstance *aInstance) { OT_UNUSED_VARIABLE(aInstance); + return &sTransmitFrame; } int8_t otPlatRadioGetRssi(otInstance *aInstance) { OT_UNUSED_VARIABLE(aInstance); + return (int8_t)(RAIL_GetAverageRssi(sRailHandle) >> 2); } otRadioCaps otPlatRadioGetCaps(otInstance *aInstance) { OT_UNUSED_VARIABLE(aInstance); + return OT_RADIO_CAPS_ACK_TIMEOUT | OT_RADIO_CAPS_CSMA_BACKOFF; } bool otPlatRadioGetPromiscuous(otInstance *aInstance) { OT_UNUSED_VARIABLE(aInstance); + return sPromiscuous; } void otPlatRadioSetPromiscuous(otInstance *aInstance, bool aEnable) { - RAIL_Status_t status; - OT_UNUSED_VARIABLE(aInstance); + RAIL_Status_t status; + sPromiscuous = aEnable; status = RAIL_IEEE802154_SetPromiscuousMode(sRailHandle, aEnable); assert(status == RAIL_STATUS_NO_ERROR); @@ -510,11 +515,11 @@ void otPlatRadioEnableSrcMatch(otInstance *aInstance, bool aEnable) otError otPlatRadioAddSrcMatchShortEntry(otInstance *aInstance, const uint16_t aShortAddress) { + OT_UNUSED_VARIABLE(aInstance); + otError error = OT_ERROR_NONE; int8_t entry = -1; - OT_UNUSED_VARIABLE(aInstance); - entry = findSrcMatchAvailEntry(true); otLogDebgPlat("Add ShortAddr entry: %d", entry); @@ -528,11 +533,11 @@ exit: otError otPlatRadioAddSrcMatchExtEntry(otInstance *aInstance, const otExtAddress *aExtAddress) { + OT_UNUSED_VARIABLE(aInstance); + otError error = OT_ERROR_NONE; int8_t entry = -1; - OT_UNUSED_VARIABLE(aInstance); - entry = findSrcMatchAvailEntry(false); otLogDebgPlat("Add ExtAddr entry: %d", entry); @@ -546,11 +551,11 @@ exit: otError otPlatRadioClearSrcMatchShortEntry(otInstance *aInstance, const uint16_t aShortAddress) { + OT_UNUSED_VARIABLE(aInstance); + otError error = OT_ERROR_NONE; int8_t entry = -1; - OT_UNUSED_VARIABLE(aInstance); - entry = findSrcMatchShortEntry(aShortAddress); otLogDebgPlat("Clear ShortAddr entry: %d", entry); @@ -564,11 +569,11 @@ exit: otError otPlatRadioClearSrcMatchExtEntry(otInstance *aInstance, const otExtAddress *aExtAddress) { + OT_UNUSED_VARIABLE(aInstance); + otError error = OT_ERROR_NONE; int8_t entry = -1; - OT_UNUSED_VARIABLE(aInstance); - entry = findSrcMatchExtEntry(aExtAddress); otLogDebgPlat("Clear ExtAddr entry: %d", entry); @@ -773,6 +778,7 @@ otError otPlatRadioEnergyScan(otInstance *aInstance, uint8_t aScanChannel, uint1 OT_UNUSED_VARIABLE(aInstance); OT_UNUSED_VARIABLE(aScanChannel); OT_UNUSED_VARIABLE(aScanDuration); + return OT_ERROR_NOT_IMPLEMENTED; } @@ -810,10 +816,10 @@ void efr32RadioProcess(otInstance *aInstance) otError otPlatRadioGetTransmitPower(otInstance *aInstance, int8_t *aPower) { - otError error = OT_ERROR_NONE; - OT_UNUSED_VARIABLE(aInstance); + otError error = OT_ERROR_NONE; + otEXPECT_ACTION(aPower != NULL, error = OT_ERROR_INVALID_ARGS); *aPower = (int8_t)(RAIL_GetTxPowerDbm(sRailHandle) / 10); @@ -823,10 +829,10 @@ exit: otError otPlatRadioSetTransmitPower(otInstance *aInstance, int8_t aPower) { - RAIL_Status_t status; - OT_UNUSED_VARIABLE(aInstance); + RAIL_Status_t status; + status = RAIL_SetTxPowerDbm(sRailHandle, ((RAIL_TxPower_t)aPower) * 10); assert(status == RAIL_STATUS_NO_ERROR); @@ -836,5 +842,6 @@ otError otPlatRadioSetTransmitPower(otInstance *aInstance, int8_t aPower) int8_t otPlatRadioGetReceiveSensitivity(otInstance *aInstance) { OT_UNUSED_VARIABLE(aInstance); + return EFR32_RECEIVE_SENSITIVITY; } diff --git a/examples/platforms/emsk/alarm.c b/examples/platforms/emsk/alarm.c index 3c119394a..74f043932 100644 --- a/examples/platforms/emsk/alarm.c +++ b/examples/platforms/emsk/alarm.c @@ -54,6 +54,7 @@ uint32_t otPlatAlarmMilliGetNow(void) void otPlatAlarmMilliStartAt(otInstance *aInstance, uint32_t t0, uint32_t dt) { OT_UNUSED_VARIABLE(aInstance); + expires = t0 + dt; sIsRunning = true; } @@ -61,6 +62,7 @@ void otPlatAlarmMilliStartAt(otInstance *aInstance, uint32_t t0, uint32_t dt) void otPlatAlarmMilliStop(otInstance *aInstance) { OT_UNUSED_VARIABLE(aInstance); + sIsRunning = false; } diff --git a/examples/platforms/emsk/misc.c b/examples/platforms/emsk/misc.c index d4ff19c41..48ad82a27 100755 --- a/examples/platforms/emsk/misc.c +++ b/examples/platforms/emsk/misc.c @@ -31,14 +31,16 @@ void otPlatReset(otInstance *aInstance) { - // Default OT_UNUSED_VARIABLE(aInstance); + + // Default mrf24j40_hard_reset(); } otPlatResetReason otPlatGetResetReason(otInstance *aInstance) { OT_UNUSED_VARIABLE(aInstance); + // TODO: Write me! return OT_PLAT_RESET_REASON_POWER_ON; } diff --git a/examples/platforms/emsk/radio.c b/examples/platforms/emsk/radio.c index 85b95fa6e..797d34969 100644 --- a/examples/platforms/emsk/radio.c +++ b/examples/platforms/emsk/radio.c @@ -240,10 +240,10 @@ void otPlatRadioGetIeeeEui64(otInstance *aInstance, uint8_t *aIeeeEui64) void otPlatRadioSetPanId(otInstance *aInstance, uint16_t panid) { - uint8_t pan[2]; - OT_UNUSED_VARIABLE(aInstance); + uint8_t pan[2]; + pan[0] = (uint8_t)(panid & 0xFF); pan[1] = (uint8_t)(panid >> 8); mrf24j40_set_pan(pan); @@ -252,16 +252,17 @@ void otPlatRadioSetPanId(otInstance *aInstance, uint16_t panid) void otPlatRadioSetExtendedAddress(otInstance *aInstance, const otExtAddress *address) { OT_UNUSED_VARIABLE(aInstance); + /* cast to remove const, FIXME: perhaps the bsp library should be updated? */ mrf24j40_set_eui((uint8_t *)(address->m8)); } void otPlatRadioSetShortAddress(otInstance *aInstance, uint16_t address) { - uint8_t addr[2]; - OT_UNUSED_VARIABLE(aInstance); + uint8_t addr[2]; + addr[0] = (uint8_t)(address & 0xFF); addr[1] = (uint8_t)(address >> 8); mrf24j40_set_short_addr(addr); @@ -331,6 +332,7 @@ void emskRadioInit(void) bool otPlatRadioIsEnabled(otInstance *aInstance) { OT_UNUSED_VARIABLE(aInstance); + return (sState != OT_RADIO_STATE_DISABLED); } @@ -356,10 +358,10 @@ otError otPlatRadioDisable(otInstance *aInstance) otError otPlatRadioSleep(otInstance *aInstance) { - otError error = OT_ERROR_INVALID_STATE; - OT_UNUSED_VARIABLE(aInstance); + otError error = OT_ERROR_INVALID_STATE; + if (sState == OT_RADIO_STATE_SLEEP || sState == OT_RADIO_STATE_RECEIVE) { error = OT_ERROR_NONE; @@ -372,10 +374,10 @@ otError otPlatRadioSleep(otInstance *aInstance) otError otPlatRadioReceive(otInstance *aInstance, uint8_t aChannel) { - otError error = OT_ERROR_INVALID_STATE; - OT_UNUSED_VARIABLE(aInstance); + otError error = OT_ERROR_INVALID_STATE; + if (sState != OT_RADIO_STATE_DISABLED) { error = OT_ERROR_NONE; @@ -390,11 +392,11 @@ otError otPlatRadioReceive(otInstance *aInstance, uint8_t aChannel) otError otPlatRadioTransmit(otInstance *aInstance, otRadioFrame *aFrame) { - otError error = OT_ERROR_INVALID_STATE; - OT_UNUSED_VARIABLE(aInstance); OT_UNUSED_VARIABLE(aFrame); + otError error = OT_ERROR_INVALID_STATE; + if (sState == OT_RADIO_STATE_RECEIVE) { error = OT_ERROR_NONE; @@ -407,24 +409,28 @@ otError otPlatRadioTransmit(otInstance *aInstance, otRadioFrame *aFrame) otRadioFrame *otPlatRadioGetTransmitBuffer(otInstance *aInstance) { OT_UNUSED_VARIABLE(aInstance); + return &sTransmitFrame; } int8_t otPlatRadioGetRssi(otInstance *aInstance) { OT_UNUSED_VARIABLE(aInstance); + return 0; } otRadioCaps otPlatRadioGetCaps(otInstance *aInstance) { OT_UNUSED_VARIABLE(aInstance); + return OT_RADIO_CAPS_NONE; } bool otPlatRadioGetPromiscuous(otInstance *aInstance) { OT_UNUSED_VARIABLE(aInstance); + return (bool)(mrf24j40_read_short_ctrl_reg(MRF24J40_RXMCR) & MRF24J40_PROMI); } @@ -432,6 +438,7 @@ bool otPlatRadioGetPromiscuous(otInstance *aInstance) void otPlatRadioSetPromiscuous(otInstance *aInstance, bool aEnable) { OT_UNUSED_VARIABLE(aInstance); + mrf24j40_set_promiscuous(~aEnable); } @@ -637,6 +644,7 @@ otError otPlatRadioAddSrcMatchShortEntry(otInstance *aInstance, const uint16_t a { OT_UNUSED_VARIABLE(aInstance); OT_UNUSED_VARIABLE(aShortAddress); + return OT_ERROR_NONE; } @@ -644,6 +652,7 @@ otError otPlatRadioAddSrcMatchExtEntry(otInstance *aInstance, const otExtAddress { OT_UNUSED_VARIABLE(aInstance); OT_UNUSED_VARIABLE(aExtAddress); + return OT_ERROR_NONE; } @@ -651,6 +660,7 @@ otError otPlatRadioClearSrcMatchShortEntry(otInstance *aInstance, const uint16_t { OT_UNUSED_VARIABLE(aInstance); OT_UNUSED_VARIABLE(aShortAddress); + return OT_ERROR_NONE; } @@ -658,6 +668,7 @@ otError otPlatRadioClearSrcMatchExtEntry(otInstance *aInstance, const otExtAddre { OT_UNUSED_VARIABLE(aInstance); OT_UNUSED_VARIABLE(aExtAddress); + return OT_ERROR_NONE; } @@ -676,6 +687,7 @@ otError otPlatRadioEnergyScan(otInstance *aInstance, uint8_t aScanChannel, uint1 OT_UNUSED_VARIABLE(aInstance); OT_UNUSED_VARIABLE(aScanChannel); OT_UNUSED_VARIABLE(aScanDuration); + return OT_ERROR_NOT_IMPLEMENTED; } @@ -684,6 +696,7 @@ otError otPlatRadioGetTransmitPower(otInstance *aInstance, int8_t *aPower) // TODO: Create a proper implementation for this driver. OT_UNUSED_VARIABLE(aInstance); OT_UNUSED_VARIABLE(aPower); + return OT_ERROR_NOT_IMPLEMENTED; } @@ -692,11 +705,13 @@ otError otPlatRadioSetTransmitPower(otInstance *aInstance, int8_t aPower) // TODO: Create a proper implementation for this driver. OT_UNUSED_VARIABLE(aInstance); OT_UNUSED_VARIABLE(aPower); + return OT_ERROR_NOT_IMPLEMENTED; } int8_t otPlatRadioGetReceiveSensitivity(otInstance *aInstance) { OT_UNUSED_VARIABLE(aInstance); + return EMSK_RECEIVE_SENSITIVITY; } diff --git a/examples/platforms/gp712/alarm.c b/examples/platforms/gp712/alarm.c index b3cac40ab..d3c8c0ebd 100644 --- a/examples/platforms/gp712/alarm.c +++ b/examples/platforms/gp712/alarm.c @@ -57,6 +57,7 @@ static void qorvoAlarmFired(void *aInstance) void otPlatAlarmMilliStartAt(otInstance *aInstance, uint32_t t0, uint32_t dt) { OT_UNUSED_VARIABLE(t0); + qorvoAlarmUnScheduleEventArg((qorvoAlarmCallback_t)qorvoAlarmFired, aInstance); qorvoAlarmScheduleEventArg(dt * 1000, qorvoAlarmFired, aInstance); } diff --git a/examples/platforms/gp712/flash.c b/examples/platforms/gp712/flash.c index abf544296..e1b95dd27 100644 --- a/examples/platforms/gp712/flash.c +++ b/examples/platforms/gp712/flash.c @@ -120,6 +120,7 @@ exit: otError utilsFlashStatusWait(uint32_t aTimeout) { OT_UNUSED_VARIABLE(aTimeout); + return OT_ERROR_NONE; } diff --git a/examples/platforms/gp712/logging.c b/examples/platforms/gp712/logging.c index ef7f4b6f2..f0a3a98b9 100644 --- a/examples/platforms/gp712/logging.c +++ b/examples/platforms/gp712/logging.c @@ -92,13 +92,13 @@ int PlatOtLogLevelToSysLogLevel(otLogLevel aLogLevel) OT_TOOL_WEAK void otPlatLog(otLogLevel aLogLevel, otLogRegion aLogRegion, const char *aFormat, ...) { + OT_UNUSED_VARIABLE(aLogRegion); + char logString[512]; unsigned int offset; int charsWritten; va_list args; - OT_UNUSED_VARIABLE(aLogRegion); - offset = 0; va_start(args, aFormat); diff --git a/examples/platforms/gp712/misc.c b/examples/platforms/gp712/misc.c index 97b903a01..15a297c25 100644 --- a/examples/platforms/gp712/misc.c +++ b/examples/platforms/gp712/misc.c @@ -44,10 +44,10 @@ extern void platformUartRestore(void); void otPlatReset(otInstance *aInstance) { - char *argv[gArgumentsCount + 1]; - OT_UNUSED_VARIABLE(aInstance); + char *argv[gArgumentsCount + 1]; + for (int i = 0; i < gArgumentsCount; ++i) { argv[i] = gArguments[i]; @@ -66,6 +66,7 @@ void otPlatReset(otInstance *aInstance) otPlatResetReason otPlatGetResetReason(otInstance *aInstance) { OT_UNUSED_VARIABLE(aInstance); + return OT_PLAT_RESET_REASON_POWER_ON; } diff --git a/examples/platforms/gp712/radio.c b/examples/platforms/gp712/radio.c index 067cb5b21..c64a449f6 100644 --- a/examples/platforms/gp712/radio.c +++ b/examples/platforms/gp712/radio.c @@ -83,12 +83,14 @@ static int8_t sLastReceivedPower = 127; void otPlatRadioGetIeeeEui64(otInstance *aInstance, uint8_t *aIeeeEui64) { OT_UNUSED_VARIABLE(aInstance); + qorvoRadioGetIeeeEui64(aIeeeEui64); } void otPlatRadioSetPanId(otInstance *aInstance, uint16_t panid) { OT_UNUSED_VARIABLE(aInstance); + qorvoRadioSetPanId(panid); otCachedSettings.panid = panid; } @@ -96,18 +98,21 @@ void otPlatRadioSetPanId(otInstance *aInstance, uint16_t panid) void otPlatRadioSetExtendedAddress(otInstance *aInstance, const otExtAddress *address) { OT_UNUSED_VARIABLE(aInstance); + qorvoRadioSetExtendedAddress(address->m8); } void otPlatRadioSetShortAddress(otInstance *aInstance, uint16_t address) { OT_UNUSED_VARIABLE(aInstance); + qorvoRadioSetShortAddress(address); } bool otPlatRadioIsEnabled(otInstance *aInstance) { OT_UNUSED_VARIABLE(aInstance); + return (sState != OT_RADIO_STATE_DISABLED); } @@ -143,10 +148,10 @@ exit: otError otPlatRadioSleep(otInstance *aInstance) { - otError error = OT_ERROR_INVALID_STATE; - OT_UNUSED_VARIABLE(aInstance); + otError error = OT_ERROR_INVALID_STATE; + if (sState == OT_RADIO_STATE_RECEIVE) { qorvoRadioSetRxOnWhenIdle(false); @@ -227,24 +232,28 @@ void cbQorvoRadioReceiveDone(otRadioFrame *aPacket, otError aError) otRadioFrame *otPlatRadioGetTransmitBuffer(otInstance *aInstance) { OT_UNUSED_VARIABLE(aInstance); + return &sTransmitFrame; } int8_t otPlatRadioGetRssi(otInstance *aInstance) { OT_UNUSED_VARIABLE(aInstance); + return sLastReceivedPower; } otRadioCaps otPlatRadioGetCaps(otInstance *aInstance) { OT_UNUSED_VARIABLE(aInstance); + return OT_RADIO_CAPS_ACK_TIMEOUT | OT_RADIO_CAPS_ENERGY_SCAN | OT_RADIO_CAPS_TRANSMIT_RETRIES; } bool otPlatRadioGetPromiscuous(otInstance *aInstance) { OT_UNUSED_VARIABLE(aInstance); + return false; } @@ -257,36 +266,42 @@ void otPlatRadioSetPromiscuous(otInstance *aInstance, bool aEnable) void otPlatRadioEnableSrcMatch(otInstance *aInstance, bool aEnable) { OT_UNUSED_VARIABLE(aInstance); + qorvoRadioEnableSrcMatch(aEnable); } otError otPlatRadioAddSrcMatchShortEntry(otInstance *aInstance, const uint16_t aShortAddress) { OT_UNUSED_VARIABLE(aInstance); + return qorvoRadioAddSrcMatchShortEntry(aShortAddress, otCachedSettings.panid); } otError otPlatRadioAddSrcMatchExtEntry(otInstance *aInstance, const otExtAddress *aExtAddress) { OT_UNUSED_VARIABLE(aInstance); + return qorvoRadioAddSrcMatchExtEntry(aExtAddress->m8, otCachedSettings.panid); } otError otPlatRadioClearSrcMatchShortEntry(otInstance *aInstance, const uint16_t aShortAddress) { OT_UNUSED_VARIABLE(aInstance); + return qorvoRadioClearSrcMatchShortEntry(aShortAddress, otCachedSettings.panid); } otError otPlatRadioClearSrcMatchExtEntry(otInstance *aInstance, const otExtAddress *aExtAddress) { OT_UNUSED_VARIABLE(aInstance); + return qorvoRadioClearSrcMatchExtEntry(aExtAddress->m8, otCachedSettings.panid); } void otPlatRadioClearSrcMatchShortEntries(otInstance *aInstance) { OT_UNUSED_VARIABLE(aInstance); + /* clear both short and extended addresses here */ qorvoRadioClearSrcMatchEntries(); } @@ -294,6 +309,7 @@ void otPlatRadioClearSrcMatchShortEntries(otInstance *aInstance) void otPlatRadioClearSrcMatchExtEntries(otInstance *aInstance) { OT_UNUSED_VARIABLE(aInstance); + /* not implemented */ /* assumes clearing of short and extended entries is done simultaniously by the openthread stack */ } @@ -301,6 +317,7 @@ void otPlatRadioClearSrcMatchExtEntries(otInstance *aInstance) otError otPlatRadioEnergyScan(otInstance *aInstance, uint8_t aScanChannel, uint16_t aScanDuration) { OT_UNUSED_VARIABLE(aInstance); + sScanstate = 1; return qorvoRadioEnergyScan(aScanChannel, aScanDuration); } @@ -316,6 +333,7 @@ otError otPlatRadioGetTransmitPower(otInstance *aInstance, int8_t *aPower) // TODO: Create a proper implementation for this driver. OT_UNUSED_VARIABLE(aInstance); OT_UNUSED_VARIABLE(aPower); + return OT_ERROR_NOT_IMPLEMENTED; } @@ -324,11 +342,13 @@ otError otPlatRadioSetTransmitPower(otInstance *aInstance, int8_t aPower) // TODO: Create a proper implementation for this driver. OT_UNUSED_VARIABLE(aInstance); OT_UNUSED_VARIABLE(aPower); + return OT_ERROR_NOT_IMPLEMENTED; } int8_t otPlatRadioGetReceiveSensitivity(otInstance *aInstance) { OT_UNUSED_VARIABLE(aInstance); + return GP712_RECEIVE_SENSITIVITY; } diff --git a/examples/platforms/gp712/uart-posix.c b/examples/platforms/gp712/uart-posix.c index f7e4b5b52..7f80c203c 100644 --- a/examples/platforms/gp712/uart-posix.c +++ b/examples/platforms/gp712/uart-posix.c @@ -78,6 +78,7 @@ void platformDummy(void *dummyPointer) static void cbKeyPressed(uint8_t Param) { OT_UNUSED_VARIABLE(Param); + qorvoAlarmScheduleEventArg(0, platformDummy, (void *)&s_in_fd); } diff --git a/examples/platforms/gp712/uart-socket.c b/examples/platforms/gp712/uart-socket.c index e8a73bc40..36b9f1c43 100644 --- a/examples/platforms/gp712/uart-socket.c +++ b/examples/platforms/gp712/uart-socket.c @@ -188,6 +188,7 @@ exit: void PlatSocketRxSignaled(uint8_t id) { OT_UNUSED_VARIABLE(id); + //Dummy callback function to flush pipe uint8_t readChar; //Remove trigger byte from pipe diff --git a/examples/platforms/kw41z/alarm.c b/examples/platforms/kw41z/alarm.c index 8d26804f5..ef0f63774 100644 --- a/examples/platforms/kw41z/alarm.c +++ b/examples/platforms/kw41z/alarm.c @@ -80,12 +80,14 @@ void kw41zAlarmProcess(otInstance *aInstance) void otPlatAlarmMilliStartAt(otInstance *aInstance, uint32_t aT0, uint32_t aDt) { OT_UNUSED_VARIABLE(aInstance); + sAlarmTime = aT0 + aDt; } void otPlatAlarmMilliStop(otInstance *aInstance) { OT_UNUSED_VARIABLE(aInstance); + sAlarmTime = 0; } diff --git a/examples/platforms/kw41z/misc.c b/examples/platforms/kw41z/misc.c index 2dfba31ff..9eab7d265 100644 --- a/examples/platforms/kw41z/misc.c +++ b/examples/platforms/kw41z/misc.c @@ -43,10 +43,10 @@ void otPlatReset(otInstance *aInstance) otPlatResetReason otPlatGetResetReason(otInstance *aInstance) { - otPlatResetReason reason; - OT_UNUSED_VARIABLE(aInstance); + otPlatResetReason reason; + if (RCM->SRS0 & RCM_SRS0_POR_MASK) { reason = OT_PLAT_RESET_REASON_POWER_ON; diff --git a/examples/platforms/kw41z/radio.c b/examples/platforms/kw41z/radio.c index 1a9fbf3ce..c007d65ef 100644 --- a/examples/platforms/kw41z/radio.c +++ b/examples/platforms/kw41z/radio.c @@ -127,16 +127,17 @@ static bool rf_process_rx_frame(void); otRadioState otPlatRadioGetState(otInstance *aInstance) { OT_UNUSED_VARIABLE(aInstance); + return sState; } void otPlatRadioGetIeeeEui64(otInstance *aInstance, uint8_t *aIeeeEui64) { + OT_UNUSED_VARIABLE(aInstance); + uint32_t addrLo; uint32_t addrHi; - OT_UNUSED_VARIABLE(aInstance); - if ((RSIM->MAC_LSB == 0xffffffff) && (RSIM->MAC_MSB == 0xff)) { addrLo = SIM->UIDL; @@ -163,11 +164,11 @@ void otPlatRadioSetPanId(otInstance *aInstance, uint16_t aPanId) void otPlatRadioSetExtendedAddress(otInstance *aInstance, const otExtAddress *aExtAddress) { + OT_UNUSED_VARIABLE(aInstance); + uint32_t addrLo; uint32_t addrHi; - OT_UNUSED_VARIABLE(aInstance); - memcpy(&addrLo, aExtAddress->m8, sizeof(addrLo)); memcpy(&addrHi, aExtAddress->m8 + sizeof(addrLo), sizeof(addrHi)); @@ -213,15 +214,16 @@ exit: bool otPlatRadioIsEnabled(otInstance *aInstance) { OT_UNUSED_VARIABLE(aInstance); + return sState != OT_RADIO_STATE_DISABLED; } otError otPlatRadioSleep(otInstance *aInstance) { - otError status = OT_ERROR_NONE; - OT_UNUSED_VARIABLE(aInstance); + otError status = OT_ERROR_NONE; + otEXPECT_ACTION(((sState != OT_RADIO_STATE_TRANSMIT) && (sState != OT_RADIO_STATE_DISABLED)), status = OT_ERROR_INVALID_STATE); @@ -234,10 +236,10 @@ exit: otError otPlatRadioReceive(otInstance *aInstance, uint8_t aChannel) { - otError status = OT_ERROR_NONE; - OT_UNUSED_VARIABLE(aInstance); + otError status = OT_ERROR_NONE; + otEXPECT_ACTION(((sState != OT_RADIO_STATE_TRANSMIT) && (sState != OT_RADIO_STATE_DISABLED)), status = OT_ERROR_INVALID_STATE); @@ -283,46 +285,46 @@ void otPlatRadioEnableSrcMatch(otInstance *aInstance, bool aEnable) otError otPlatRadioAddSrcMatchShortEntry(otInstance *aInstance, const uint16_t aShortAddress) { - uint16_t checksum = sPanId + aShortAddress; - OT_UNUSED_VARIABLE(aInstance); + uint16_t checksum = sPanId + aShortAddress; + return rf_add_addr_table_entry(checksum, false); } otError otPlatRadioAddSrcMatchExtEntry(otInstance *aInstance, const otExtAddress *aExtAddress) { - uint16_t checksum = rf_get_addr_checksum((uint8_t *)aExtAddress->m8, true, sPanId); - OT_UNUSED_VARIABLE(aInstance); + uint16_t checksum = rf_get_addr_checksum((uint8_t *)aExtAddress->m8, true, sPanId); + return rf_add_addr_table_entry(checksum, true); } otError otPlatRadioClearSrcMatchShortEntry(otInstance *aInstance, const uint16_t aShortAddress) { - uint16_t checksum = sPanId + aShortAddress; - OT_UNUSED_VARIABLE(aInstance); + uint16_t checksum = sPanId + aShortAddress; + return rf_remove_addr_table_entry(checksum); } otError otPlatRadioClearSrcMatchExtEntry(otInstance *aInstance, const otExtAddress *aExtAddress) { - uint16_t checksum = rf_get_addr_checksum((uint8_t *)aExtAddress->m8, true, sPanId); - OT_UNUSED_VARIABLE(aInstance); + uint16_t checksum = rf_get_addr_checksum((uint8_t *)aExtAddress->m8, true, sPanId); + return rf_remove_addr_table_entry(checksum); } void otPlatRadioClearSrcMatchShortEntries(otInstance *aInstance) { - uint32_t i; - OT_UNUSED_VARIABLE(aInstance); + uint32_t i; + for (i = 0; i < RADIO_CONFIG_SRC_MATCH_ENTRY_NUM; i++) { /* Optimization: sExtSrcAddrBitmap[i / 8] & (1 << (i % 8)) */ @@ -335,10 +337,10 @@ void otPlatRadioClearSrcMatchShortEntries(otInstance *aInstance) void otPlatRadioClearSrcMatchExtEntries(otInstance *aInstance) { - uint32_t i; - OT_UNUSED_VARIABLE(aInstance); + uint32_t i; + for (i = 0; i < RADIO_CONFIG_SRC_MATCH_ENTRY_NUM; i++) { /* Optimization: sExtSrcAddrBitmap[i / 8] & (1 << (i % 8))*/ @@ -352,6 +354,7 @@ void otPlatRadioClearSrcMatchExtEntries(otInstance *aInstance) otRadioFrame *otPlatRadioGetTransmitBuffer(otInstance *aInstance) { OT_UNUSED_VARIABLE(aInstance); + return &sTxFrame; } @@ -421,18 +424,21 @@ exit: int8_t otPlatRadioGetRssi(otInstance *aInstance) { OT_UNUSED_VARIABLE(aInstance); + return (ZLL->LQI_AND_RSSI & ZLL_LQI_AND_RSSI_RSSI_MASK) >> ZLL_LQI_AND_RSSI_RSSI_SHIFT; } otRadioCaps otPlatRadioGetCaps(otInstance *aInstance) { OT_UNUSED_VARIABLE(aInstance); + return OT_RADIO_CAPS_ACK_TIMEOUT | OT_RADIO_CAPS_ENERGY_SCAN; } bool otPlatRadioGetPromiscuous(otInstance *aInstance) { OT_UNUSED_VARIABLE(aInstance); + return (ZLL->PHY_CTRL & ZLL_PHY_CTRL_PROMISCUOUS_MASK) == ZLL_PHY_CTRL_PROMISCUOUS_MASK; } @@ -456,11 +462,11 @@ void otPlatRadioSetPromiscuous(otInstance *aInstance, bool aEnable) otError otPlatRadioEnergyScan(otInstance *aInstance, uint8_t aScanChannel, uint16_t aScanDuration) { + OT_UNUSED_VARIABLE(aInstance); + otError status = OT_ERROR_NONE; uint32_t timeout; - OT_UNUSED_VARIABLE(aInstance); - otEXPECT_ACTION(((sState != OT_RADIO_STATE_TRANSMIT) && (sState != OT_RADIO_STATE_DISABLED)), status = OT_ERROR_INVALID_STATE); @@ -512,6 +518,7 @@ otError otPlatRadioSetTransmitPower(otInstance *aInstance, int8_t aPower) int8_t otPlatRadioGetReceiveSensitivity(otInstance *aInstance) { OT_UNUSED_VARIABLE(aInstance); + return -100; } diff --git a/examples/platforms/kw41z/system.c b/examples/platforms/kw41z/system.c index e751006dd..8e0dc274a 100644 --- a/examples/platforms/kw41z/system.c +++ b/examples/platforms/kw41z/system.c @@ -44,12 +44,12 @@ otInstance *sInstance; void otSysInit(int argc, char *argv[]) { - uint32_t temp, tempTrim; - uint8_t revId; - OT_UNUSED_VARIABLE(argc); OT_UNUSED_VARIABLE(argv); + uint32_t temp, tempTrim; + uint8_t revId; + /* enable clock for PORTs */ CLOCK_EnableClock(kCLOCK_PortA); CLOCK_EnableClock(kCLOCK_PortB); diff --git a/examples/platforms/nrf52840/misc.c b/examples/platforms/nrf52840/misc.c index 09ab691e2..4d57bf4d7 100644 --- a/examples/platforms/nrf52840/misc.c +++ b/examples/platforms/nrf52840/misc.c @@ -71,6 +71,7 @@ void nrf5MiscDeinit(void) void otPlatReset(otInstance *aInstance) { OT_UNUSED_VARIABLE(aInstance); + #if OPENTHREAD_PLATFORM_USE_PSEUDO_RESET gPlatformPseudoResetWasRequested = true; sResetReason = POWER_RESETREAS_SREQ_Msk; diff --git a/examples/platforms/nrf52840/radio.c b/examples/platforms/nrf52840/radio.c index 69271b145..f152c4560 100644 --- a/examples/platforms/nrf52840/radio.c +++ b/examples/platforms/nrf52840/radio.c @@ -321,10 +321,10 @@ otError otPlatRadioSleep(otInstance *aInstance) otError otPlatRadioReceive(otInstance *aInstance, uint8_t aChannel) { - bool result; - OT_UNUSED_VARIABLE(aInstance); + bool result; + nrf_802154_channel_set(aChannel); nrf_802154_tx_power_set(sDefaultTxPower); result = nrf_802154_receive(); @@ -407,10 +407,10 @@ void otPlatRadioEnableSrcMatch(otInstance *aInstance, bool aEnable) otError otPlatRadioAddSrcMatchShortEntry(otInstance *aInstance, const uint16_t aShortAddress) { - otError error; - OT_UNUSED_VARIABLE(aInstance); + otError error; + uint8_t shortAddress[SHORT_ADDRESS_SIZE]; convertShortAddress(shortAddress, aShortAddress); @@ -428,10 +428,10 @@ otError otPlatRadioAddSrcMatchShortEntry(otInstance *aInstance, const uint16_t a otError otPlatRadioAddSrcMatchExtEntry(otInstance *aInstance, const otExtAddress *aExtAddress) { - otError error; - OT_UNUSED_VARIABLE(aInstance); + otError error; + if (nrf_802154_pending_bit_for_addr_set(aExtAddress->m8, true)) { error = OT_ERROR_NONE; @@ -446,10 +446,10 @@ otError otPlatRadioAddSrcMatchExtEntry(otInstance *aInstance, const otExtAddress otError otPlatRadioClearSrcMatchShortEntry(otInstance *aInstance, const uint16_t aShortAddress) { - otError error; - OT_UNUSED_VARIABLE(aInstance); + otError error; + uint8_t shortAddress[SHORT_ADDRESS_SIZE]; convertShortAddress(shortAddress, aShortAddress); @@ -467,10 +467,10 @@ otError otPlatRadioClearSrcMatchShortEntry(otInstance *aInstance, const uint16_t otError otPlatRadioClearSrcMatchExtEntry(otInstance *aInstance, const otExtAddress *aExtAddress) { - otError error; - OT_UNUSED_VARIABLE(aInstance); + otError error; + if (nrf_802154_pending_bit_for_addr_clear(aExtAddress->m8, true)) { error = OT_ERROR_NONE; @@ -522,10 +522,10 @@ otError otPlatRadioEnergyScan(otInstance *aInstance, uint8_t aScanChannel, uint1 otError otPlatRadioGetTransmitPower(otInstance *aInstance, int8_t *aPower) { - otError error = OT_ERROR_NONE; - OT_UNUSED_VARIABLE(aInstance); + otError error = OT_ERROR_NONE; + if (aPower == NULL) { error = OT_ERROR_INVALID_ARGS; @@ -799,6 +799,7 @@ void nrf_802154_energy_detected(uint8_t result) int8_t otPlatRadioGetReceiveSensitivity(otInstance *aInstance) { OT_UNUSED_VARIABLE(aInstance); + return NRF52840_RECEIVE_SENSITIVITY; } diff --git a/examples/platforms/posix/alarm.c b/examples/platforms/posix/alarm.c index 7001d972d..be69b2b7b 100644 --- a/examples/platforms/posix/alarm.c +++ b/examples/platforms/posix/alarm.c @@ -78,6 +78,7 @@ uint32_t otPlatAlarmMilliGetNow(void) void otPlatAlarmMilliStartAt(otInstance *aInstance, uint32_t aT0, uint32_t aDt) { OT_UNUSED_VARIABLE(aInstance); + sMsAlarm = aT0 + aDt; sIsMsRunning = true; } @@ -85,6 +86,7 @@ void otPlatAlarmMilliStartAt(otInstance *aInstance, uint32_t aT0, uint32_t aDt) void otPlatAlarmMilliStop(otInstance *aInstance) { OT_UNUSED_VARIABLE(aInstance); + sIsMsRunning = false; } @@ -96,6 +98,7 @@ uint32_t otPlatAlarmMicroGetNow(void) void otPlatAlarmMicroStartAt(otInstance *aInstance, uint32_t aT0, uint32_t aDt) { OT_UNUSED_VARIABLE(aInstance); + sUsAlarm = aT0 + aDt; sIsUsRunning = true; } @@ -103,6 +106,7 @@ void otPlatAlarmMicroStartAt(otInstance *aInstance, uint32_t aT0, uint32_t aDt) void otPlatAlarmMicroStop(otInstance *aInstance) { OT_UNUSED_VARIABLE(aInstance); + sIsUsRunning = false; } diff --git a/examples/platforms/posix/flash.c b/examples/platforms/posix/flash.c index 5f87bdb1c..681b428ca 100644 --- a/examples/platforms/posix/flash.c +++ b/examples/platforms/posix/flash.c @@ -128,6 +128,7 @@ exit: otError utilsFlashStatusWait(uint32_t aTimeout) { OT_UNUSED_VARIABLE(aTimeout); + return OT_ERROR_NONE; } diff --git a/examples/platforms/posix/logging.c b/examples/platforms/posix/logging.c index db302dd99..66171a102 100644 --- a/examples/platforms/posix/logging.c +++ b/examples/platforms/posix/logging.c @@ -58,14 +58,14 @@ (OPENTHREAD_CONFIG_LOG_OUTPUT == OPENTHREAD_CONFIG_LOG_OUTPUT_NCP_SPINEL) OT_TOOL_WEAK void otPlatLog(otLogLevel aLogLevel, otLogRegion aLogRegion, const char *aFormat, ...) { + OT_UNUSED_VARIABLE(aLogLevel); + OT_UNUSED_VARIABLE(aLogRegion); + char logString[512]; unsigned int offset; int charsWritten; va_list args; - OT_UNUSED_VARIABLE(aLogLevel); - OT_UNUSED_VARIABLE(aLogRegion); - offset = 0; LOG_PRINTF("[%d] ", gNodeId); diff --git a/examples/platforms/posix/misc.c b/examples/platforms/posix/misc.c index 467587517..c271114f6 100644 --- a/examples/platforms/posix/misc.c +++ b/examples/platforms/posix/misc.c @@ -70,6 +70,7 @@ void otPlatReset(otInstance *aInstance) otPlatResetReason otPlatGetResetReason(otInstance *aInstance) { OT_UNUSED_VARIABLE(aInstance); + return sPlatResetReason; } @@ -80,10 +81,10 @@ void otPlatWakeHost(void) otError otPlatSetMcuPowerState(otInstance *aInstance, otPlatMcuPowerState aState) { - otError error = OT_ERROR_NONE; - OT_UNUSED_VARIABLE(aInstance); + otError error = OT_ERROR_NONE; + switch (aState) { case OT_PLAT_MCU_POWER_STATE_ON: @@ -102,5 +103,6 @@ otError otPlatSetMcuPowerState(otInstance *aInstance, otPlatMcuPowerState aState otPlatMcuPowerState otPlatGetMcuPowerState(otInstance *aInstance) { OT_UNUSED_VARIABLE(aInstance); + return gPlatMcuPowerState; } diff --git a/examples/platforms/posix/radio.c b/examples/platforms/posix/radio.c index b7feb210d..f4a2f3657 100644 --- a/examples/platforms/posix/radio.c +++ b/examples/platforms/posix/radio.c @@ -378,6 +378,7 @@ void otPlatRadioSetShortAddress(otInstance *aInstance, uint16_t address) void otPlatRadioSetPromiscuous(otInstance *aInstance, bool aEnable) { OT_UNUSED_VARIABLE(aInstance); + sPromiscuous = aEnable; } @@ -451,6 +452,7 @@ void platformRadioDeinit(void) bool otPlatRadioIsEnabled(otInstance *aInstance) { OT_UNUSED_VARIABLE(aInstance); + return (sState != OT_RADIO_STATE_DISABLED) ? true : false; } @@ -476,10 +478,10 @@ otError otPlatRadioDisable(otInstance *aInstance) otError otPlatRadioSleep(otInstance *aInstance) { - otError error = OT_ERROR_INVALID_STATE; - OT_UNUSED_VARIABLE(aInstance); + otError error = OT_ERROR_INVALID_STATE; + if (sState == OT_RADIO_STATE_SLEEP || sState == OT_RADIO_STATE_RECEIVE) { error = OT_ERROR_NONE; @@ -491,10 +493,10 @@ otError otPlatRadioSleep(otInstance *aInstance) otError otPlatRadioReceive(otInstance *aInstance, uint8_t aChannel) { - otError error = OT_ERROR_INVALID_STATE; - OT_UNUSED_VARIABLE(aInstance); + otError error = OT_ERROR_INVALID_STATE; + if (sState != OT_RADIO_STATE_DISABLED) { error = OT_ERROR_NONE; @@ -508,11 +510,11 @@ otError otPlatRadioReceive(otInstance *aInstance, uint8_t aChannel) otError otPlatRadioTransmit(otInstance *aInstance, otRadioFrame *aRadio) { - otError error = OT_ERROR_INVALID_STATE; - OT_UNUSED_VARIABLE(aInstance); OT_UNUSED_VARIABLE(aRadio); + otError error = OT_ERROR_INVALID_STATE; + if (sState == OT_RADIO_STATE_RECEIVE) { error = OT_ERROR_NONE; @@ -525,17 +527,18 @@ otError otPlatRadioTransmit(otInstance *aInstance, otRadioFrame *aRadio) otRadioFrame *otPlatRadioGetTransmitBuffer(otInstance *aInstance) { OT_UNUSED_VARIABLE(aInstance); + return &sTransmitFrame; } int8_t otPlatRadioGetRssi(otInstance *aInstance) { + OT_UNUSED_VARIABLE(aInstance); + int8_t rssi = POSIX_LOW_RSSI_SAMPLE; uint8_t channel = sReceiveFrame.mChannel; uint32_t probabilityThreshold; - OT_UNUSED_VARIABLE(aInstance); - otEXPECT((OT_RADIO_CHANNEL_MIN <= channel) && channel <= (OT_RADIO_CHANNEL_MAX)); // To emulate a simple interference model, we return either a high or @@ -556,12 +559,14 @@ exit: otRadioCaps otPlatRadioGetCaps(otInstance *aInstance) { OT_UNUSED_VARIABLE(aInstance); + return OT_RADIO_CAPS_NONE; } bool otPlatRadioGetPromiscuous(otInstance *aInstance) { OT_UNUSED_VARIABLE(aInstance); + return sPromiscuous; } @@ -831,12 +836,15 @@ exit: void otPlatRadioEnableSrcMatch(otInstance *aInstance, bool aEnable) { - sSrcMatchEnabled = aEnable; OT_UNUSED_VARIABLE(aInstance); + + sSrcMatchEnabled = aEnable; } otError otPlatRadioAddSrcMatchShortEntry(otInstance *aInstance, const uint16_t aShortAddress) { + OT_UNUSED_VARIABLE(aInstance); + otError error = OT_ERROR_NONE; otEXPECT_ACTION(sShortAddressMatchTableCount < sizeof(sShortAddressMatchTable) / sizeof(uint16_t), error = OT_ERROR_NO_BUFS); @@ -849,12 +857,13 @@ otError otPlatRadioAddSrcMatchShortEntry(otInstance *aInstance, const uint16_t a sShortAddressMatchTable[sShortAddressMatchTableCount++] = aShortAddress; exit: - OT_UNUSED_VARIABLE(aInstance); return error; } otError otPlatRadioAddSrcMatchExtEntry(otInstance *aInstance, const otExtAddress *aExtAddress) { + OT_UNUSED_VARIABLE(aInstance); + otError error = OT_ERROR_NONE; otEXPECT_ACTION(sExtAddressMatchTableCount < sizeof(sExtAddressMatchTable) / sizeof(otExtAddress), @@ -869,12 +878,13 @@ otError otPlatRadioAddSrcMatchExtEntry(otInstance *aInstance, const otExtAddress sExtAddressMatchTable[sExtAddressMatchTableCount++] = *aExtAddress; exit: - OT_UNUSED_VARIABLE(aInstance); return error; } otError otPlatRadioClearSrcMatchShortEntry(otInstance *aInstance, const uint16_t aShortAddress) { + OT_UNUSED_VARIABLE(aInstance); + otError error = OT_ERROR_NOT_FOUND; otEXPECT(sShortAddressMatchTableCount > 0); @@ -889,12 +899,13 @@ otError otPlatRadioClearSrcMatchShortEntry(otInstance *aInstance, const uint16_t } exit: - OT_UNUSED_VARIABLE(aInstance); return error; } otError otPlatRadioClearSrcMatchExtEntry(otInstance *aInstance, const otExtAddress *aExtAddress) { + OT_UNUSED_VARIABLE(aInstance); + otError error = OT_ERROR_NOT_FOUND; otEXPECT(sExtAddressMatchTableCount > 0); @@ -910,20 +921,21 @@ otError otPlatRadioClearSrcMatchExtEntry(otInstance *aInstance, const otExtAddre } exit: - OT_UNUSED_VARIABLE(aInstance); return error; } void otPlatRadioClearSrcMatchShortEntries(otInstance *aInstance) { - sShortAddressMatchTableCount = 0; OT_UNUSED_VARIABLE(aInstance); + + sShortAddressMatchTableCount = 0; } void otPlatRadioClearSrcMatchExtEntries(otInstance *aInstance) { - sExtAddressMatchTableCount = 0; OT_UNUSED_VARIABLE(aInstance); + + sExtAddressMatchTableCount = 0; } otError otPlatRadioEnergyScan(otInstance *aInstance, uint8_t aScanChannel, uint16_t aScanDuration) @@ -931,12 +943,14 @@ otError otPlatRadioEnergyScan(otInstance *aInstance, uint8_t aScanChannel, uint1 OT_UNUSED_VARIABLE(aInstance); OT_UNUSED_VARIABLE(aScanChannel); OT_UNUSED_VARIABLE(aScanDuration); + return OT_ERROR_NOT_IMPLEMENTED; } otError otPlatRadioGetTransmitPower(otInstance *aInstance, int8_t *aPower) { OT_UNUSED_VARIABLE(aInstance); + *aPower = sTxPower; return OT_ERROR_NONE; @@ -945,6 +959,7 @@ otError otPlatRadioGetTransmitPower(otInstance *aInstance, int8_t *aPower) otError otPlatRadioSetTransmitPower(otInstance *aInstance, int8_t aPower) { OT_UNUSED_VARIABLE(aInstance); + sTxPower = aPower; return OT_ERROR_NONE; @@ -953,6 +968,7 @@ otError otPlatRadioSetTransmitPower(otInstance *aInstance, int8_t aPower) int8_t otPlatRadioGetReceiveSensitivity(otInstance *aInstance) { OT_UNUSED_VARIABLE(aInstance); + return POSIX_RECEIVE_SENSITIVITY; } diff --git a/examples/platforms/posix/sim/alarm-sim.c b/examples/platforms/posix/sim/alarm-sim.c index 944d0e186..66da3e26b 100644 --- a/examples/platforms/posix/sim/alarm-sim.c +++ b/examples/platforms/posix/sim/alarm-sim.c @@ -51,6 +51,7 @@ static uint32_t sUsAlarm = 0; void platformAlarmInit(uint32_t aSpeedUpFactor) { OT_UNUSED_VARIABLE(aSpeedUpFactor); + sNow = 0; } @@ -80,6 +81,7 @@ void otPlatAlarmMilliStartAt(otInstance *aInstance, uint32_t aT0, uint32_t aDt) void otPlatAlarmMilliStop(otInstance *aInstance) { OT_UNUSED_VARIABLE(aInstance); + sIsMsRunning = false; } @@ -99,6 +101,7 @@ void otPlatAlarmMicroStartAt(otInstance *aInstance, uint32_t aT0, uint32_t aDt) void otPlatAlarmMicroStop(otInstance *aInstance) { OT_UNUSED_VARIABLE(aInstance); + sIsUsRunning = false; } diff --git a/examples/platforms/posix/sim/platform-sim.c b/examples/platforms/posix/sim/platform-sim.c index 36c2a1a2f..8a2e16dd4 100644 --- a/examples/platforms/posix/sim/platform-sim.c +++ b/examples/platforms/posix/sim/platform-sim.c @@ -65,6 +65,7 @@ uint16_t sPortOffset; static void handleSignal(int aSignal) { OT_UNUSED_VARIABLE(aSignal); + gTerminate = true; } diff --git a/examples/platforms/posix/sim/radio-sim.c b/examples/platforms/posix/sim/radio-sim.c index cfe9dd9d9..0279de4fa 100644 --- a/examples/platforms/posix/sim/radio-sim.c +++ b/examples/platforms/posix/sim/radio-sim.c @@ -343,6 +343,7 @@ void otPlatRadioGetIeeeEui64(otInstance *aInstance, uint8_t *aIeeeEui64) void otPlatRadioSetPanId(otInstance *aInstance, uint16_t panid) { OT_UNUSED_VARIABLE(aInstance); + sPanid = panid; } @@ -359,12 +360,14 @@ void otPlatRadioSetExtendedAddress(otInstance *aInstance, const otExtAddress *aE void otPlatRadioSetShortAddress(otInstance *aInstance, uint16_t address) { OT_UNUSED_VARIABLE(aInstance); + sShortAddress = address; } void otPlatRadioSetPromiscuous(otInstance *aInstance, bool aEnable) { OT_UNUSED_VARIABLE(aInstance); + sPromiscuous = aEnable; } @@ -378,6 +381,7 @@ void platformRadioInit(void) bool otPlatRadioIsEnabled(otInstance *aInstance) { OT_UNUSED_VARIABLE(aInstance); + return (sState != OT_RADIO_STATE_DISABLED) ? true : false; } @@ -403,10 +407,10 @@ otError otPlatRadioDisable(otInstance *aInstance) otError otPlatRadioSleep(otInstance *aInstance) { - otError error = OT_ERROR_INVALID_STATE; - OT_UNUSED_VARIABLE(aInstance); + otError error = OT_ERROR_INVALID_STATE; + if (sState == OT_RADIO_STATE_SLEEP || sState == OT_RADIO_STATE_RECEIVE) { error = OT_ERROR_NONE; @@ -418,10 +422,10 @@ otError otPlatRadioSleep(otInstance *aInstance) otError otPlatRadioReceive(otInstance *aInstance, uint8_t aChannel) { - otError error = OT_ERROR_INVALID_STATE; - OT_UNUSED_VARIABLE(aInstance); + otError error = OT_ERROR_INVALID_STATE; + if (sState != OT_RADIO_STATE_DISABLED) { error = OT_ERROR_NONE; @@ -435,11 +439,11 @@ otError otPlatRadioReceive(otInstance *aInstance, uint8_t aChannel) otError otPlatRadioTransmit(otInstance *aInstance, otRadioFrame *aRadio) { - otError error = OT_ERROR_INVALID_STATE; - OT_UNUSED_VARIABLE(aInstance); OT_UNUSED_VARIABLE(aRadio); + otError error = OT_ERROR_INVALID_STATE; + if (sState == OT_RADIO_STATE_RECEIVE) { error = OT_ERROR_NONE; @@ -452,24 +456,28 @@ otError otPlatRadioTransmit(otInstance *aInstance, otRadioFrame *aRadio) otRadioFrame *otPlatRadioGetTransmitBuffer(otInstance *aInstance) { OT_UNUSED_VARIABLE(aInstance); + return &sTransmitFrame; } int8_t otPlatRadioGetRssi(otInstance *aInstance) { OT_UNUSED_VARIABLE(aInstance); + return 0; } otRadioCaps otPlatRadioGetCaps(otInstance *aInstance) { OT_UNUSED_VARIABLE(aInstance); + return OT_RADIO_CAPS_NONE; } bool otPlatRadioGetPromiscuous(otInstance *aInstance) { OT_UNUSED_VARIABLE(aInstance); + return sPromiscuous; } @@ -658,12 +666,15 @@ exit: void otPlatRadioEnableSrcMatch(otInstance *aInstance, bool aEnable) { - sSrcMatchEnabled = aEnable; OT_UNUSED_VARIABLE(aInstance); + + sSrcMatchEnabled = aEnable; } otError otPlatRadioAddSrcMatchShortEntry(otInstance *aInstance, const uint16_t aShortAddress) { + OT_UNUSED_VARIABLE(aInstance); + otError error = OT_ERROR_NONE; otEXPECT_ACTION(sShortAddressMatchTableCount < sizeof(sShortAddressMatchTable) / sizeof(uint16_t), error = OT_ERROR_NO_BUFS); @@ -676,12 +687,13 @@ otError otPlatRadioAddSrcMatchShortEntry(otInstance *aInstance, const uint16_t a sShortAddressMatchTable[sShortAddressMatchTableCount++] = aShortAddress; exit: - OT_UNUSED_VARIABLE(aInstance); return error; } otError otPlatRadioAddSrcMatchExtEntry(otInstance *aInstance, const otExtAddress *aExtAddress) { + OT_UNUSED_VARIABLE(aInstance); + otError error = OT_ERROR_NONE; otEXPECT_ACTION(sExtAddressMatchTableCount < sizeof(sExtAddressMatchTable) / sizeof(otExtAddress), @@ -696,12 +708,13 @@ otError otPlatRadioAddSrcMatchExtEntry(otInstance *aInstance, const otExtAddress sExtAddressMatchTable[sExtAddressMatchTableCount++] = *aExtAddress; exit: - OT_UNUSED_VARIABLE(aInstance); return error; } otError otPlatRadioClearSrcMatchShortEntry(otInstance *aInstance, const uint16_t aShortAddress) { + OT_UNUSED_VARIABLE(aInstance); + otError error = OT_ERROR_NOT_FOUND; otEXPECT(sShortAddressMatchTableCount > 0); @@ -716,12 +729,13 @@ otError otPlatRadioClearSrcMatchShortEntry(otInstance *aInstance, const uint16_t } exit: - OT_UNUSED_VARIABLE(aInstance); return error; } otError otPlatRadioClearSrcMatchExtEntry(otInstance *aInstance, const otExtAddress *aExtAddress) { + OT_UNUSED_VARIABLE(aInstance); + otError error = OT_ERROR_NOT_FOUND; otEXPECT(sExtAddressMatchTableCount > 0); @@ -737,20 +751,21 @@ otError otPlatRadioClearSrcMatchExtEntry(otInstance *aInstance, const otExtAddre } exit: - OT_UNUSED_VARIABLE(aInstance); return error; } void otPlatRadioClearSrcMatchShortEntries(otInstance *aInstance) { - sShortAddressMatchTableCount = 0; OT_UNUSED_VARIABLE(aInstance); + + sShortAddressMatchTableCount = 0; } void otPlatRadioClearSrcMatchExtEntries(otInstance *aInstance) { - sExtAddressMatchTableCount = 0; OT_UNUSED_VARIABLE(aInstance); + + sExtAddressMatchTableCount = 0; } otError otPlatRadioEnergyScan(otInstance *aInstance, uint8_t aScanChannel, uint16_t aScanDuration) @@ -758,6 +773,7 @@ otError otPlatRadioEnergyScan(otInstance *aInstance, uint8_t aScanChannel, uint1 OT_UNUSED_VARIABLE(aInstance); OT_UNUSED_VARIABLE(aScanChannel); OT_UNUSED_VARIABLE(aScanDuration); + return OT_ERROR_NOT_IMPLEMENTED; } @@ -765,6 +781,7 @@ otError otPlatRadioGetTransmitPower(otInstance *aInstance, int8_t *aPower) { OT_UNUSED_VARIABLE(aInstance); OT_UNUSED_VARIABLE(aPower); + return OT_ERROR_NOT_IMPLEMENTED; } @@ -772,12 +789,14 @@ otError otPlatRadioSetTransmitPower(otInstance *aInstance, int8_t aPower) { OT_UNUSED_VARIABLE(aInstance); OT_UNUSED_VARIABLE(aPower); + return OT_ERROR_NOT_IMPLEMENTED; } int8_t otPlatRadioGetReceiveSensitivity(otInstance *aInstance) { OT_UNUSED_VARIABLE(aInstance); + return POSIX_RECEIVE_SENSITIVITY; } diff --git a/examples/platforms/posix/system.c b/examples/platforms/posix/system.c index 35e801ce9..9dac0cfd1 100644 --- a/examples/platforms/posix/system.c +++ b/examples/platforms/posix/system.c @@ -61,6 +61,7 @@ static volatile bool gTerminate = false; static void handleSignal(int aSignal) { OT_UNUSED_VARIABLE(aSignal); + gTerminate = true; } #endif diff --git a/examples/platforms/utils/debug_uart.c b/examples/platforms/utils/debug_uart.c index d34a54718..e1d10bdc9 100644 --- a/examples/platforms/utils/debug_uart.c +++ b/examples/platforms/utils/debug_uart.c @@ -124,6 +124,7 @@ OT_TOOL_WEAK otError otPlatDebugUart_logfile(const char *filename) { OT_UNUSED_VARIABLE(filename); + return OT_ERROR_FAILED; } @@ -131,12 +132,12 @@ otError otPlatDebugUart_logfile(const char *filename) /* this should not be a WEAK function */ void otPlatLog(otLogLevel aLogLevel, otLogRegion aLogRegion, const char *aFormat, ...) { - va_list ap; - uint32_t now; - OT_UNUSED_VARIABLE(aLogLevel); OT_UNUSED_VARIABLE(aLogRegion); + va_list ap; + uint32_t now; + now = otPlatAlarmMilliGetNow(); otPlatDebugUart_printf("%3d.%03d | ", (int)(now / 1000), (int)(now % 1000)); va_start(ap, aFormat); diff --git a/examples/platforms/utils/settings_flash.c b/examples/platforms/utils/settings_flash.c index 8e7b8dd90..7a1392eca 100644 --- a/examples/platforms/utils/settings_flash.c +++ b/examples/platforms/utils/settings_flash.c @@ -128,14 +128,14 @@ static void initSettings(uint32_t aBase, uint32_t aFlag) static uint32_t swapSettingsBlock(otInstance *aInstance) { + OT_UNUSED_VARIABLE(aInstance); + uint32_t oldBase = sSettingsBaseAddress; uint32_t swapAddress = oldBase; uint32_t usedSize = sSettingsUsedSize; uint8_t pageNum = SETTINGS_CONFIG_PAGE_NUM; uint32_t settingsSize = pageNum > 1 ? SETTINGS_CONFIG_PAGE_SIZE * pageNum / 2 : SETTINGS_CONFIG_PAGE_SIZE; - OT_UNUSED_VARIABLE(aInstance); - otEXPECT(pageNum > 1); sSettingsBaseAddress = @@ -257,12 +257,12 @@ exit: // settings API void otPlatSettingsInit(otInstance *aInstance) { + OT_UNUSED_VARIABLE(aInstance); + uint8_t index; uint32_t settingsSize = SETTINGS_CONFIG_PAGE_NUM > 1 ? SETTINGS_CONFIG_PAGE_SIZE * SETTINGS_CONFIG_PAGE_NUM / 2 : SETTINGS_CONFIG_PAGE_SIZE; - OT_UNUSED_VARIABLE(aInstance); - sSettingsBaseAddress = SETTINGS_CONFIG_BASE_ADDRESS; utilsFlashInit(); @@ -307,30 +307,33 @@ void otPlatSettingsInit(otInstance *aInstance) otError otPlatSettingsBeginChange(otInstance *aInstance) { OT_UNUSED_VARIABLE(aInstance); + return OT_ERROR_NONE; } otError otPlatSettingsCommitChange(otInstance *aInstance) { OT_UNUSED_VARIABLE(aInstance); + return OT_ERROR_NONE; } otError otPlatSettingsAbandonChange(otInstance *aInstance) { OT_UNUSED_VARIABLE(aInstance); + return OT_ERROR_NONE; } otError otPlatSettingsGet(otInstance *aInstance, uint16_t aKey, int aIndex, uint8_t *aValue, uint16_t *aValueLength) { + OT_UNUSED_VARIABLE(aInstance); + otError error = OT_ERROR_NOT_FOUND; uint32_t address = sSettingsBaseAddress + OT_SETTINGS_FLAG_SIZE; uint16_t valueLength = 0; int index = 0; - OT_UNUSED_VARIABLE(aInstance); - while (address < (sSettingsBaseAddress + sSettingsUsedSize)) { struct settingsBlock block; @@ -397,12 +400,12 @@ otError otPlatSettingsAdd(otInstance *aInstance, uint16_t aKey, const uint8_t *a otError otPlatSettingsDelete(otInstance *aInstance, uint16_t aKey, int aIndex) { + OT_UNUSED_VARIABLE(aInstance); + otError error = OT_ERROR_NOT_FOUND; uint32_t address = sSettingsBaseAddress + OT_SETTINGS_FLAG_SIZE; int index = 0; - OT_UNUSED_VARIABLE(aInstance); - while (address < (sSettingsBaseAddress + sSettingsUsedSize)) { struct settingsBlock block; diff --git a/src/cli/cli.cpp b/src/cli/cli.cpp index a46a198ec..58cdff046 100644 --- a/src/cli/cli.cpp +++ b/src/cli/cli.cpp @@ -413,6 +413,9 @@ otError Interpreter::ParseUnsignedLong(char *argv, unsigned long &value) void Interpreter::ProcessHelp(int argc, char *argv[]) { + OT_UNUSED_VARIABLE(argc); + OT_UNUSED_VARIABLE(argv); + for (unsigned int i = 0; i < OT_ARRAY_LENGTH(sCommands); i++) { mServer->OutputFormat("%s\r\n", sCommands[i].mName); @@ -422,9 +425,6 @@ void Interpreter::ProcessHelp(int argc, char *argv[]) { mServer->OutputFormat("%s\r\n", mUserCommands[i].mName); } - - OT_UNUSED_VARIABLE(argc); - OT_UNUSED_VARIABLE(argv); } void Interpreter::ProcessAutoStart(int argc, char *argv[]) @@ -460,10 +460,11 @@ void Interpreter::ProcessAutoStart(int argc, char *argv[]) void Interpreter::ProcessBufferInfo(int argc, char *argv[]) { - otBufferInfo bufferInfo; OT_UNUSED_VARIABLE(argc); OT_UNUSED_VARIABLE(argv); + otBufferInfo bufferInfo; + otMessageGetBufferInfo(mInstance, &bufferInfo); mServer->OutputFormat("total: %d\r\n", bufferInfo.mTotalBuffers); @@ -887,6 +888,9 @@ void Interpreter::HandleDnsResponse(const char *aHostname, Ip6::Address &aAddres #if OPENTHREAD_FTD void Interpreter::ProcessEidCache(int argc, char *argv[]) { + OT_UNUSED_VARIABLE(argc); + OT_UNUSED_VARIABLE(argv); + otEidCacheEntry entry; for (uint8_t i = 0;; i++) @@ -906,14 +910,14 @@ void Interpreter::ProcessEidCache(int argc, char *argv[]) } exit: - OT_UNUSED_VARIABLE(argc); - OT_UNUSED_VARIABLE(argv); AppendResult(OT_ERROR_NONE); } #endif // OPENTHREAD_FTD void Interpreter::ProcessEui64(int argc, char *argv[]) { + OT_UNUSED_VARIABLE(argv); + otError error = OT_ERROR_NONE; otExtAddress extAddress; @@ -924,7 +928,6 @@ void Interpreter::ProcessEui64(int argc, char *argv[]) mServer->OutputFormat("\r\n"); exit: - OT_UNUSED_VARIABLE(argv); AppendResult(error); } @@ -954,9 +957,10 @@ exit: #if OPENTHREAD_POSIX void Interpreter::ProcessExit(int argc, char *argv[]) { - exit(EXIT_SUCCESS); OT_UNUSED_VARIABLE(argc); OT_UNUSED_VARIABLE(argv); + + exit(EXIT_SUCCESS); } #endif @@ -1000,9 +1004,10 @@ exit: void Interpreter::ProcessFactoryReset(int argc, char *argv[]) { - otInstanceFactoryReset(mInstance); OT_UNUSED_VARIABLE(argc); OT_UNUSED_VARIABLE(argv); + + otInstanceFactoryReset(mInstance); } void Interpreter::ProcessIfconfig(int argc, char *argv[]) @@ -1251,6 +1256,9 @@ exit: void Interpreter::ProcessLeaderData(int argc, char *argv[]) { + OT_UNUSED_VARIABLE(argc); + OT_UNUSED_VARIABLE(argv); + otError error; otLeaderData leaderData; @@ -1263,8 +1271,6 @@ void Interpreter::ProcessLeaderData(int argc, char *argv[]) mServer->OutputFormat("Leader Router ID: %d\r\n", leaderData.mLeaderRouterId); exit: - OT_UNUSED_VARIABLE(argc); - OT_UNUSED_VARIABLE(argv); AppendResult(error); } @@ -1494,6 +1500,9 @@ exit: #if OPENTHREAD_ENABLE_SERVICE void Interpreter::ProcessNetworkDataShow(int argc, char *argv[]) { + OT_UNUSED_VARIABLE(argc); + OT_UNUSED_VARIABLE(argv); + otError error = OT_ERROR_NONE; uint8_t data[255]; uint8_t len = sizeof(data); @@ -1504,8 +1513,6 @@ void Interpreter::ProcessNetworkDataShow(int argc, char *argv[]) mServer->OutputFormat("\r\n"); exit: - OT_UNUSED_VARIABLE(argc); - OT_UNUSED_VARIABLE(argv); AppendResult(error); } @@ -1558,6 +1565,9 @@ exit: #if OPENTHREAD_ENABLE_BORDER_ROUTER || OPENTHREAD_ENABLE_SERVICE void Interpreter::ProcessNetworkDataRegister(int argc, char *argv[]) { + OT_UNUSED_VARIABLE(argc); + OT_UNUSED_VARIABLE(argv); + otError error = OT_ERROR_NONE; #if OPENTHREAD_ENABLE_BORDER_ROUTER SuccessOrExit(error = otBorderRouterRegister(mInstance)); @@ -1566,8 +1576,6 @@ void Interpreter::ProcessNetworkDataRegister(int argc, char *argv[]) #endif exit: - OT_UNUSED_VARIABLE(argc); - OT_UNUSED_VARIABLE(argv); AppendResult(error); } #endif // OPENTHREAD_ENABLE_BORDER_ROUTER || OPENTHREAD_ENABLE_SERVICE @@ -1686,6 +1694,9 @@ exit: void Interpreter::ProcessParent(int argc, char *argv[]) { + OT_UNUSED_VARIABLE(argc); + OT_UNUSED_VARIABLE(argv); + otError error = OT_ERROR_NONE; otRouterInfo parentInfo; @@ -1705,8 +1716,6 @@ void Interpreter::ProcessParent(int argc, char *argv[]) mServer->OutputFormat("Age: %d\r\n", parentInfo.mAge); exit: - OT_UNUSED_VARIABLE(argc); - OT_UNUSED_VARIABLE(argv); AppendResult(error); } @@ -2092,6 +2101,8 @@ exit: otError Interpreter::ProcessPrefixRemove(int argc, char *argv[]) { + OT_UNUSED_VARIABLE(argc); + otError error = OT_ERROR_NONE; struct otIp6Prefix prefix; int argcur = 0; @@ -2120,7 +2131,6 @@ otError Interpreter::ProcessPrefixRemove(int argc, char *argv[]) error = otBorderRouterRemoveOnMeshPrefix(mInstance, &prefix); exit: - OT_UNUSED_VARIABLE(argc); return error; } @@ -2234,17 +2244,19 @@ exit: void Interpreter::ProcessReset(int argc, char *argv[]) { - otInstanceReset(mInstance); OT_UNUSED_VARIABLE(argc); OT_UNUSED_VARIABLE(argv); + + otInstanceReset(mInstance); } void Interpreter::ProcessRloc16(int argc, char *argv[]) { - mServer->OutputFormat("%04x\r\n", otThreadGetRloc16(mInstance)); - mServer->OutputFormat("Done\r\n"); OT_UNUSED_VARIABLE(argc); OT_UNUSED_VARIABLE(argv); + + mServer->OutputFormat("%04x\r\n", otThreadGetRloc16(mInstance)); + mServer->OutputFormat("Done\r\n"); } #if OPENTHREAD_ENABLE_BORDER_ROUTER @@ -2692,6 +2704,9 @@ exit: void Interpreter::ProcessSingleton(int argc, char *argv[]) { + OT_UNUSED_VARIABLE(argc); + OT_UNUSED_VARIABLE(argv); + otError error = OT_ERROR_NONE; if (otThreadIsSingleton(mInstance)) @@ -2703,9 +2718,6 @@ void Interpreter::ProcessSingleton(int argc, char *argv[]) mServer->OutputFormat("false\r\n"); } - OT_UNUSED_VARIABLE(argc); - OT_UNUSED_VARIABLE(argv); - AppendResult(error); } @@ -2853,6 +2865,9 @@ exit: void Interpreter::ProcessThread(int argc, char *argv[]) { + OT_UNUSED_VARIABLE(argc); + OT_UNUSED_VARIABLE(argv); + otError error = OT_ERROR_NONE; VerifyOrExit(argc > 0, error = OT_ERROR_INVALID_ARGS); @@ -2871,8 +2886,6 @@ void Interpreter::ProcessThread(int argc, char *argv[]) } exit: - OT_UNUSED_VARIABLE(argc); - OT_UNUSED_VARIABLE(argv); AppendResult(error); } @@ -2910,11 +2923,12 @@ void Interpreter::ProcessUdp(int argc, char *argv[]) void Interpreter::ProcessVersion(int argc, char *argv[]) { + OT_UNUSED_VARIABLE(argc); + OT_UNUSED_VARIABLE(argv); + otStringPtr version(otGetVersionString()); mServer->OutputFormat("%s\r\n", (const char *)version); AppendResult(OT_ERROR_NONE); - OT_UNUSED_VARIABLE(argc); - OT_UNUSED_VARIABLE(argv); } #if OPENTHREAD_ENABLE_COMMISSIONER && OPENTHREAD_FTD @@ -3232,6 +3246,8 @@ exit: void Interpreter::ProcessJoinerId(int argc, char *argv[]) { + OT_UNUSED_VARIABLE(argv); + otError error = OT_ERROR_NONE; otExtAddress joinerId; @@ -3242,7 +3258,6 @@ void Interpreter::ProcessJoinerId(int argc, char *argv[]) mServer->OutputFormat("\r\n"); exit: - OT_UNUSED_VARIABLE(argv); AppendResult(error); } @@ -3796,8 +3811,9 @@ Interpreter &Interpreter::GetOwner(OwnerLocator &aOwnerLocator) #if OPENTHREAD_ENABLE_MULTIPLE_INSTANCES Interpreter &interpreter = (aOwnerLocator.GetOwner()); #else - Interpreter &interpreter = Uart::sUartServer->GetInterpreter(); OT_UNUSED_VARIABLE(aOwnerLocator); + + Interpreter &interpreter = Uart::sUartServer->GetInterpreter(); #endif return interpreter; } diff --git a/src/cli/cli_coap.cpp b/src/cli/cli_coap.cpp index 0c4bc9d13..ba6398310 100644 --- a/src/cli/cli_coap.cpp +++ b/src/cli/cli_coap.cpp @@ -341,6 +341,9 @@ void Coap::HandleClientResponse(otCoapHeader * aHeader, const otMessageInfo *aMessageInfo, otError aError) { + OT_UNUSED_VARIABLE(aHeader); + OT_UNUSED_VARIABLE(aMessageInfo); + if (aError != OT_ERROR_NONE) { mInterpreter.mServer->OutputFormat("Error receiving coap response message: Error %d: %s\r\n", aError, @@ -351,9 +354,6 @@ void Coap::HandleClientResponse(otCoapHeader * aHeader, mInterpreter.mServer->OutputFormat("Received coap response"); PrintPayload(aMessage); } - - OT_UNUSED_VARIABLE(aHeader); - OT_UNUSED_VARIABLE(aMessageInfo); } } // namespace Cli diff --git a/src/cli/cli_coap_secure.cpp b/src/cli/cli_coap_secure.cpp index 7ca3ad6f4..534c2e1c8 100644 --- a/src/cli/cli_coap_secure.cpp +++ b/src/cli/cli_coap_secure.cpp @@ -320,6 +320,8 @@ void OTCALL CoapSecure::HandleClientConnect(bool aConnected, void *aContext) void CoapSecure::HandleClientConnect(bool aConnected) { + OT_UNUSED_VARIABLE(aConnected); + if (aConnected) { mInterpreter.mServer->OutputFormat("CoAP Secure connected!\r\n> "); @@ -344,8 +346,6 @@ void CoapSecure::HandleClientConnect(bool aConnected) mShutdownFlag = false; } } - - OT_UNUSED_VARIABLE(aConnected); } void OTCALL CoapSecure::HandleServerResponse(void * aContext, @@ -579,6 +579,9 @@ void CoapSecure::HandleClientResponse(otCoapHeader * aHeader, const otMessageInfo *aMessageInfo, otError aError) { + OT_UNUSED_VARIABLE(aHeader); + OT_UNUSED_VARIABLE(aMessageInfo); + if (aError != OT_ERROR_NONE) { mInterpreter.mServer->OutputFormat("Error receiving coap secure response message: Error %d: %s\r\n", aError, @@ -590,9 +593,6 @@ void CoapSecure::HandleClientResponse(otCoapHeader * aHeader, PrintHeaderInfos(aHeader); PrintPayload(aMessage); } - - OT_UNUSED_VARIABLE(aHeader); - OT_UNUSED_VARIABLE(aMessageInfo); } #if CLI_COAP_SECURE_USE_COAP_DEFAULT_HANDLER diff --git a/src/cli/cli_dataset.cpp b/src/cli/cli_dataset.cpp index bb826a645..a66ce9ded 100644 --- a/src/cli/cli_dataset.cpp +++ b/src/cli/cli_dataset.cpp @@ -212,19 +212,23 @@ exit: otError Dataset::ProcessHelp(otInstance *aInstance, int argc, char *argv[]) { + OT_UNUSED_VARIABLE(aInstance); + OT_UNUSED_VARIABLE(argc); + OT_UNUSED_VARIABLE(argv); + for (unsigned int i = 0; i < OT_ARRAY_LENGTH(sCommands); i++) { sServer->OutputFormat("%s\r\n", sCommands[i].mName); } - OT_UNUSED_VARIABLE(aInstance); - OT_UNUSED_VARIABLE(argc); - OT_UNUSED_VARIABLE(argv); return OT_ERROR_NONE; } otError Dataset::ProcessActive(otInstance *aInstance, int argc, char *argv[]) { + OT_UNUSED_VARIABLE(argc); + OT_UNUSED_VARIABLE(argv); + otOperationalDataset dataset; otError error; @@ -232,13 +236,14 @@ otError Dataset::ProcessActive(otInstance *aInstance, int argc, char *argv[]) error = Print(dataset); exit: - OT_UNUSED_VARIABLE(argc); - OT_UNUSED_VARIABLE(argv); return error; } otError Dataset::ProcessPending(otInstance *aInstance, int argc, char *argv[]) { + OT_UNUSED_VARIABLE(argc); + OT_UNUSED_VARIABLE(argv); + otOperationalDataset dataset; otError error; @@ -246,14 +251,14 @@ otError Dataset::ProcessPending(otInstance *aInstance, int argc, char *argv[]) error = Print(dataset); exit: - OT_UNUSED_VARIABLE(argc); - OT_UNUSED_VARIABLE(argv); return error; } #if OPENTHREAD_FTD otError Dataset::ProcessActiveTimestamp(otInstance *aInstance, int argc, char *argv[]) { + OT_UNUSED_VARIABLE(aInstance); + otError error = OT_ERROR_NONE; long value; @@ -262,14 +267,14 @@ otError Dataset::ProcessActiveTimestamp(otInstance *aInstance, int argc, char *a sDataset.mActiveTimestamp = static_cast(value); sDataset.mComponents.mIsActiveTimestampPresent = true; - OT_UNUSED_VARIABLE(aInstance); - exit: return error; } otError Dataset::ProcessChannel(otInstance *aInstance, int argc, char *argv[]) { + OT_UNUSED_VARIABLE(aInstance); + otError error = OT_ERROR_NONE; long value; @@ -278,14 +283,14 @@ otError Dataset::ProcessChannel(otInstance *aInstance, int argc, char *argv[]) sDataset.mChannel = static_cast(value); sDataset.mComponents.mIsChannelPresent = true; - OT_UNUSED_VARIABLE(aInstance); - exit: return error; } otError Dataset::ProcessChannelMask(otInstance *aInstance, int argc, char *argv[]) { + OT_UNUSED_VARIABLE(aInstance); + otError error = OT_ERROR_NONE; long value; @@ -293,7 +298,6 @@ otError Dataset::ProcessChannelMask(otInstance *aInstance, int argc, char *argv[ SuccessOrExit(error = Interpreter::ParseLong(argv[0], value)); sDataset.mChannelMaskPage0 = static_cast(value); sDataset.mComponents.mIsChannelMaskPage0Present = true; - OT_UNUSED_VARIABLE(aInstance); exit: return error; @@ -301,15 +305,18 @@ exit: otError Dataset::ProcessClear(otInstance *aInstance, int argc, char *argv[]) { - memset(&sDataset, 0, sizeof(sDataset)); OT_UNUSED_VARIABLE(aInstance); OT_UNUSED_VARIABLE(argc); OT_UNUSED_VARIABLE(argv); + + memset(&sDataset, 0, sizeof(sDataset)); return OT_ERROR_NONE; } otError Dataset::ProcessCommit(otInstance *aInstance, int argc, char *argv[]) { + OT_UNUSED_VARIABLE(aInstance); + otError error = OT_ERROR_NONE; VerifyOrExit(argc > 0, error = OT_ERROR_INVALID_ARGS); @@ -327,14 +334,14 @@ otError Dataset::ProcessCommit(otInstance *aInstance, int argc, char *argv[]) ExitNow(error = OT_ERROR_INVALID_ARGS); } - OT_UNUSED_VARIABLE(aInstance); - exit: return error; } otError Dataset::ProcessDelay(otInstance *aInstance, int argc, char *argv[]) { + OT_UNUSED_VARIABLE(aInstance); + otError error = OT_ERROR_NONE; long value; @@ -343,14 +350,14 @@ otError Dataset::ProcessDelay(otInstance *aInstance, int argc, char *argv[]) sDataset.mDelay = static_cast(value); sDataset.mComponents.mIsDelayPresent = true; - OT_UNUSED_VARIABLE(aInstance); - exit: return error; } otError Dataset::ProcessExtPanId(otInstance *aInstance, int argc, char *argv[]) { + OT_UNUSED_VARIABLE(aInstance); + otError error = OT_ERROR_NONE; uint8_t extPanId[OT_EXT_PAN_ID_SIZE]; @@ -360,14 +367,14 @@ otError Dataset::ProcessExtPanId(otInstance *aInstance, int argc, char *argv[]) memcpy(sDataset.mExtendedPanId.m8, extPanId, sizeof(sDataset.mExtendedPanId)); sDataset.mComponents.mIsExtendedPanIdPresent = true; - OT_UNUSED_VARIABLE(aInstance); - exit: return error; } otError Dataset::ProcessMasterKey(otInstance *aInstance, int argc, char *argv[]) { + OT_UNUSED_VARIABLE(aInstance); + otError error = OT_ERROR_NONE; uint8_t key[OT_MASTER_KEY_SIZE]; @@ -377,14 +384,14 @@ otError Dataset::ProcessMasterKey(otInstance *aInstance, int argc, char *argv[]) memcpy(sDataset.mMasterKey.m8, key, sizeof(sDataset.mMasterKey)); sDataset.mComponents.mIsMasterKeyPresent = true; - OT_UNUSED_VARIABLE(aInstance); - exit: return error; } otError Dataset::ProcessMeshLocalPrefix(otInstance *aInstance, int argc, char *argv[]) { + OT_UNUSED_VARIABLE(aInstance); + otError error = OT_ERROR_NONE; otIp6Address prefix; @@ -394,14 +401,14 @@ otError Dataset::ProcessMeshLocalPrefix(otInstance *aInstance, int argc, char *a memcpy(sDataset.mMeshLocalPrefix.m8, prefix.mFields.m8, sizeof(sDataset.mMeshLocalPrefix.m8)); sDataset.mComponents.mIsMeshLocalPrefixPresent = true; - OT_UNUSED_VARIABLE(aInstance); - exit: return error; } otError Dataset::ProcessNetworkName(otInstance *aInstance, int argc, char *argv[]) { + OT_UNUSED_VARIABLE(aInstance); + otError error = OT_ERROR_NONE; size_t length; @@ -412,14 +419,14 @@ otError Dataset::ProcessNetworkName(otInstance *aInstance, int argc, char *argv[ memcpy(sDataset.mNetworkName.m8, argv[0], length); sDataset.mComponents.mIsNetworkNamePresent = true; - OT_UNUSED_VARIABLE(aInstance); - exit: return error; } otError Dataset::ProcessPanId(otInstance *aInstance, int argc, char *argv[]) { + OT_UNUSED_VARIABLE(aInstance); + otError error = OT_ERROR_NONE; long value; @@ -428,14 +435,14 @@ otError Dataset::ProcessPanId(otInstance *aInstance, int argc, char *argv[]) sDataset.mPanId = static_cast(value); sDataset.mComponents.mIsPanIdPresent = true; - OT_UNUSED_VARIABLE(aInstance); - exit: return error; } otError Dataset::ProcessPendingTimestamp(otInstance *aInstance, int argc, char *argv[]) { + OT_UNUSED_VARIABLE(aInstance); + otError error = OT_ERROR_NONE; long value; @@ -444,14 +451,14 @@ otError Dataset::ProcessPendingTimestamp(otInstance *aInstance, int argc, char * sDataset.mPendingTimestamp = static_cast(value); sDataset.mComponents.mIsPendingTimestampPresent = true; - OT_UNUSED_VARIABLE(aInstance); - exit: return error; } otError Dataset::ProcessMgmtSetCommand(otInstance *aInstance, int argc, char *argv[]) { + OT_UNUSED_VARIABLE(aInstance); + otError error = OT_ERROR_NONE; otOperationalDataset dataset; uint8_t tlvs[128]; @@ -568,14 +575,14 @@ otError Dataset::ProcessMgmtSetCommand(otInstance *aInstance, int argc, char *ar ExitNow(error = OT_ERROR_INVALID_ARGS); } - OT_UNUSED_VARIABLE(aInstance); - exit: return error; } otError Dataset::ProcessMgmtGetCommand(otInstance *aInstance, int argc, char *argv[]) { + OT_UNUSED_VARIABLE(aInstance); + otError error = OT_ERROR_NONE; otOperationalDatasetComponents datasetComponents; uint8_t tlvs[32]; @@ -667,14 +674,14 @@ otError Dataset::ProcessMgmtGetCommand(otInstance *aInstance, int argc, char *ar ExitNow(error = OT_ERROR_INVALID_ARGS); } - OT_UNUSED_VARIABLE(aInstance); - exit: return error; } otError Dataset::ProcessPSKc(otInstance *aInstance, int argc, char *argv[]) { + OT_UNUSED_VARIABLE(aInstance); + otError error = OT_ERROR_NONE; uint16_t length; @@ -685,7 +692,6 @@ otError Dataset::ProcessPSKc(otInstance *aInstance, int argc, char *argv[]) error = OT_ERROR_PARSE); sDataset.mComponents.mIsPSKcPresent = true; - OT_UNUSED_VARIABLE(aInstance); exit: return error; @@ -693,6 +699,8 @@ exit: otError Dataset::ProcessSecurityPolicy(otInstance *aInstance, int argc, char *argv[]) { + OT_UNUSED_VARIABLE(aInstance); + otError error = OT_ERROR_NONE; long value; @@ -735,7 +743,6 @@ otError Dataset::ProcessSecurityPolicy(otInstance *aInstance, int argc, char *ar } sDataset.mComponents.mIsSecurityPolicyPresent = true; - OT_UNUSED_VARIABLE(aInstance); exit: return error; diff --git a/src/cli/cli_uart.cpp b/src/cli/cli_uart.cpp index f783a507f..0e780b3e5 100644 --- a/src/cli/cli_uart.cpp +++ b/src/cli/cli_uart.cpp @@ -295,14 +295,14 @@ void Uart::SendDoneTask(void) extern "C" void otCliPlatLogv(otLogLevel aLogLevel, otLogRegion aLogRegion, const char *aFormat, va_list aArgs) { + OT_UNUSED_VARIABLE(aLogLevel); + OT_UNUSED_VARIABLE(aLogRegion); + VerifyOrExit(Uart::sUartServer != NULL); Uart::sUartServer->OutputFormatV(aFormat, aArgs); Uart::sUartServer->OutputFormat("\r\n"); - OT_UNUSED_VARIABLE(aLogLevel); - OT_UNUSED_VARIABLE(aLogRegion); - exit: return; } diff --git a/src/cli/cli_udp_example.cpp b/src/cli/cli_udp_example.cpp index 10668d6ab..9d68eeff5 100644 --- a/src/cli/cli_udp_example.cpp +++ b/src/cli/cli_udp_example.cpp @@ -56,14 +56,14 @@ UdpExample::UdpExample(Interpreter &aInterpreter) otError UdpExample::ProcessHelp(int argc, char *argv[]) { + OT_UNUSED_VARIABLE(argc); + OT_UNUSED_VARIABLE(argv); + for (unsigned int i = 0; i < OT_ARRAY_LENGTH(sCommands); i++) { mInterpreter.mServer->OutputFormat("%s\r\n", sCommands[i].mName); } - OT_UNUSED_VARIABLE(argc); - OT_UNUSED_VARIABLE(argv); - return OT_ERROR_NONE; } diff --git a/src/core/api/commissioner_api.cpp b/src/core/api/commissioner_api.cpp index 46eae704b..b08fa7416 100644 --- a/src/core/api/commissioner_api.cpp +++ b/src/core/api/commissioner_api.cpp @@ -58,6 +58,8 @@ exit: otError otCommissionerStop(otInstance *aInstance) { + OT_UNUSED_VARIABLE(aInstance); + otError error = OT_ERROR_DISABLED_FEATURE; #if OPENTHREAD_FTD && OPENTHREAD_ENABLE_COMMISSIONER @@ -69,7 +71,6 @@ otError otCommissionerStop(otInstance *aInstance) #endif exit: #endif - OT_UNUSED_VARIABLE(aInstance); return error; } diff --git a/src/core/api/logging_api.cpp b/src/core/api/logging_api.cpp index 17481c4a2..4f43761a5 100644 --- a/src/core/api/logging_api.cpp +++ b/src/core/api/logging_api.cpp @@ -53,6 +53,8 @@ otLogLevel otLoggingGetLevel(void) otError otLoggingSetLevel(otLogLevel aLogLevel) { + OT_UNUSED_VARIABLE(aLogLevel); + otError error = OT_ERROR_DISABLED_FEATURE; #if OPENTHREAD_CONFIG_ENABLE_DYNAMIC_LOG_LEVEL @@ -64,6 +66,5 @@ otError otLoggingSetLevel(otLogLevel aLogLevel) #endif #endif - OT_UNUSED_VARIABLE(aLogLevel); return error; } diff --git a/src/core/coap/coap_secure.cpp b/src/core/coap/coap_secure.cpp index 4c7bf74d7..acca65707 100644 --- a/src/core/coap/coap_secure.cpp +++ b/src/core/coap/coap_secure.cpp @@ -243,6 +243,7 @@ otError CoapSecure::SendMessage(Message & aMessage, otError CoapSecure::Send(Message &aMessage, const Ip6::MessageInfo &aMessageInfo) { OT_UNUSED_VARIABLE(aMessageInfo); + mTransmitQueue.Enqueue(aMessage); mTransmitTask.Post(); return OT_ERROR_NONE; diff --git a/src/core/meshcop/border_agent.cpp b/src/core/meshcop/border_agent.cpp index 000acff45..56642ab09 100644 --- a/src/core/meshcop/border_agent.cpp +++ b/src/core/meshcop/border_agent.cpp @@ -187,6 +187,8 @@ void BorderAgent::HandleCoapResponse(void * aContext, const otMessageInfo *aMessageInfo, otError aResult) { + OT_UNUSED_VARIABLE(aMessageInfo); + ForwardContext &forwardContext = *static_cast(aContext); BorderAgent & borderAgent = forwardContext.GetBorderAgent(); ThreadNetif & netif = borderAgent.GetNetif(); @@ -194,8 +196,6 @@ void BorderAgent::HandleCoapResponse(void * aContext, Coap::Header header; otError error; - OT_UNUSED_VARIABLE(aMessageInfo); - SuccessOrExit(error = aResult); if (forwardContext.IsPetition()) @@ -319,13 +319,13 @@ BorderAgent::BorderAgent(Instance &aInstance) void BorderAgent::HandleProxyTransmit(const Coap::Header &aHeader, const Message &aMessage) { + OT_UNUSED_VARIABLE(aHeader); + Message * message = NULL; Ip6::MessageInfo messageInfo; uint16_t offset; otError error; - OT_UNUSED_VARIABLE(aHeader); - { UdpEncapsulationTlv tlv; diff --git a/src/core/meshcop/commissioner.cpp b/src/core/meshcop/commissioner.cpp index 4b5a07ed1..bc2c17fa0 100644 --- a/src/core/meshcop/commissioner.cpp +++ b/src/core/meshcop/commissioner.cpp @@ -650,13 +650,13 @@ void Commissioner::HandleLeaderPetitionResponse(Coap::Header * aHeader, const Ip6::MessageInfo *aMessageInfo, otError aResult) { + OT_UNUSED_VARIABLE(aMessageInfo); + ThreadNetif & netif = GetNetif(); StateTlv state; CommissionerSessionIdTlv sessionId; bool retransmit = false; - OT_UNUSED_VARIABLE(aMessageInfo); - VerifyOrExit(mState == OT_COMMISSIONER_STATE_PETITION, mState = OT_COMMISSIONER_STATE_DISABLED); VerifyOrExit(aResult == OT_ERROR_NONE && aHeader->GetCode() == OT_COAP_CODE_CHANGED, retransmit = true); @@ -756,10 +756,10 @@ void Commissioner::HandleLeaderKeepAliveResponse(Coap::Header * aHeader const Ip6::MessageInfo *aMessageInfo, otError aResult) { - StateTlv state; - OT_UNUSED_VARIABLE(aMessageInfo); + StateTlv state; + VerifyOrExit(mState == OT_COMMISSIONER_STATE_ACTIVE, mState = OT_COMMISSIONER_STATE_DISABLED); VerifyOrExit(aResult == OT_ERROR_NONE && aHeader->GetCode() == OT_COAP_CODE_CHANGED, mState = OT_COMMISSIONER_STATE_DISABLED); @@ -794,6 +794,8 @@ void Commissioner::HandleRelayReceive(void * aContext, void Commissioner::HandleRelayReceive(Coap::Header &aHeader, Message &aMessage, const Ip6::MessageInfo &aMessageInfo) { + OT_UNUSED_VARIABLE(aMessageInfo); + ThreadNetif & netif = GetNetif(); otError error; JoinerUdpPortTlv joinerPort; @@ -872,8 +874,6 @@ void Commissioner::HandleRelayReceive(Coap::Header &aHeader, Message &aMessage, netif.GetCoapSecure().Receive(aMessage, joinerMessageInfo); exit: - OT_UNUSED_VARIABLE(aMessageInfo); - return; } @@ -889,10 +889,11 @@ void Commissioner::HandleDatasetChanged(void * aContext, void Commissioner::HandleDatasetChanged(Coap::Header &aHeader, Message &aMessage, const Ip6::MessageInfo &aMessageInfo) { + OT_UNUSED_VARIABLE(aMessage); + VerifyOrExit(aHeader.GetType() == OT_COAP_TYPE_CONFIRMABLE && aHeader.GetCode() == OT_COAP_CODE_POST); otLogInfoMeshCoP("received dataset changed"); - OT_UNUSED_VARIABLE(aMessage); SuccessOrExit(GetNetif().GetCoap().SendEmptyAck(aHeader, aMessageInfo)); @@ -915,6 +916,7 @@ void Commissioner::HandleJoinerFinalize(void * aContext, void Commissioner::HandleJoinerFinalize(Coap::Header &aHeader, Message &aMessage, const Ip6::MessageInfo &aMessageInfo) { OT_UNUSED_VARIABLE(aMessageInfo); + StateTlv::State state = StateTlv::kAccept; ProvisioningUrlTlv provisioningUrl; @@ -999,6 +1001,8 @@ otError Commissioner::SendRelayTransmit(void *aContext, Message &aMessage, const otError Commissioner::SendRelayTransmit(Message &aMessage, const Ip6::MessageInfo &aMessageInfo) { + OT_UNUSED_VARIABLE(aMessageInfo); + ThreadNetif & netif = GetNetif(); otError error = OT_ERROR_NONE; Coap::Header header; @@ -1010,8 +1014,6 @@ otError Commissioner::SendRelayTransmit(Message &aMessage, const Ip6::MessageInf uint16_t offset; Ip6::MessageInfo messageInfo; - OT_UNUSED_VARIABLE(aMessageInfo); - header.Init(OT_COAP_TYPE_NON_CONFIRMABLE, OT_COAP_CODE_POST); header.AppendUriPathOptions(OT_URI_PATH_RELAY_TX); header.SetPayloadMarker(); diff --git a/src/core/meshcop/dtls.cpp b/src/core/meshcop/dtls.cpp index 42bc32e04..c02ace64e 100644 --- a/src/core/meshcop/dtls.cpp +++ b/src/core/meshcop/dtls.cpp @@ -112,11 +112,11 @@ Dtls::Dtls(Instance &aInstance) int Dtls::HandleMbedtlsEntropyPoll(void *aData, unsigned char *aOutput, size_t aInLen, size_t *aOutLen) { + OT_UNUSED_VARIABLE(aData); + otError error; int rval = 0; - OT_UNUSED_VARIABLE(aData); - error = otPlatRandomGetTrue((uint8_t *)aOutput, (uint16_t)aInLen); SuccessOrExit(error); @@ -665,6 +665,8 @@ int Dtls::HandleMbedtlsExportKeys(const unsigned char *aMasterSecret, size_t aKeyLength, size_t aIvLength) { + OT_UNUSED_VARIABLE(aMasterSecret); + uint8_t kek[Crypto::Sha256::kHashSize]; Crypto::Sha256 sha256; @@ -684,8 +686,6 @@ int Dtls::HandleMbedtlsExportKeys(const unsigned char *aMasterSecret, otLogInfoCoap("ApplicationCoapSecure Generated KEK"); } #endif // OPENTHREAD_ENABLE_APPLICATION_COAP_SECURE - - OT_UNUSED_VARIABLE(aMasterSecret); return 0; } @@ -871,10 +871,10 @@ otError Dtls::MapError(int rval) void Dtls::HandleMbedtlsDebug(void *ctx, int level, const char *, int, const char *str) { - Dtls *pThis = static_cast(ctx); - OT_UNUSED_VARIABLE(pThis); OT_UNUSED_VARIABLE(str); + Dtls *pThis = static_cast(ctx); + if (pThis->mCipherSuites[0] == MBEDTLS_TLS_ECJPAKE_WITH_AES_128_CCM_8) { switch (level) diff --git a/src/core/meshcop/joiner.cpp b/src/core/meshcop/joiner.cpp index 9e5c70e9a..cbbd122bc 100644 --- a/src/core/meshcop/joiner.cpp +++ b/src/core/meshcop/joiner.cpp @@ -427,10 +427,10 @@ void Joiner::HandleJoinerFinalizeResponse(Coap::Header * aHeader, const Ip6::MessageInfo *aMessageInfo, otError aResult) { - StateTlv state; - OT_UNUSED_VARIABLE(aMessageInfo); + StateTlv state; + VerifyOrExit(mState == OT_JOINER_STATE_CONNECTED && aResult == OT_ERROR_NONE && aHeader->GetType() == OT_COAP_TYPE_ACKNOWLEDGMENT && aHeader->GetCode() == OT_COAP_CODE_CHANGED); diff --git a/src/core/meshcop/joiner_router.cpp b/src/core/meshcop/joiner_router.cpp index cd99bf12e..0543c9b62 100644 --- a/src/core/meshcop/joiner_router.cpp +++ b/src/core/meshcop/joiner_router.cpp @@ -221,6 +221,8 @@ void JoinerRouter::HandleRelayTransmit(void * aContext, void JoinerRouter::HandleRelayTransmit(Coap::Header &aHeader, Message &aMessage, const Ip6::MessageInfo &aMessageInfo) { + OT_UNUSED_VARIABLE(aMessageInfo); + otError error; JoinerUdpPortTlv joinerPort; JoinerIidTlv joinerIid; @@ -280,8 +282,6 @@ void JoinerRouter::HandleRelayTransmit(Coap::Header &aHeader, Message &aMessage, } exit: - OT_UNUSED_VARIABLE(aMessageInfo); - if (error != OT_ERROR_NONE && message != NULL) { message->Free(); diff --git a/src/core/meshcop/leader.cpp b/src/core/meshcop/leader.cpp index 322431502..074c2b06d 100644 --- a/src/core/meshcop/leader.cpp +++ b/src/core/meshcop/leader.cpp @@ -79,6 +79,8 @@ void Leader::HandlePetition(void * aContext, void Leader::HandlePetition(Coap::Header &aHeader, Message &aMessage, const Ip6::MessageInfo &aMessageInfo) { + OT_UNUSED_VARIABLE(aMessageInfo); + CommissioningData data; CommissionerIdTlv commissionerId; StateTlv::State state = StateTlv::kReject; @@ -116,7 +118,6 @@ void Leader::HandlePetition(Coap::Header &aHeader, Message &aMessage, const Ip6: mTimer.Start(TimerMilli::SecToMsec(kTimeoutLeaderPetition)); exit: - OT_UNUSED_VARIABLE(aMessageInfo); SendPetitionResponse(aHeader, aMessageInfo, state); } diff --git a/src/core/net/dhcp6_client.cpp b/src/core/net/dhcp6_client.cpp index cbfe8e30c..fd9e4d70b 100644 --- a/src/core/net/dhcp6_client.cpp +++ b/src/core/net/dhcp6_client.cpp @@ -79,6 +79,7 @@ void Dhcp6Client::UpdateAddresses(otInstance * aInstance, void * aContext) { OT_UNUSED_VARIABLE(aContext); + bool found = false; bool newAgent = false; otDhcpAddress * address = NULL; @@ -518,9 +519,10 @@ void Dhcp6Client::HandleUdpReceive(void *aContext, otMessage *aMessage, const ot void Dhcp6Client::HandleUdpReceive(Message &aMessage, const Ip6::MessageInfo &aMessageInfo) { - Dhcp6Header header; OT_UNUSED_VARIABLE(aMessageInfo); + Dhcp6Header header; + VerifyOrExit(aMessage.Read(aMessage.GetOffset(), sizeof(header), &header) == sizeof(header)); aMessage.MoveOffset(sizeof(header)); diff --git a/src/core/net/dns_client.cpp b/src/core/net/dns_client.cpp index a53ced747..d8295d00b 100644 --- a/src/core/net/dns_client.cpp +++ b/src/core/net/dns_client.cpp @@ -450,6 +450,10 @@ void Client::HandleUdpReceive(void *aContext, otMessage *aMessage, const otMessa void Client::HandleUdpReceive(Message &aMessage, const Ip6::MessageInfo &aMessageInfo) { + // RFC1035 7.3. Resolver cannot rely that a response will come from the same address + // which it sent the corresponding query to. + OT_UNUSED_VARIABLE(aMessageInfo); + otError error = OT_ERROR_NONE; Header responseHeader; QueryMetadata queryMetadata; @@ -457,10 +461,6 @@ void Client::HandleUdpReceive(Message &aMessage, const Ip6::MessageInfo &aMessag Message * message = NULL; uint16_t offset; - // RFC1035 7.3. Resolver cannot rely that a response will come from the same address - // which it sent the corresponding query to. - OT_UNUSED_VARIABLE(aMessageInfo); - VerifyOrExit(aMessage.Read(aMessage.GetOffset(), sizeof(responseHeader), &responseHeader) == sizeof(responseHeader)); VerifyOrExit(responseHeader.GetType() == Header::kTypeResponse && responseHeader.GetQuestionCount() == 1 && diff --git a/src/core/net/sntp_client.cpp b/src/core/net/sntp_client.cpp index acb43d7b0..2ba966742 100644 --- a/src/core/net/sntp_client.cpp +++ b/src/core/net/sntp_client.cpp @@ -328,14 +328,14 @@ void Client::HandleUdpReceive(void *aContext, otMessage *aMessage, const otMessa void Client::HandleUdpReceive(Message &aMessage, const Ip6::MessageInfo &aMessageInfo) { + OT_UNUSED_VARIABLE(aMessageInfo); + otError error = OT_ERROR_NONE; Header responseHeader; QueryMetadata queryMetadata; Message * message = NULL; uint64_t unixTime = 0; - OT_UNUSED_VARIABLE(aMessageInfo); - VerifyOrExit(aMessage.Read(aMessage.GetOffset(), sizeof(responseHeader), &responseHeader) == sizeof(responseHeader)); diff --git a/src/core/thread/address_resolver.cpp b/src/core/thread/address_resolver.cpp index 71c6e08cd..52f91a714 100644 --- a/src/core/thread/address_resolver.cpp +++ b/src/core/thread/address_resolver.cpp @@ -185,6 +185,8 @@ const char *AddressResolver::ConvertInvalidationReasonToString(InvalidationReaso void AddressResolver::InvalidateCacheEntry(Cache &aEntry, InvalidationReason aReason) { + OT_UNUSED_VARIABLE(aReason); + for (int i = 0; i < kCacheEntries; i++) { if (mCache[i].mAge > aEntry.mAge) @@ -212,8 +214,6 @@ void AddressResolver::InvalidateCacheEntry(Cache &aEntry, InvalidationReason aRe aEntry.mAge = kCacheEntries - 1; aEntry.mState = Cache::kStateInvalid; - - OT_UNUSED_VARIABLE(aReason); } void AddressResolver::UpdateCacheEntry(const Ip6::Address &aEid, Mac::ShortAddress aRloc16) @@ -759,17 +759,19 @@ void AddressResolver::HandleIcmpReceive(void * aContext, const otMessageInfo *aMessageInfo, const otIcmp6Header *aIcmpHeader) { + OT_UNUSED_VARIABLE(aMessageInfo); + static_cast(aContext)->HandleIcmpReceive(*static_cast(aMessage), *static_cast(aMessageInfo), *static_cast(aIcmpHeader)); - - OT_UNUSED_VARIABLE(aMessageInfo); } void AddressResolver::HandleIcmpReceive(Message & aMessage, const Ip6::MessageInfo &aMessageInfo, const Ip6::IcmpHeader & aIcmpHeader) { + OT_UNUSED_VARIABLE(aMessageInfo); + Ip6::Header ip6Header; VerifyOrExit(aIcmpHeader.GetType() == Ip6::IcmpHeader::kTypeDstUnreach); @@ -786,7 +788,7 @@ void AddressResolver::HandleIcmpReceive(Message & aMessage, } exit: - OT_UNUSED_VARIABLE(aMessageInfo); + return; } } // namespace ot diff --git a/src/core/thread/mle.cpp b/src/core/thread/mle.cpp index 656daacd1..e79ac769b 100644 --- a/src/core/thread/mle.cpp +++ b/src/core/thread/mle.cpp @@ -3292,6 +3292,8 @@ exit: otError Mle::HandleChildIdResponse(const Message &aMessage, const Ip6::MessageInfo &aMessageInfo) { + OT_UNUSED_VARIABLE(aMessageInfo); + ThreadNetif & netif = GetNetif(); otError error = OT_ERROR_NONE; LeaderDataTlv leaderData; @@ -3409,7 +3411,6 @@ exit: otLogWarnMleErr(error, "Failed to process Child ID Response"); } - OT_UNUSED_VARIABLE(aMessageInfo); return error; } @@ -3591,6 +3592,8 @@ exit: otError Mle::HandleAnnounce(const Message &aMessage, const Ip6::MessageInfo &aMessageInfo) { + OT_UNUSED_VARIABLE(aMessageInfo); + otError error = OT_ERROR_NONE; ChannelTlv channelTlv; ActiveTimestampTlv timestamp; @@ -3655,7 +3658,6 @@ otError Mle::HandleAnnounce(const Message &aMessage, const Ip6::MessageInfo &aMe } exit: - OT_UNUSED_VARIABLE(aMessageInfo); return error; } @@ -4079,19 +4081,19 @@ void Mle::UpdateParentSearchState(void) void Mle::LogMleMessage(const char *aLogString, const Ip6::Address &aAddress) const { - otLogInfoMle("%s (%s)", aLogString, aAddress.ToString().AsCString()); - OT_UNUSED_VARIABLE(aLogString); OT_UNUSED_VARIABLE(aAddress); + + otLogInfoMle("%s (%s)", aLogString, aAddress.ToString().AsCString()); } void Mle::LogMleMessage(const char *aLogString, const Ip6::Address &aAddress, uint16_t aRloc) const { - otLogInfoMle("%s (%s,0x%04x)", aLogString, aAddress.ToString().AsCString(), aRloc); - OT_UNUSED_VARIABLE(aLogString); OT_UNUSED_VARIABLE(aAddress); OT_UNUSED_VARIABLE(aRloc); + + otLogInfoMle("%s (%s,0x%04x)", aLogString, aAddress.ToString().AsCString(), aRloc); } const char *Mle::RoleToString(otDeviceRole aRole) diff --git a/src/core/thread/network_data_leader_ftd.cpp b/src/core/thread/network_data_leader_ftd.cpp index 1b907a2b6..385224cb9 100644 --- a/src/core/thread/network_data_leader_ftd.cpp +++ b/src/core/thread/network_data_leader_ftd.cpp @@ -819,6 +819,11 @@ exit: otError Leader::AddNetworkData(uint8_t *aTlvs, uint8_t aTlvsLength, uint8_t *aOldTlvs, uint8_t aOldTlvsLength) { +#if !OPENTHREAD_ENABLE_SERVICE + OT_UNUSED_VARIABLE(aOldTlvs); + OT_UNUSED_VARIABLE(aOldTlvsLength); +#endif + otError error = OT_ERROR_NONE; NetworkDataTlv *cur = reinterpret_cast(aTlvs); NetworkDataTlv *end = reinterpret_cast(aTlvs + aTlvsLength); @@ -849,11 +854,6 @@ otError Leader::AddNetworkData(uint8_t *aTlvs, uint8_t aTlvsLength, uint8_t *aOl cur = cur->GetNext(); } -#if !OPENTHREAD_ENABLE_SERVICE - OT_UNUSED_VARIABLE(aOldTlvs); - OT_UNUSED_VARIABLE(aOldTlvsLength); -#endif - otDumpDebgNetData("add done", mTlvs, mLength); exit: diff --git a/src/diag/diag_process.cpp b/src/diag/diag_process.cpp index 5ca2893f7..35305b838 100644 --- a/src/diag/diag_process.cpp +++ b/src/diag/diag_process.cpp @@ -115,11 +115,11 @@ void Diag::AppendErrorResult(otError aError, char *aOutput, size_t aOutputMaxLen void Diag::ProcessStart(int aArgCount, char *aArgVector[], char *aOutput, size_t aOutputMaxLen) { - otError error = OT_ERROR_NONE; - OT_UNUSED_VARIABLE(aArgCount); OT_UNUSED_VARIABLE(aArgVector); + otError error = OT_ERROR_NONE; + otPlatRadioEnable(sInstance); otPlatRadioSetPromiscuous(sInstance, true); otPlatAlarmMilliStop(sInstance); @@ -134,11 +134,11 @@ exit: void Diag::ProcessStop(int aArgCount, char *aArgVector[], char *aOutput, size_t aOutputMaxLen) { - otError error = OT_ERROR_NONE; - OT_UNUSED_VARIABLE(aArgCount); OT_UNUSED_VARIABLE(aArgVector); + otError error = OT_ERROR_NONE; + VerifyOrExit(otPlatDiagModeGet(), error = OT_ERROR_INVALID_STATE); otPlatAlarmMilliStop(sInstance); @@ -291,11 +291,11 @@ exit: void Diag::ProcessStats(int aArgCount, char *aArgVector[], char *aOutput, size_t aOutputMaxLen) { - otError error = OT_ERROR_NONE; - OT_UNUSED_VARIABLE(aArgCount); OT_UNUSED_VARIABLE(aArgVector); + otError error = OT_ERROR_NONE; + VerifyOrExit(otPlatDiagModeGet(), error = OT_ERROR_INVALID_STATE); snprintf(aOutput, aOutputMaxLen, diff --git a/src/ncp/ncp_base.cpp b/src/ncp/ncp_base.cpp index b45452f66..987955dfc 100644 --- a/src/ncp/ncp_base.cpp +++ b/src/ncp/ncp_base.cpp @@ -1148,10 +1148,10 @@ otError NcpBase::CommandHandler_NOOP(uint8_t aHeader) otError NcpBase::CommandHandler_RESET(uint8_t aHeader) { - otError error = OT_ERROR_NONE; - OT_UNUSED_VARIABLE(aHeader); + otError error = OT_ERROR_NONE; + // Signal a platform reset. If implemented, this function // shouldn't return. otInstanceReset(mInstance); @@ -2158,6 +2158,9 @@ exit: otError otNcpRegisterPeekPokeDelagates(otNcpDelegateAllowPeekPoke aAllowPeekDelegate, otNcpDelegateAllowPeekPoke aAllowPokeDelegate) { + OT_UNUSED_VARIABLE(aAllowPeekDelegate); + OT_UNUSED_VARIABLE(aAllowPokeDelegate); + otError error = OT_ERROR_NONE; #if OPENTHREAD_CONFIG_NCP_ENABLE_PEEK_POKE @@ -2168,9 +2171,6 @@ otError otNcpRegisterPeekPokeDelagates(otNcpDelegateAllowPeekPoke aAllowPeekDele ncp->RegisterPeekPokeDelagates(aAllowPeekDelegate, aAllowPokeDelegate); } #else - OT_UNUSED_VARIABLE(aAllowPeekDelegate); - OT_UNUSED_VARIABLE(aAllowPokeDelegate); - error = OT_ERROR_DISABLED_FEATURE; #endif // OPENTHREAD_CONFIG_NCP_ENABLE_PEEK_POKE @@ -2197,6 +2197,9 @@ otError otNcpStreamWrite(int aStreamId, const uint8_t *aDataPtr, int aDataLen) extern "C" void otNcpPlatLogv(otLogLevel aLogLevel, otLogRegion aLogRegion, const char *aFormat, va_list aArgs) { + OT_UNUSED_VARIABLE(aLogLevel); + OT_UNUSED_VARIABLE(aLogRegion); + char logString[OPENTHREAD_CONFIG_NCP_SPINEL_LOG_MAX_SIZE]; int charsWritten; @@ -2209,9 +2212,6 @@ extern "C" void otNcpPlatLogv(otLogLevel aLogLevel, otLogRegion aLogRegion, cons otNcpStreamWrite(0, reinterpret_cast(logString), charsWritten); } - - OT_UNUSED_VARIABLE(aLogLevel); - OT_UNUSED_VARIABLE(aLogRegion); } #if (OPENTHREAD_CONFIG_LOG_OUTPUT == OPENTHREAD_CONFIG_LOG_OUTPUT_NCP_SPINEL) diff --git a/src/ncp/ncp_base_radio.cpp b/src/ncp/ncp_base_radio.cpp index 99e344752..5b38f730f 100644 --- a/src/ncp/ncp_base_radio.cpp +++ b/src/ncp/ncp_base_radio.cpp @@ -105,6 +105,8 @@ void NcpBase::LinkRawTransmitDone(otInstance *, otRadioFrame *aFrame, otRadioFra void NcpBase::LinkRawTransmitDone(otRadioFrame *aFrame, otRadioFrame *aAckFrame, otError aError) { + OT_UNUSED_VARIABLE(aFrame); + if (mCurTransmitTID) { uint8_t header = SPINEL_HEADER_FLAG | SPINEL_HEADER_IID_0 | mCurTransmitTID; @@ -138,7 +140,6 @@ void NcpBase::LinkRawTransmitDone(otRadioFrame *aFrame, otRadioFrame *aAckFrame, } exit: - OT_UNUSED_VARIABLE(aFrame); return; } diff --git a/src/posix/platform/hdlc_interface.cpp b/src/posix/platform/hdlc_interface.cpp index 8270a97b2..10c12743d 100644 --- a/src/posix/platform/hdlc_interface.cpp +++ b/src/posix/platform/hdlc_interface.cpp @@ -445,12 +445,12 @@ void HdlcInterface::HandleHdlcFrame(void *aContext, uint8_t *aFrame, uint16_t aF void HdlcInterface::HandleHdlcError(void *aContext, otError aError, uint8_t *aFrame, uint16_t aFrameLength) { - otLogWarnPlat("Error decoding hdlc frame: %s", otThreadErrorToString(aError)); - OT_UNUSED_VARIABLE(aContext); OT_UNUSED_VARIABLE(aError); OT_UNUSED_VARIABLE(aFrame); OT_UNUSED_VARIABLE(aFrameLength); + + otLogWarnPlat("Error decoding hdlc frame: %s", otThreadErrorToString(aError)); } } // namespace PosixApp diff --git a/src/posix/platform/logging.c b/src/posix/platform/logging.c index 39d811677..ba88015f7 100644 --- a/src/posix/platform/logging.c +++ b/src/posix/platform/logging.c @@ -59,14 +59,14 @@ void platformLoggingInit(const char *aName) (OPENTHREAD_CONFIG_LOG_OUTPUT == OPENTHREAD_CONFIG_LOG_OUTPUT_NCP_SPINEL) OT_TOOL_WEAK void otPlatLog(otLogLevel aLogLevel, otLogRegion aLogRegion, const char *aFormat, ...) { + OT_UNUSED_VARIABLE(aLogRegion); + char logString[LOGGING_MAX_LOG_STRING_SIZE]; int charsWritten; va_list args; int logLevel; unsigned int offset = 0; - OT_UNUSED_VARIABLE(aLogRegion); - charsWritten = snprintf(&logString[offset], sizeof(logString), "[%" PRIx64 "] ", gNodeId); otEXPECT_ACTION(charsWritten >= 0, logString[offset] = 0); offset += (unsigned int)charsWritten; diff --git a/src/posix/platform/misc.c b/src/posix/platform/misc.c index f4ee9e4f5..dbfd25e23 100644 --- a/src/posix/platform/misc.c +++ b/src/posix/platform/misc.c @@ -67,10 +67,10 @@ void otPlatWakeHost(void) otError otPlatSetMcuPowerState(otInstance *aInstance, otPlatMcuPowerState aState) { - otError error = OT_ERROR_NONE; - OT_UNUSED_VARIABLE(aInstance); + otError error = OT_ERROR_NONE; + switch (aState) { case OT_PLAT_MCU_POWER_STATE_ON: diff --git a/src/posix/platform/radio_spinel.cpp b/src/posix/platform/radio_spinel.cpp index a1ebb99cc..abc4e4ded 100644 --- a/src/posix/platform/radio_spinel.cpp +++ b/src/posix/platform/radio_spinel.cpp @@ -189,13 +189,13 @@ static otError SpinelStatusToOtError(spinel_status_t aError) static void LogIfFail(const char *aText, otError aError) { + OT_UNUSED_VARIABLE(aText); + OT_UNUSED_VARIABLE(aError); + if (aError != OT_ERROR_NONE) { otLogWarnPlat("%s: %s", aText, otThreadErrorToString(aError)); } - - OT_UNUSED_VARIABLE(aText); - OT_UNUSED_VARIABLE(aError); } void HdlcInterface::Callbacks::HandleReceivedFrame(const uint8_t *aBuffer, uint16_t aLength) diff --git a/src/posix/platform/settings.cpp b/src/posix/platform/settings.cpp index f482144f4..a2507fd38 100644 --- a/src/posix/platform/settings.cpp +++ b/src/posix/platform/settings.cpp @@ -134,10 +134,10 @@ static void swapDiscard(int aFd) void otPlatSettingsInit(otInstance *aInstance) { - otError error = OT_ERROR_NONE; - OT_UNUSED_VARIABLE(aInstance); + otError error = OT_ERROR_NONE; + { struct stat st; @@ -181,11 +181,12 @@ exit: otError otPlatSettingsGet(otInstance *aInstance, uint16_t aKey, int aIndex, uint8_t *aValue, uint16_t *aValueLength) { + OT_UNUSED_VARIABLE(aInstance); + otError error = OT_ERROR_NOT_FOUND; const off_t size = lseek(sSettingsFd, 0, SEEK_END); off_t offset = lseek(sSettingsFd, 0, SEEK_SET); - OT_UNUSED_VARIABLE(aInstance); VerifyOrExit(offset == 0 && size >= 0, error = OT_ERROR_PARSE); while (offset < size) @@ -243,11 +244,11 @@ otError otPlatSettingsSet(otInstance *aInstance, uint16_t aKey, const uint8_t *a otError otPlatSettingsAdd(otInstance *aInstance, uint16_t aKey, const uint8_t *aValue, uint16_t aValueLength) { + OT_UNUSED_VARIABLE(aInstance); + off_t size = lseek(sSettingsFd, 0, SEEK_END); int swapFd = swapOpen(); - OT_UNUSED_VARIABLE(aInstance); - if (size > 0) { VerifyOrDie(0 == lseek(sSettingsFd, 0, SEEK_SET)); @@ -265,12 +266,13 @@ otError otPlatSettingsAdd(otInstance *aInstance, uint16_t aKey, const uint8_t *a otError otPlatSettingsDelete(otInstance *aInstance, uint16_t aKey, int aIndex) { + OT_UNUSED_VARIABLE(aInstance); + otError error = OT_ERROR_NOT_FOUND; off_t size = lseek(sSettingsFd, 0, SEEK_END); off_t offset = lseek(sSettingsFd, 0, SEEK_SET); int swapFd = swapOpen(); - OT_UNUSED_VARIABLE(aInstance); assert(swapFd != -1); assert(offset == 0); VerifyOrExit(offset == 0 && size >= 0, error = OT_ERROR_PARSE);