Repository navigation
net/ieee802154: add timed transmission #23031
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: master
Are you sure you want to change the base?
Changes from all commits
15aa926
64dfa55
4422b9f
db9e5fe
710d72e
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change | ||||||||
|---|---|---|---|---|---|---|---|---|---|---|
|
|
@@ -6,6 +6,7 @@ | |||||||||
| #include "esp_ieee802154.h" | ||||||||||
|
|
||||||||||
| #include "esp_ieee802154_hal.h" | ||||||||||
| #include "esp_timer.h" | ||||||||||
| #include "iolist.h" | ||||||||||
| #include "log.h" | ||||||||||
| #include "net/ieee802154/radio.h" | ||||||||||
|
|
@@ -31,9 +32,9 @@ | |||||||||
|
|
||||||||||
| static const ieee802154_radio_ops_t esp_ieee802154_driver; | ||||||||||
| static ieee802154_dev_t *esp_ieee802154_dev; | ||||||||||
|
|
||||||||||
| static uint8_t _tx_frame[IEEE802154_FRAME_LEN_MAX + 1]; /* additional byte 0 is used for length */ | ||||||||||
| static uint8_t *_rx_frame; | ||||||||||
|
Check warning on line 37 in cpu/esp32/esp-ieee802154/esp_ieee802154_hal.c
|
||||||||||
| static const uint8_t *_ack_frame; | ||||||||||
|
|
||||||||||
| static esp_ieee802154_frame_info_t *_rx_frame_info; | ||||||||||
|
|
@@ -109,6 +110,12 @@ | |||||||||
| return res; | ||||||||||
| } | ||||||||||
|
|
||||||||||
| static uint32_t _get_time(ieee802154_dev_t *dev) | ||||||||||
| { | ||||||||||
| (void)dev; | ||||||||||
| return (uint32_t)esp_timer_get_time(); | ||||||||||
|
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
Suggested change
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 Since we already use
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe 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
Suggested change
Contributor
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe 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
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe 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 The reason for this is that Since the implementation of Since the ESP-IDF Sorry for the confusion.
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe 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 The reason |
||||||||||
| } | ||||||||||
|
|
||||||||||
| static int _off(ieee802154_dev_t *dev) | ||||||||||
| { | ||||||||||
| (void)dev; | ||||||||||
|
|
@@ -145,6 +152,10 @@ | |||||||||
| _tx_error = ESP_IEEE802154_TX_ERR_NONE; | ||||||||||
| _ack_frame = NULL; | ||||||||||
| _ack_frame_info = NULL; | ||||||||||
| if (ctx) { | ||||||||||
| uint32_t target_us = *(const uint32_t *)ctx; | ||||||||||
| return esp_ieee802154_transmit_at(_tx_frame, _cca_send_on, target_us) ? -EIO : 0; | ||||||||||
| } | ||||||||||
| return esp_ieee802154_transmit(_tx_frame, _cca_send_on) ? -EIO : 0; | ||||||||||
| case IEEE802154_HAL_OP_SET_RX: | ||||||||||
| DEBUG("[esp_ieee802154] %s: IEEE802154_HAL_OP_SET_RX\n", __func__); | ||||||||||
|
|
@@ -195,15 +206,15 @@ | |||||||||
| esp_ieee802154_receive_handle_done(_ack_frame); | ||||||||||
| return 0; | ||||||||||
| case IEEE802154_HAL_OP_SET_RX: | ||||||||||
| DEBUG("[esp_ieee802154] %s: IEEE802154_HAL_OP_SET_RX\n", __func__); | ||||||||||
| return (!IS_ACTIVE(_USE_SET_RX) || | ||||||||||
| (state == ESP_IEEE802154_RADIO_RECEIVE)) ? 0 : -EAGAIN; | ||||||||||
| case IEEE802154_HAL_OP_SET_IDLE: | ||||||||||
|
Check warning on line 212 in cpu/esp32/esp-ieee802154/esp_ieee802154_hal.c
|
||||||||||
| DEBUG("[esp_ieee802154] %s: IEEE802154_HAL_OP_SET_IDLE\n", __func__); | ||||||||||
| return (!IS_ACTIVE(_USE_SET_IDLE) || | ||||||||||
| ((state == ESP_IEEE802154_RADIO_IDLE) || | ||||||||||
| (state == ESP_IEEE802154_RADIO_SLEEP))) ? 0 : -EAGAIN; | ||||||||||
| case IEEE802154_HAL_OP_CCA: | ||||||||||
|
Check warning on line 217 in cpu/esp32/esp-ieee802154/esp_ieee802154_hal.c
|
||||||||||
| DEBUG("[esp_ieee802154] %s: IEEE802154_HAL_OP_CCA\n", __func__); | ||||||||||
| assert(ctx); | ||||||||||
| *((bool *)ctx) = _channel_clear; | ||||||||||
|
|
@@ -249,18 +260,18 @@ | |||||||||
| assert(conf); | ||||||||||
|
|
||||||||||
| DEBUG("[esp_ieee802154] %s\n", __func__); | ||||||||||
|
|
||||||||||
| if (esp_ieee802154_set_txpower(conf->pow) || | ||||||||||
| esp_ieee802154_set_channel(conf->channel)) { | ||||||||||
| return -EIO; | ||||||||||
|
Check warning on line 266 in cpu/esp32/esp-ieee802154/esp_ieee802154_hal.c
|
||||||||||
| } | ||||||||||
|
|
||||||||||
| return 0; | ||||||||||
| } | ||||||||||
|
|
||||||||||
| static int _set_csma_params(ieee802154_dev_t *dev, const ieee802154_csma_be_t *bd, | ||||||||||
| int8_t retries) | ||||||||||
| { | ||||||||||
|
Check warning on line 274 in cpu/esp32/esp-ieee802154/esp_ieee802154_hal.c
|
||||||||||
| (void)dev; | ||||||||||
| DEBUG("[esp_ieee802154] %s %p %d\n", __func__, bd, retries); | ||||||||||
| if (retries > 0) { | ||||||||||
|
|
@@ -303,21 +314,21 @@ | |||||||||
|
|
||||||||||
| switch (cmd) { | ||||||||||
| case IEEE802154_AF_SHORT_ADDR: | ||||||||||
| const network_uint16_t *short_addr = value; | ||||||||||
| DEBUG("[esp_ieee802154] %s: set IEEE802154_AF_SHORT_ADDR %02x:%02x\n", | ||||||||||
| __func__, addr[0], addr[1]); | ||||||||||
| return esp_ieee802154_set_short_address(byteorder_ntohs(*short_addr)) ? -EIO : 0; | ||||||||||
| case IEEE802154_AF_EXT_ADDR: | ||||||||||
| DEBUG("[esp_ieee802154] %s: set IEEE802154_AF_EXT_ADDR " | ||||||||||
| "%02x:%02x:%02x:%02x:%02x:%02x:%02x:%02x\n", __func__, | ||||||||||
| addr[0], addr[1], addr[2], addr[3], addr[4], addr[5], addr[6], addr[7]); | ||||||||||
| const eui64_t *ext_addr = value; | ||||||||||
|
Check warning on line 325 in cpu/esp32/esp-ieee802154/esp_ieee802154_hal.c
|
||||||||||
| uint64_t le_addr = byteorder_swapll(ext_addr->uint64.u64); | ||||||||||
| return esp_ieee802154_set_extended_address((const uint8_t *)&le_addr) ? -EIO : 0; | ||||||||||
| case IEEE802154_AF_PANID: | ||||||||||
| DEBUG("[esp_ieee802154] %s: set IEEE802154_AF_PANID %02x:%02x\n", | ||||||||||
| __func__, addr[1], addr[0]); | ||||||||||
| return esp_ieee802154_set_panid(*((const uint16_t *)value)) ? -EIO : 0; | ||||||||||
|
Check warning on line 331 in cpu/esp32/esp-ieee802154/esp_ieee802154_hal.c
|
||||||||||
| case IEEE802154_AF_PAN_COORD: | ||||||||||
| DEBUG("[esp_ieee802154] %s: set IEEE802154_AF_PAN_COORD not supported\n", __func__); | ||||||||||
| return -ENOTSUP; | ||||||||||
|
|
@@ -330,16 +341,16 @@ | |||||||||
| const void *value) | ||||||||||
| { | ||||||||||
| (void)dev; | ||||||||||
|
|
||||||||||
| bool enable = *((bool*)value); | ||||||||||
|
|
||||||||||
| switch (cmd) { | ||||||||||
| case IEEE802154_SRC_MATCH_EN: | ||||||||||
| DEBUG("[esp_ieee802154] %s: IEEE802154_SRC_MATCH_EN %d\n", __func__, enable); | ||||||||||
| return esp_ieee802154_set_pending_mode(enable | ||||||||||
| ? ESP_IEEE802154_AUTO_PENDING_ENABLE | ||||||||||
| : ESP_IEEE802154_AUTO_PENDING_DISABLE) ? -EIO : 0; | ||||||||||
| case IEEE802154_SRC_MATCH_SHORT_ADD: | ||||||||||
|
Check warning on line 353 in cpu/esp32/esp-ieee802154/esp_ieee802154_hal.c
|
||||||||||
| DEBUG("[esp_ieee802154] %s: set IEEE802154_SRC_MATCH_SHORT_ADD\n", __func__); | ||||||||||
| return esp_ieee802154_add_pending_addr(value, true) ? -ENOMEM : 0; | ||||||||||
| case IEEE802154_SRC_MATCH_SHORT_CLEAR: | ||||||||||
|
|
@@ -465,7 +476,8 @@ | |||||||||
| | IEEE802154_CAP_IRQ_TX_START | ||||||||||
| #endif | ||||||||||
| | IEEE802154_CAP_IRQ_TX_DONE | ||||||||||
| | IEEE802154_CAP_IRQ_ACK_TIMEOUT, | ||||||||||
| | IEEE802154_CAP_IRQ_ACK_TIMEOUT | ||||||||||
| | IEEE802154_CAP_TIMED_TX, | ||||||||||
| .write = _write, | ||||||||||
| .read = _read, | ||||||||||
| .request_on = _request_on, | ||||||||||
|
|
@@ -480,5 +492,6 @@ | |||||||||
| .set_csma_params = _set_csma_params, | ||||||||||
| .config_addr_filter = _config_addr_filter, | ||||||||||
| .config_src_addr_match = _config_src_addr_match, | ||||||||||
| .get_time = _get_time, | ||||||||||
| .set_frame_filter_mode = _set_frame_filter_mode, | ||||||||||
| }; | ||||||||||
Uh oh!
There was an error while loading. Please reload this page.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.