Skip to content

net/ieee802154: add timed transmission - #23031

Open
Stopkaa wants to merge 5 commits into
RIOT-OS:masterfrom
Stopkaa:timed-transmission
Open

Stopkaa wants to merge 5 commits into
RIOT-OS:masterfrom
Stopkaa:timed-transmission

Conversation

@Stopkaa

@Stopkaa Stopkaa commented Oct 29, 2026

Copy link
Copy Markdown
Contributor

Contribution description

This PR introduces timed tranmission for the radio HAL. Timed transmission is useful in various MAC-Layers and Protocols like TSCH(openwsn), DSME(opendsme) or Thread(openthread). Right now this functionality is unused but feel free to pick this up.
Could be also used in #22539. Also this can be used for periodically send 15.4 frames like in the hal-test

Testing procedure

Run the HAL test for the support devices tests/net/ieee802154_hal and execute the txtsnd_after command:
NRF52840DK

txtsnd_after FF:FF 10 5000
2026-10-29 11:02:44,759 # txtsnd_after FF:FF 10 5000
2026-10-29 11:02:44,762 # Sending at radio time 383640229
2026-10-29 11:02:49,762 # Transmission succeeded

ESP32C6-devkit

 txtsnd_after FF:FF 10 5000   
2026-10-29 11:07:38,638 # txtsnd_after FF:FF 10 5000  
2026-10-29 11:07:38,640 # Sending at radio time 109272382  
2026-10-29 11:07:43,638 # Transmission succeeded  

FRDM-KW41Z

  
txtsnd_after FF:FF 10 5000
2026-10-29 11:12:27,596 # txtsnd_after FF:FF 10 5000
2026-10-29 11:12:27,600 # Sending at radio time 55356224
2026-10-29 11:12:32,599 # Transmission succeeded

Issues/PRs references

  • none

Declaration of AI-Tools / LLMs usage:

AI-Tools / LLMs that were used are:

  • Claude Opus 5.5 for documentation and research on the timer capabilitys of different radios

@github-actions github-actions Bot added Platform: ARM Platform: This PR/issue effects ARM-based platforms Area: network Area: Networking Area: tests Area: tests and testing framework Area: drivers Area: Device drivers Platform: ESP Platform: This PR/issue effects ESP-based platforms Area: cpu Area: CPU/MCU ports Area: sys Area: System labels Oct 29, 2026
@Stopkaa Stopkaa added CI: ready for build If set, CI server will compile all applications for all available boards for the labeled PR AI: Co-Authored PR/Issue relies on AI. Documentation / Code was partly generated by AI. labels Oct 29, 2026
@crasbe crasbe added the Type: new feature The issue requests / The PR implemements a new feature for RIOT label Oct 29, 2026
@riot-ci

riot-ci commented Oct 29, 2026

Copy link
Copy Markdown

Murdock results

❌ FAILED

710d72e tests/net/ieee802154_hal: add timed tx test

Success Failures Total Runtime
943 1 13041 02m:03s
Build failures (1)
Application Target Toolchain Runtime (s) Worker
tests/pkg/openwsn nrf52840dk gnu 2.80 mobi6

Artifacts

* @brief Get the current radio time
*
* The radio time is a free running counter in microseconds that wraps
* around at 2^32. It is only valid while the device is on. Time values

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
* around at 2^32. It is only valid while the device is on. Time values
* around at 2^32. It is only valid while the device is on.

Comment on lines +1024 to +1025
* @pre The device is on
* @pre The device supports @ref IEEE802154_CAP_TIMED_TX

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
* @pre The device is on
* @pre The device supports @ref IEEE802154_CAP_TIMED_TX
* @pre The device is on.
* @pre The device supports @ref IEEE802154_CAP_TIMED_TX.

@gschorcht gschorcht Oct 29, 2026 •

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I know, the period at the end of this short sentence is also missing in other functions, but this doesn't make it right 😉

Comment on lines +9 to 12
#include "esp_timer.h"
#include "iolist.h"
#include "log.h"
#include "net/ieee802154/radio.h"

@gschorcht gschorcht Oct 29, 2026 •

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
#include "esp_timer.h"
#include "iolist.h"
#include "log.h"
#include "net/ieee802154/radio.h"
#include "iolist.h"
#include "log.h"
#include "net/ieee802154/radio.h"

static uint32_t _get_time(ieee802154_dev_t *dev)
{
(void)dev;
return (uint32_t)esp_timer_get_time();

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
return (uint32_t)esp_timer_get_time();
return ztimer::get_now(ZTIMER_MSEC);

From the very beginning, the goal was to keep the RIOT code as independent as possible from ESP-IDF in order to limit the amount of source code that needed to be compiled in from ESP-IDF. The dependencies between the ESP-IDF modules are very complex and more and more ESP-IDF source code must be compiled in very quickly, which makes the manual maintenance of the Makefiles in cpu/esp32/esp-idf very hard. For this reason, various basic functions have been implemented in RIOT, including a system time in milliseconds that can be retrieved using system_get_time.

Since we already use ztimer_msec modul, the RIOT function should be used.

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I've given it some more thought. If the intention was to use a timer that is independent of RIOT's ztimer, you should use system_get_time to be independent of ESP-IDF, even though the ESP-IDF IEEE 802.15.4 driver uses esp_timer_get_time internally.

Suggested change
return (uint32_t)esp_timer_get_time();
return (uint32_t)system_get_time();

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

That's some useful insight I didn't have. The idea behind it was if the radio has a dedicated only for the radio it should be used instead of ztimer if this not the case for example at86rf233 don't have such a timer the functionality would be offloaded to the submac instead. Going through the esp code I notice that the transmit_at function uses esp_timer_get_time() and thought it would use the dedicated timer then. But didn't seems like it would

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Okay, I've thought about it some more 🤔 As you suggested 👍, we should use esp_timer_get_time instead of system_get_time here. So please ignore my change request.

The reason for this is that system_get_time uses a different timer than esp_timer_get_time. While system_get_time uses a real timer (TIMER_0 from TIMER_GROUP_0) for the system time, esp_timer_get_time uses a special system timer peripheral. On the ESP32, an additional counter (the LACT) from TIMER_GROUP_0 is used; all other ESP32x SoC variants have a dedicated SYSTIMER peripheral that is used for the system time.

Since the implementation of esp_ieee80215_transmit_at uses the ESP-IDF system time as its time base, we should also use this for our interface. The time returned by esp_time_get_time is likely to differ slightly from the time returned by system_get_time.

Since the ESP-IDF esp_timer is compiled in anyway in cpu/esp32/esp-idf/common, using the esp_timer_get_time function here doesn't increase the dependency on ESP-IDF.

Sorry for the confusion.

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This discussion inspires me to clean up the implementation of the system time in RIOT for the ESP32. Since we’re including the ESP-IDF module esp_timer anyway, we could implement the function system_get_time based on esp_timer_get_time.

The reason system_get_time hasn’t relied on esp_time_get_time until now is that, in earlier versions of ESP-IDF, it wasn’t necessary to include the esp_timer module. This requirement was added over time, but system_get_time wasn’t updated accordingly.

This branch has not been deployed

No deployments
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

AI: Co-Authored PR/Issue relies on AI. Documentation / Code was partly generated by AI. Area: cpu Area: CPU/MCU ports Area: drivers Area: Device drivers Area: network Area: Networking Area: sys Area: System Area: tests Area: tests and testing framework CI: ready for build If set, CI server will compile all applications for all available boards for the labeled PR Platform: ARM Platform: This PR/issue effects ARM-based platforms Platform: ESP Platform: This PR/issue effects ESP-based platforms Type: new feature The issue requests / The PR implemements a new feature for RIOT

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants