Skip to content

Commit

Permalink
Cap out top priority retry limit as well to stop freezes.
Browse files Browse the repository at this point in the history
  • Loading branch information
linguini1 committed Jun 16, 2024
1 parent 0f8f9d8 commit f0d5111
Showing 1 changed file with 8 additions and 15 deletions.
23 changes: 8 additions & 15 deletions src/main.c
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,9 @@
/** How many times broadcaster will attempt to transmit a packet before giving up. */
#define RETRY_LIMIT 3

/** How many times broadcaster will attempt to transmit a high priority packet before giving up. */
#define TOP_PRIOR_RETRY_LIMIT 10

/** The name of the message queue to read input from. */
#define IN_QUEUE "plogger-out"

Expand Down Expand Up @@ -177,23 +180,13 @@ int main(int argc, char **argv) {
continue;
}

// Top priority messages get infinite retries
if (priority >= TOP_PRIORITY) {
for (;; transmission_tries++) {
err = radio_tx_bytes(radio, (uint8_t *)buffer, nbytes);
if (!err) break;
}
}

// Messages are limited to retry limit
else {
for (; transmission_tries < RETRY_LIMIT; transmission_tries++) {
err = radio_tx_bytes(radio, (uint8_t *)buffer, nbytes);
if (!err) break;
}
unsigned int retry_limit = priority >= TOP_PRIORITY ? TOP_PRIOR_RETRY_LIMIT : RETRY_LIMIT;
for (; transmission_tries < retry_limit; transmission_tries++) {
err = radio_tx_bytes(radio, (uint8_t *)buffer, nbytes);
if (!err) break;
}

if (priority < TOP_PRIORITY && transmission_tries >= RETRY_LIMIT) {
if (transmission_tries >= retry_limit) {
log_print(stderr, LOG_ERROR, "Failed to transmit after %u tries: %s", transmission_tries,
strerror(err));
}
Expand Down

0 comments on commit f0d5111

Please sign in to comment.