From e3a06685e4893318b1ee7d688b7af4cd1dccda77 Mon Sep 17 00:00:00 2001 From: Thomas Kolb Date: Sun, 17 Nov 2024 17:05:07 +0100 Subject: [PATCH] digipeater: rename interval to cycle Interval suggests a regular timing structure which is not intended in this construct and therefore is misleading. --- impl/src/layer2/digipeater.c | 22 +++++++++++----------- impl/src/layer2/digipeater.h | 17 ++++++++--------- 2 files changed, 19 insertions(+), 20 deletions(-) diff --git a/impl/src/layer2/digipeater.c b/impl/src/layer2/digipeater.c index b5de3c7..5d79870 100644 --- a/impl/src/layer2/digipeater.c +++ b/impl/src/layer2/digipeater.c @@ -110,7 +110,7 @@ result_t digipeater_init(digipeater_ctx_t *ctx, const ham64_t *my_addr, digipeat uint64_t now = get_hires_time(); ctx->next_beacon_time = now + HRTIME_MS(BEACON_INTERVAL_MS); - ctx->interval_end_time = now; + ctx->cycle_end_time = now; return connection_list_init(&ctx->conn_list); } @@ -188,10 +188,10 @@ result_t digipeater_handle_packet(digipeater_ctx_t *ctx, const uint8_t *buf, siz result = digipeater_handle_beacon_responses(ctx, &header, payload, payload_len); } - // end the current interval if tx_request is set in an incoming packet + // end the current cycle if tx_request is set in an incoming packet if(header.tx_request) { - LOG(LVL_INFO, "TX Request was received. Ending current interval."); - digipeater_end_interval(ctx); + LOG(LVL_INFO, "TX Request was received. Ending current cycle."); + digipeater_end_cycle(ctx); } return result; @@ -322,13 +322,13 @@ bool digipeater_can_transmit(digipeater_ctx_t *ctx) } -void digipeater_extend_interval(digipeater_ctx_t *ctx, uint64_t ns) +void digipeater_extend_cycle(digipeater_ctx_t *ctx, uint64_t ns) { - ctx->interval_end_time += ns; + ctx->cycle_end_time += ns; } -result_t digipeater_end_interval(digipeater_ctx_t *ctx) +result_t digipeater_end_cycle(digipeater_ctx_t *ctx) { uint64_t now = get_hires_time(); @@ -341,7 +341,7 @@ result_t digipeater_end_interval(digipeater_ctx_t *ctx) connection_list_reschedule_head(&ctx->conn_list, now + HRTIME_MS(MIN_INTERVAL_TIME_MS)); ctx->state = DIGIPEATER_STATE_CONN; - ctx->interval_end_time = now + HRTIME_MS(MIN_INTERVAL_TIME_MS); + ctx->cycle_end_time = now + HRTIME_MS(MIN_INTERVAL_TIME_MS); } return OK; @@ -352,11 +352,11 @@ result_t digipeater_maintain(digipeater_ctx_t *ctx) { uint64_t now = get_hires_time(); - if(now > ctx->interval_end_time) { - // at the end of the interval, the next connection is activated and the + if(now > ctx->cycle_end_time) { + // at the end of the cycle, the next connection is activated and the // current one is re-scheduled. LOG(LVL_DEBUG, "Interval ended by timeout at %llu ns.", now); - digipeater_end_interval(ctx); + digipeater_end_cycle(ctx); } switch(ctx->state) { diff --git a/impl/src/layer2/digipeater.h b/impl/src/layer2/digipeater.h index 664ee01..fa094fb 100644 --- a/impl/src/layer2/digipeater.h +++ b/impl/src/layer2/digipeater.h @@ -23,8 +23,7 @@ typedef enum { } digipeater_state_t; typedef enum { - // FIXME: rename to Cycle - DIGIPEATER_EVT_INTERVAL_END, //!< The current interval has ended and new packets should be transmitted. + DIGIPEATER_EVT_INTERVAL_END, //!< The current cycle has ended and new packets should be transmitted. } digipeater_evt_t; /*!\brief Type for a callback function that is called when a data packet was received. */ @@ -44,7 +43,7 @@ typedef struct digipeater_ctx_s { packet_queue_t oneshot_queue; //!< Queue for packets that are sent once and connection-independent uint64_t next_beacon_time; //!< Absolute timestamp of the next beacon transmission. - uint64_t interval_end_time; //!< Absolute timestamp of the end of the current interval. + uint64_t cycle_end_time; //!< Absolute timestamp of the end of the current cycle. connection_list_t conn_list; //!< List of connections. } digipeater_ctx_t; @@ -98,9 +97,9 @@ size_t digipeater_encode_next_packet(digipeater_ctx_t *ctx, uint8_t *buf, size_t */ bool digipeater_can_transmit(digipeater_ctx_t *ctx); -/*!\brief Extend the current interval. +/*!\brief Extend the current cycle. * - * By default, the interval duration is set to a minimum length. It must be + * By default, the cycle duration is set to a minimum length. It must be * extended by the time needed to transmit and receive packets. As the time * necessary for packet transfer is unknown to the Layer 2, it must be * calculated externally. @@ -109,14 +108,14 @@ bool digipeater_can_transmit(digipeater_ctx_t *ctx); * - A packet is transmitted from digipeater_encode_next_packet(), or * - A packet is being received */ -void digipeater_extend_interval(digipeater_ctx_t *ctx, uint64_t ns); +void digipeater_extend_cycle(digipeater_ctx_t *ctx, uint64_t ns); -/*!\brief End the current interval. +/*!\brief End the current cycle. * - * End the interval without waiting for the timeout. This switches to the next + * End the cycle without waiting for the timeout. This switches to the next * connection and stop forwarding received packets to the current one. */ -result_t digipeater_end_interval(digipeater_ctx_t *ctx); +result_t digipeater_end_cycle(digipeater_ctx_t *ctx); /*!\brief Handle internal maintenance tasks. *