digipeater: rename interval to cycle

Interval suggests a regular timing structure which is not intended in this
construct and therefore is misleading.
This commit is contained in:
Thomas Kolb 2024-11-17 17:05:07 +01:00
parent 1c8e46f54a
commit f895adf877
2 changed files with 19 additions and 20 deletions

View file

@ -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) {

View file

@ -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.
*