Added default_packet_send_count config

This allows you to configure how many times a non ACK packet
will be sent before giving up.
This commit is contained in:
Hemna 2024-04-19 15:59:55 -04:00
parent bef32059f4
commit 813bc7ea29
2 changed files with 18 additions and 2 deletions

View File

@ -105,6 +105,11 @@ aprsd_opts = [
"'multiline' will use multiple lines for each packet and is the traditional format." "'multiline' will use multiple lines for each packet and is the traditional format."
"both will log both compact and multiline.", "both will log both compact and multiline.",
), ),
cfg.IntOpt(
"default_packet_send_count",
default=3,
help="The number of times to send a non ack packet before giving up.",
),
cfg.IntOpt( cfg.IntOpt(
"default_ack_send_count", "default_ack_send_count",
default=3, default=3,

View File

@ -22,15 +22,22 @@ def log_multiline(packet, tx: Optional[bool] = False, header: Optional[bool] = T
"""LOG a packet to the logfile.""" """LOG a packet to the logfile."""
if CONF.log_packet_format == "compact": if CONF.log_packet_format == "compact":
return return
# asdict(packet) # asdict(packet)
logit = ["\n"] logit = ["\n"]
name = packet.__class__.__name__ name = packet.__class__.__name__
if isinstance(packet, AckPacket):
pkt_max_send_count = CONF.default_ack_send_count
else:
pkt_max_send_count = CONF.default_packet_send_count
if header: if header:
if tx: if tx:
header_str = f"<{TX_COLOR}>TX</{TX_COLOR}>" header_str = f"<{TX_COLOR}>TX</{TX_COLOR}>"
logit.append( logit.append(
f"{header_str}________(<{PACKET_COLOR}>{name}</{PACKET_COLOR}> " f"{header_str}________(<{PACKET_COLOR}>{name}</{PACKET_COLOR}> "
f"TX:{packet.send_count + 1} of {packet.retry_count})", f"TX:{packet.send_count + 1} of {pkt_max_send_count}",
) )
else: else:
header_str = f"<{RX_COLOR}>RX</{RX_COLOR}>" header_str = f"<{RX_COLOR}>RX</{RX_COLOR}>"
@ -78,6 +85,10 @@ def log(packet, tx: Optional[bool] = False, header: Optional[bool] = True) -> No
logit = [] logit = []
name = packet.__class__.__name__ name = packet.__class__.__name__
if isinstance(packet, AckPacket):
pkt_max_send_count = CONF.default_ack_send_count
else:
pkt_max_send_count = CONF.default_packet_send_count
if header: if header:
if tx: if tx:
@ -87,7 +98,7 @@ def log(packet, tx: Optional[bool] = False, header: Optional[bool] = True) -> No
f"<red>TX {arrow}</red> " f"<red>TX {arrow}</red> "
f"<cyan>{name}</cyan>" f"<cyan>{name}</cyan>"
f":{packet.msgNo}" f":{packet.msgNo}"
f" ({packet.send_count + 1} of {packet.retry_count})", f" ({packet.send_count + 1} of {pkt_max_send_count})",
) )
else: else:
via_color = "fg #828282" via_color = "fg #828282"