firmware: runtime preamble-detector length; generalized single-variable A/B harness

This commit is contained in:
Lars Nolden
2026-09-01 11:30:00 +02:00
parent 6bdcb2acad
commit 697e10e8cf
6 changed files with 160 additions and 2 deletions
+8 -1
View File
@@ -57,6 +57,10 @@ static uint8_t s_rx_payload_len = 255;
static int8_t s_tx_dbm = -9;
static SemaphoreHandle_t s_lock; // serializes SPI access across tasks
static bool s_pa_low = true; // true = +10 dBm-optimal PA row (lowest output)
// Preamble detector length. Shorter = more sensitive but more false syncs,
// and every false sync costs one fixed-255-byte RX window (~12 ms).
// SX126x codes: 0x00 off, 0x04 = 8 bits, 0x05 = 16, 0x06 = 24, 0x07 = 32.
static uint8_t s_preamble_det = 0x04;
// ---------------------------------------------------------------- low level
@@ -361,7 +365,7 @@ static bool set_packet_params(uint8_t payload_len)
// radio CRC (wM-Bus CRC is per-block, validated in software), no whitening
uint8_t pp[9] = {
0x00, 0x30, // TX preamble length: 48 bits
0x04, // preamble detector: 8 bits
s_preamble_det, // preamble detector length (see s_preamble_det)
16, // sync word length in bits
0x00, // no address filtering
0x00, // fixed length packet
@@ -516,3 +520,6 @@ uint8_t sx126x_get_status(void)
}
void sx126x_set_pa_low(bool low) { s_pa_low = low; }
void sx126x_set_preamble_detect(uint8_t code) { s_preamble_det = code; }
uint8_t sx126x_get_preamble_detect(void) { return s_preamble_det; }