esp-sdr-zephyr
Raw I/Q receive and transmit on the ESP32-S3/C6 Wi-Fi radio, for Zephyr
Loading...
Searching...
No Matches
Clip guard

The receive gain down a level when packets reach full scale, up again after a quiet hold (esp_sdr_gain_guard.h, CONFIG_ESP_SDR_GAIN_GUARD). More...

Data Structures

struct  esp_sdr_gain_guard_cfg
struct  esp_sdr_gain_guard

Functions

void esp_sdr_gain_guard_init (struct esp_sdr_gain_guard *g, const struct esp_sdr_gain_guard_cfg *cfg, int64_t now_ms)
bool esp_sdr_gain_guard_update (struct esp_sdr_gain_guard *g, int64_t now_ms, uint32_t clipped, uint32_t loud)

Detailed Description

The receive gain down a level when packets reach full scale, up again after a quiet hold (esp_sdr_gain_guard.h, CONFIG_ESP_SDR_GAIN_GUARD).

Guide: Gain.

A receiver at a high gain clips a transmitter close by: its packets come out with bit errors or not at all. The guard watches two counters the receiver keeps, packets at full scale and packets within 10 dB of it (or whatever margin the app counts as loud), and moves through the app's gain levels, the first the highest: down a level after esp_sdr_gain_guard_cfg::down_n packets at full scale within esp_sdr_gain_guard_cfg::down_ms, up a level after a hold without a loud packet. The hold starts at esp_sdr_gain_guard_cfg::up_ms and doubles, up to esp_sdr_gain_guard_cfg::up_max_ms, each time the guard steps down again within esp_sdr_gain_guard_cfg::bounce_ms of stepping up: a source in bursts (a host scanning, then connecting) would otherwise find the gain back up for the first packets of each burst. The longest hold at the first level with nothing loud brings the hold back to the first. The levels' gains and their measured drops (for an RSSI calibration) stay with the app.

Function Documentation

◆ esp_sdr_gain_guard_init()

void esp_sdr_gain_guard_init ( struct esp_sdr_gain_guard * g,
const struct esp_sdr_gain_guard_cfg * cfg,
int64_t now_ms )

Start at the first level with the shortest hold, at now_ms.

◆ esp_sdr_gain_guard_update()

bool esp_sdr_gain_guard_update ( struct esp_sdr_gain_guard * g,
int64_t now_ms,
uint32_t clipped,
uint32_t loud )

The receiver's counters of packets at full scale and loud packets at now_ms (running totals, wrapping); true when the level changed.