Skip to content

Commit 683b945

Browse files
committed
[nrf fromlist] net: openthread: support Kconfig IEEE802154_SELECTIVE_TXCHANNEL
For transmit_message if the transmission is timed and underlying driver supports `IEEE802154_HW_SELECTIVE_TXCHANNEL` then use the selective txchannel feature for transmission. This does not change the current `channel` at the moment of call, the driver will transmit the message on the channel selected through `net_pkt_set_ieee802154_txchannel` then (after receiving an ACK if requested) it will return to the original channel. When Kconfig option IEEE802154_SELECTIVE_TXCHANNEL is turned on, the timed transmissions scheduled some time ahead on different channel will not abort ongoing reception until the exact moment of transmission comes. Upstream PR: zephyrproject-rtos/zephyr#79919 Signed-off-by: Andrzej Kuroś <[email protected]>
1 parent 8d44d12 commit 683b945

File tree

1 file changed

+18
-4
lines changed

1 file changed

+18
-4
lines changed

modules/openthread/platform/radio.c

Lines changed: 18 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -381,6 +381,12 @@ void platformRadioInit(void)
381381
radio_api->configure(radio_dev, IEEE802154_CONFIG_EVENT_HANDLER, &cfg);
382382
}
383383

384+
static void radio_set_channel(uint16_t ch)
385+
{
386+
channel = ch;
387+
radio_api->set_channel(radio_dev, ch);
388+
}
389+
384390
void transmit_message(struct k_work *tx_job)
385391
{
386392
int tx_err;
@@ -396,10 +402,7 @@ void transmit_message(struct k_work *tx_job)
396402
*/
397403
tx_payload->len = sTransmitFrame.mLength - FCS_SIZE;
398404

399-
channel = sTransmitFrame.mChannel;
400-
401-
radio_api->set_channel(radio_dev, channel);
402-
radio_api->set_txpower(radio_dev, get_transmit_power_for_channel(channel));
405+
radio_api->set_txpower(radio_dev, get_transmit_power_for_channel(sTransmitFrame.mChannel));
403406

404407
#if defined(CONFIG_OPENTHREAD_TIME_SYNC)
405408
if (sTransmitFrame.mInfo.mTxInfo.mIeInfo->mTimeIeOffset != 0) {
@@ -423,10 +426,20 @@ void transmit_message(struct k_work *tx_job)
423426
uint32_t tx_at = sTransmitFrame.mInfo.mTxInfo.mTxDelayBaseTime +
424427
sTransmitFrame.mInfo.mTxInfo.mTxDelay;
425428
net_pkt_set_timestamp_ns(tx_pkt, convert_32bit_us_wrapped_to_64bit_ns(tx_at));
429+
#endif
430+
#if defined(CONFIG_IEEE802154_SELECTIVE_TXCHANNEL)
431+
if (radio_caps & IEEE802154_HW_SELECTIVE_TXCHANNEL) {
432+
net_pkt_set_ieee802154_txchannel(tx_pkt, sTransmitFrame.mChannel);
433+
} else {
434+
radio_set_channel(sTransmitFrame.mChannel);
435+
}
436+
#else
437+
radio_set_channel(sTransmitFrame.mChannel);
426438
#endif
427439
tx_err =
428440
radio_api->tx(radio_dev, IEEE802154_TX_MODE_TXTIME_CCA, tx_pkt, tx_payload);
429441
} else if (sTransmitFrame.mInfo.mTxInfo.mCsmaCaEnabled) {
442+
radio_set_channel(sTransmitFrame.mChannel);
430443
if (radio_caps & IEEE802154_HW_CSMA) {
431444
tx_err = radio_api->tx(radio_dev, IEEE802154_TX_MODE_CSMA_CA, tx_pkt,
432445
tx_payload);
@@ -438,6 +451,7 @@ void transmit_message(struct k_work *tx_job)
438451
}
439452
}
440453
} else {
454+
radio_set_channel(sTransmitFrame.mChannel);
441455
tx_err = radio_api->tx(radio_dev, IEEE802154_TX_MODE_DIRECT, tx_pkt, tx_payload);
442456
}
443457

0 commit comments

Comments
 (0)