Merge branch 'feat/set_get_ack_timeout' into 'master'

feat(802.15.4): add api for set/get ack timeout

Closes TZ-1352 and IDFGH-13994

See merge request espressif/esp-idf!35531
This commit is contained in:
Shu Chen 2024-12-31 10:57:43 +08:00
commit 9d1a4ebac4
3 changed files with 35 additions and 2 deletions

View File

@ -277,6 +277,16 @@ static inline void ieee802154_ll_set_power(uint8_t power)
IEEE802154.txpower.power = power;
}
static inline void ieee802154_ll_set_ack_timeout(uint32_t timeout)
{
IEEE802154.ack_timeout.timeout = timeout;
}
static inline uint32_t ieee802154_ll_get_ack_timeout(void)
{
return IEEE802154.ack_timeout.timeout;
}
static inline void ieee802154_ll_set_multipan_panid(ieee802154_ll_multipan_index_t index, uint16_t panid)
{
IEEE802154.conf.multipan_mask |= BIT(index);

View File

@ -184,6 +184,22 @@ esp_err_t esp_ieee802154_set_multipan_enable(uint8_t mask)
#else
esp_err_t esp_ieee802154_set_ack_timeout(uint32_t timeout)
{
// Divide by 16 and round it up.
uint32_t target_reg_value = (timeout + 15) / 16;
if((timeout % 16) != 0) {
ESP_LOGW(IEEE802154_TAG, "Ack timeout should be a multiple of 16, input %"PRIu32", will be replaced by %"PRIu32"", timeout, (target_reg_value * 16));
}
ieee802154_ll_set_ack_timeout(target_reg_value);
return ESP_OK;
}
uint32_t esp_ieee802154_get_ack_timeout(void)
{
return ieee802154_ll_get_ack_timeout() * 16;
}
uint16_t esp_ieee802154_get_panid(void)
{
return ieee802154_ll_get_multipan_panid(ESP_IEEE802154_MULTIPAN_0);

View File

@ -150,8 +150,8 @@ esp_err_t esp_ieee802154_transmit(const uint8_t *frame, bool cca);
/**
* @brief Set the time to wait for the ack frame.
*
* @param[in] timeout The time to wait for the ack frame, in symbol unit (16 us).
* Default: 0x006C, Range: 0x0000 - 0xFFFF.
* @param[in] timeout The time to wait for the ack frame, in us.
* It Should be a multiple of 16. The default value is 1728 us (108 * 16).
*
* @return
* - ESP_OK on success.
@ -159,6 +159,13 @@ esp_err_t esp_ieee802154_transmit(const uint8_t *frame, bool cca);
*/
esp_err_t esp_ieee802154_set_ack_timeout(uint32_t timeout);
/**
* @brief Get the time to wait for the ack frame.
*
* @return The time to wait for the ack frame, in us.
*/
uint32_t esp_ieee802154_get_ack_timeout(void);
/**
* @brief Get the device PAN ID.
*