Skip to content

Commit 9588726

Browse files
rluboskartben
authored andcommitted
net: openthread: Fix ignored return values in platform diag module
Verify return values for otPlatRadio* functions and log the error accordingly. For otPlatRadioTransmit() case, just log the error and let the entire TX procedure proceed on the next timeout. Signed-off-by: Robert Lubos <robert.lubos@nordicsemi.no>
1 parent cbde1ed commit 9588726

File tree

1 file changed

+18
-4
lines changed
  • modules/openthread/platform

1 file changed

+18
-4
lines changed

modules/openthread/platform/diag.c

Lines changed: 18 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -90,10 +90,16 @@ otError otPlatDiagProcess(otInstance *aInstance, uint8_t aArgsLength, char *aArg
9090

9191
void otPlatDiagModeSet(bool aMode)
9292
{
93+
otError error;
94+
9395
sDiagMode = aMode;
9496

9597
if (!sDiagMode) {
96-
otPlatRadioSleep(NULL);
98+
error = otPlatRadioSleep(NULL);
99+
if (error != OT_ERROR_NONE) {
100+
otPlatLog(OT_LOG_LEVEL_WARN, OT_LOG_REGION_PLATFORM,
101+
"%s failed (%d)", "otPlatRadioSleep", error);
102+
}
97103
}
98104
}
99105

@@ -345,6 +351,7 @@ static otError startModCarrier(otInstance *aInstance, uint8_t aArgsLength, char
345351
void otPlatDiagAlarmCallback(otInstance *aInstance)
346352
{
347353
uint32_t now;
354+
otError error;
348355
otRadioFrame *txPacket;
349356
const uint16_t diag_packet_len = 30;
350357

@@ -370,7 +377,11 @@ void otPlatDiagAlarmCallback(otInstance *aInstance)
370377
txPacket->mPsdu[i] = i;
371378
}
372379

373-
otPlatRadioTransmit(aInstance, txPacket);
380+
error = otPlatRadioTransmit(aInstance, txPacket);
381+
if (error != OT_ERROR_NONE) {
382+
otPlatLog(OT_LOG_LEVEL_WARN, OT_LOG_REGION_PLATFORM,
383+
"%s failed (%d)", "otPlatRadioTransmit", error);
384+
}
374385

375386
if (sTxCount != -1) {
376387
sTxCount--;
@@ -405,8 +416,11 @@ static otError processTransmit(otInstance *aInstance, uint8_t aArgsLength, char
405416
otPlatAlarmMilliStop(aInstance);
406417
diag_output("diagnostic message transmission is stopped\r\n");
407418
sTransmitMode = DIAG_TRANSMIT_MODE_IDLE;
408-
otPlatRadioReceive(aInstance, sChannel);
409-
419+
error = otPlatRadioReceive(aInstance, sChannel);
420+
if (error != OT_ERROR_NONE) {
421+
otPlatLog(OT_LOG_LEVEL_WARN, OT_LOG_REGION_PLATFORM,
422+
"%s failed (%d)", "otPlatRadioReceive", error);
423+
}
410424
} else if (strcmp(aArgs[0], "start") == 0) {
411425
if (sTransmitMode != DIAG_TRANSMIT_MODE_IDLE) {
412426
return OT_ERROR_INVALID_STATE;

0 commit comments

Comments
 (0)