Skip to content

Commit e27cc7c

Browse files
committed
Merge branch 'feat/set_get_ack_timeout_v5.3' into 'release/v5.3'
feat(802.15.4): add api for set/get ack timeout (v5.3) See merge request espressif/esp-idf!36086
2 parents 238d703 + b3830be commit e27cc7c

File tree

3 files changed

+35
-2
lines changed

3 files changed

+35
-2
lines changed

components/hal/include/hal/ieee802154_common_ll.h

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -277,6 +277,16 @@ static inline void ieee802154_ll_set_power(uint8_t power)
277277
IEEE802154.txpower.power = power;
278278
}
279279

280+
static inline void ieee802154_ll_set_ack_timeout(uint32_t timeout)
281+
{
282+
IEEE802154.ack_timeout.timeout = timeout;
283+
}
284+
285+
static inline uint32_t ieee802154_ll_get_ack_timeout(void)
286+
{
287+
return IEEE802154.ack_timeout.timeout;
288+
}
289+
280290
static inline void ieee802154_ll_set_multipan_panid(ieee802154_ll_multipan_index_t index, uint16_t panid)
281291
{
282292
IEEE802154.conf.multipan_mask |= BIT(index);

components/ieee802154/esp_ieee802154.c

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -184,6 +184,22 @@ esp_err_t esp_ieee802154_set_multipan_enable(uint8_t mask)
184184

185185
#else
186186

187+
esp_err_t esp_ieee802154_set_ack_timeout(uint32_t timeout)
188+
{
189+
// Divide by 16 and round it up.
190+
uint32_t target_reg_value = (timeout + 15) / 16;
191+
if((timeout % 16) != 0) {
192+
ESP_LOGW(IEEE802154_TAG, "Ack timeout should be a multiple of 16, input %"PRIu32", will be replaced by %"PRIu32"", timeout, (target_reg_value * 16));
193+
}
194+
ieee802154_ll_set_ack_timeout(target_reg_value);
195+
return ESP_OK;
196+
}
197+
198+
uint32_t esp_ieee802154_get_ack_timeout(void)
199+
{
200+
return ieee802154_ll_get_ack_timeout() * 16;
201+
}
202+
187203
uint16_t esp_ieee802154_get_panid(void)
188204
{
189205
return ieee802154_ll_get_multipan_panid(ESP_IEEE802154_MULTIPAN_0);

components/ieee802154/include/esp_ieee802154.h

Lines changed: 9 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -150,15 +150,22 @@ esp_err_t esp_ieee802154_transmit(const uint8_t *frame, bool cca);
150150
/**
151151
* @brief Set the time to wait for the ack frame.
152152
*
153-
* @param[in] timeout The time to wait for the ack frame, in symbol unit (16 us).
154-
* Default: 0x006C, Range: 0x0000 - 0xFFFF.
153+
* @param[in] timeout The time to wait for the ack frame, in us.
154+
* It Should be a multiple of 16. The default value is 1728 us (108 * 16).
155155
*
156156
* @return
157157
* - ESP_OK on success.
158158
* - ESP_FAIL on failure.
159159
*/
160160
esp_err_t esp_ieee802154_set_ack_timeout(uint32_t timeout);
161161

162+
/**
163+
* @brief Get the time to wait for the ack frame.
164+
*
165+
* @return The time to wait for the ack frame, in us.
166+
*/
167+
uint32_t esp_ieee802154_get_ack_timeout(void);
168+
162169
/**
163170
* @brief Get the device PAN ID.
164171
*

0 commit comments

Comments
 (0)