Skip to content

Commit e6b432e

Browse files
edmontcarlescufi
authored andcommitted
[nrf fromtree] net: openthread: fix handling tx done to report all kind of errors
Fix bug in radio implementation that reported any transmit error as `OT_ERROR_NO_ACK` to OpenThread. Signed-off-by: Eduardo Montoya <[email protected]> (cherry picked from commit a0093ee)
1 parent 0a1769c commit e6b432e

File tree

2 files changed

+5
-34
lines changed

2 files changed

+5
-34
lines changed

subsys/net/lib/openthread/platform/radio.c

Lines changed: 2 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -336,18 +336,8 @@ static inline void handle_tx_done(otInstance *aInstance)
336336
if (IS_ENABLED(CONFIG_OPENTHREAD_DIAG) && otPlatDiagModeGet()) {
337337
otPlatDiagRadioTransmitDone(aInstance, &sTransmitFrame, tx_result);
338338
} else {
339-
if (sTransmitFrame.mPsdu[0] & IEEE802154_AR_FLAG_SET) {
340-
if (ack_frame.mLength == 0) {
341-
LOG_DBG("No ACK received.");
342-
otPlatRadioTxDone(aInstance, &sTransmitFrame,
343-
NULL, OT_ERROR_NO_ACK);
344-
} else {
345-
otPlatRadioTxDone(aInstance, &sTransmitFrame,
346-
&ack_frame, tx_result);
347-
}
348-
} else {
349-
otPlatRadioTxDone(aInstance, &sTransmitFrame, NULL, tx_result);
350-
}
339+
otPlatRadioTxDone(aInstance, &sTransmitFrame, ack_frame.mLength ? &ack_frame : NULL,
340+
tx_result);
351341
ack_frame.mLength = 0;
352342
}
353343
}

tests/subsys/openthread/radio_test.c

Lines changed: 3 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -430,8 +430,7 @@ static void test_tx_test(void)
430430
ztest_expect_value(set_channel_mock, channel, chan);
431431
ztest_expect_value(set_txpower_mock, dbm, power);
432432
ztest_expect_value(start_mock, dev, &radio);
433-
zassert_equal(otPlatRadioReceive(ot, chan), OT_ERROR_NONE,
434-
"Failed to receive.");
433+
zassert_equal(otPlatRadioReceive(ot, chan), OT_ERROR_NONE, "Failed to receive.");
435434

436435
/* ACKed frame */
437436
frm->mChannel = chan2;
@@ -442,8 +441,7 @@ static void test_tx_test(void)
442441
ztest_expect_value(cca_mock, dev, &radio);
443442
ztest_expect_value(tx_mock, frag->data, frm->mPsdu);
444443
ztest_expect_value(set_txpower_mock, dbm, power);
445-
zassert_equal(otPlatRadioTransmit(ot, frm), OT_ERROR_NONE,
446-
"Transmit failed.");
444+
zassert_equal(otPlatRadioTransmit(ot, frm), OT_ERROR_NONE, "Transmit failed.");
447445

448446
create_ack_frame();
449447
make_sure_sem_set(Z_TIMEOUT_MS(100));
@@ -460,27 +458,10 @@ static void test_tx_test(void)
460458
ztest_expect_value(set_channel_mock, channel, chan2);
461459
ztest_expect_value(tx_mock, frag->data, frm->mPsdu);
462460
ztest_expect_value(set_txpower_mock, dbm, power);
463-
zassert_equal(otPlatRadioTransmit(ot, frm), OT_ERROR_NONE,
464-
"Transmit failed.");
461+
zassert_equal(otPlatRadioTransmit(ot, frm), OT_ERROR_NONE, "Transmit failed.");
465462
make_sure_sem_set(Z_TIMEOUT_MS(100));
466463
ztest_expect_value(otPlatRadioTxDone, aError, OT_ERROR_NONE);
467464
platformRadioProcess(ot);
468-
469-
/* ACKed frame, no ACK */
470-
frm->mChannel = --chan2;
471-
frm->mInfo.mTxInfo.mCsmaCaEnabled = false;
472-
frm->mPsdu[0] = IEEE802154_AR_FLAG_SET;
473-
474-
ztest_returns_value(set_channel_mock, 0);
475-
ztest_expect_value(set_channel_mock, channel, chan2);
476-
ztest_expect_value(tx_mock, frag->data, frm->mPsdu);
477-
ztest_expect_value(set_txpower_mock, dbm, power);
478-
zassert_equal(otPlatRadioTransmit(ot, frm), OT_ERROR_NONE,
479-
"Transmit failed.");
480-
make_sure_sem_set(Z_TIMEOUT_MS(100));
481-
482-
ztest_expect_value(otPlatRadioTxDone, aError, OT_ERROR_NO_ACK);
483-
platformRadioProcess(ot);
484465
}
485466

486467
/**

0 commit comments

Comments
 (0)