Skip to content

Commit 2ea27d9

Browse files
committed
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. Signed-off-by: Andrzej Kuroś <[email protected]>
1 parent aee4803 commit 2ea27d9

File tree

1 file changed

+22
-6
lines changed

1 file changed

+22
-6
lines changed

modules/openthread/platform/radio.c

Lines changed: 22 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -379,12 +379,20 @@ void platformRadioInit(void)
379379
radio_api->configure(radio_dev, IEEE802154_CONFIG_EVENT_HANDLER, &cfg);
380380
}
381381

382+
static void radio_set_channel(uint16_t ch)
383+
{
384+
channel = ch;
385+
radio_api->set_channel(radio_dev, ch);
386+
}
387+
382388
void transmit_message(struct k_work *tx_job)
383389
{
384390
int tx_err;
385391

386392
ARG_UNUSED(tx_job);
387393

394+
enum ieee802154_hw_caps radio_caps = radio_api->get_capabilities(radio_dev);
395+
388396
/*
389397
* The payload is already in tx_payload->data,
390398
* but we need to set the length field
@@ -394,10 +402,7 @@ void transmit_message(struct k_work *tx_job)
394402
*/
395403
tx_payload->len = sTransmitFrame.mLength - FCS_SIZE;
396404

397-
channel = sTransmitFrame.mChannel;
398-
399-
radio_api->set_channel(radio_dev, channel);
400-
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));
401406

402407
#if defined(CONFIG_OPENTHREAD_TIME_SYNC)
403408
if (sTransmitFrame.mInfo.mTxInfo.mIeInfo->mTimeIeOffset != 0) {
@@ -415,17 +420,27 @@ void transmit_message(struct k_work *tx_job)
415420
sTransmitFrame.mInfo.mTxInfo.mIsSecurityProcessed);
416421
net_pkt_set_ieee802154_mac_hdr_rdy(tx_pkt, sTransmitFrame.mInfo.mTxInfo.mIsHeaderUpdated);
417422

418-
if ((radio_api->get_capabilities(radio_dev) & IEEE802154_HW_TXTIME) &&
423+
if ((radio_caps & IEEE802154_HW_TXTIME) &&
419424
(sTransmitFrame.mInfo.mTxInfo.mTxDelay != 0)) {
420425
#if defined(CONFIG_NET_PKT_TXTIME)
421426
uint32_t tx_at = sTransmitFrame.mInfo.mTxInfo.mTxDelayBaseTime +
422427
sTransmitFrame.mInfo.mTxInfo.mTxDelay;
423428
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);
424438
#endif
425439
tx_err =
426440
radio_api->tx(radio_dev, IEEE802154_TX_MODE_TXTIME_CCA, tx_pkt, tx_payload);
427441
} else if (sTransmitFrame.mInfo.mTxInfo.mCsmaCaEnabled) {
428-
if (radio_api->get_capabilities(radio_dev) & IEEE802154_HW_CSMA) {
442+
radio_set_channel(sTransmitFrame.mChannel);
443+
if (radio_caps & IEEE802154_HW_CSMA) {
429444
tx_err = radio_api->tx(radio_dev, IEEE802154_TX_MODE_CSMA_CA, tx_pkt,
430445
tx_payload);
431446
} else {
@@ -436,6 +451,7 @@ void transmit_message(struct k_work *tx_job)
436451
}
437452
}
438453
} else {
454+
radio_set_channel(sTransmitFrame.mChannel);
439455
tx_err = radio_api->tx(radio_dev, IEEE802154_TX_MODE_DIRECT, tx_pkt, tx_payload);
440456
}
441457

0 commit comments

Comments
 (0)