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>
This commit is contained in:
parent
cbde1edc41
commit
958872648a
1 changed files with 18 additions and 4 deletions
|
@ -90,10 +90,16 @@ otError otPlatDiagProcess(otInstance *aInstance, uint8_t aArgsLength, char *aArg
|
||||||
|
|
||||||
void otPlatDiagModeSet(bool aMode)
|
void otPlatDiagModeSet(bool aMode)
|
||||||
{
|
{
|
||||||
|
otError error;
|
||||||
|
|
||||||
sDiagMode = aMode;
|
sDiagMode = aMode;
|
||||||
|
|
||||||
if (!sDiagMode) {
|
if (!sDiagMode) {
|
||||||
otPlatRadioSleep(NULL);
|
error = otPlatRadioSleep(NULL);
|
||||||
|
if (error != OT_ERROR_NONE) {
|
||||||
|
otPlatLog(OT_LOG_LEVEL_WARN, OT_LOG_REGION_PLATFORM,
|
||||||
|
"%s failed (%d)", "otPlatRadioSleep", error);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -345,6 +351,7 @@ static otError startModCarrier(otInstance *aInstance, uint8_t aArgsLength, char
|
||||||
void otPlatDiagAlarmCallback(otInstance *aInstance)
|
void otPlatDiagAlarmCallback(otInstance *aInstance)
|
||||||
{
|
{
|
||||||
uint32_t now;
|
uint32_t now;
|
||||||
|
otError error;
|
||||||
otRadioFrame *txPacket;
|
otRadioFrame *txPacket;
|
||||||
const uint16_t diag_packet_len = 30;
|
const uint16_t diag_packet_len = 30;
|
||||||
|
|
||||||
|
@ -370,7 +377,11 @@ void otPlatDiagAlarmCallback(otInstance *aInstance)
|
||||||
txPacket->mPsdu[i] = i;
|
txPacket->mPsdu[i] = i;
|
||||||
}
|
}
|
||||||
|
|
||||||
otPlatRadioTransmit(aInstance, txPacket);
|
error = otPlatRadioTransmit(aInstance, txPacket);
|
||||||
|
if (error != OT_ERROR_NONE) {
|
||||||
|
otPlatLog(OT_LOG_LEVEL_WARN, OT_LOG_REGION_PLATFORM,
|
||||||
|
"%s failed (%d)", "otPlatRadioTransmit", error);
|
||||||
|
}
|
||||||
|
|
||||||
if (sTxCount != -1) {
|
if (sTxCount != -1) {
|
||||||
sTxCount--;
|
sTxCount--;
|
||||||
|
@ -405,8 +416,11 @@ static otError processTransmit(otInstance *aInstance, uint8_t aArgsLength, char
|
||||||
otPlatAlarmMilliStop(aInstance);
|
otPlatAlarmMilliStop(aInstance);
|
||||||
diag_output("diagnostic message transmission is stopped\r\n");
|
diag_output("diagnostic message transmission is stopped\r\n");
|
||||||
sTransmitMode = DIAG_TRANSMIT_MODE_IDLE;
|
sTransmitMode = DIAG_TRANSMIT_MODE_IDLE;
|
||||||
otPlatRadioReceive(aInstance, sChannel);
|
error = otPlatRadioReceive(aInstance, sChannel);
|
||||||
|
if (error != OT_ERROR_NONE) {
|
||||||
|
otPlatLog(OT_LOG_LEVEL_WARN, OT_LOG_REGION_PLATFORM,
|
||||||
|
"%s failed (%d)", "otPlatRadioReceive", error);
|
||||||
|
}
|
||||||
} else if (strcmp(aArgs[0], "start") == 0) {
|
} else if (strcmp(aArgs[0], "start") == 0) {
|
||||||
if (sTransmitMode != DIAG_TRANSMIT_MODE_IDLE) {
|
if (sTransmitMode != DIAG_TRANSMIT_MODE_IDLE) {
|
||||||
return OT_ERROR_INVALID_STATE;
|
return OT_ERROR_INVALID_STATE;
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue