summaryrefslogtreecommitdiff
path: root/stacks/daemon/tx_pace.py
blob: b7e284bd8fb42ad9f1a5dbd3feeba7cf348f1a0e (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
"""Minimum idle gap between RF/KISS frame sends (host-side pacing)."""
from __future__ import annotations

import threading
import time

MIN_TX_GAP_SEC = 1.5

_lock = threading.Lock()
_last_tx = 0.0


def tx_pace_before_send() -> None:
    """Sleep until at least MIN_TX_GAP_SEC since the previous send."""
    global _last_tx
    with _lock:
        now = time.monotonic()
        wait = MIN_TX_GAP_SEC - (now - _last_tx)
        if wait > 0:
            time.sleep(wait)
        _last_tx = time.monotonic()
git clone -b <branch> https://cgit.mode42.com/<repo>.git
git clone -b <branch> git://cgit.mode42.com/<repo>.git

info@mode42.com