mirror of
https://github.com/MarekZegare4/MeshCore-Solo.git
synced 2026-08-07 20:56:11 +00:00
fix(repeater): close radio-profile bypass paths, dedupe preset/BW logic
CMD_SET_RADIO_PARAMS and the on-device Settings radio editors (Freq/SF/BW/CR/Preset) called radio_driver.setParams() directly instead of applyRepeaterRadio(), so editing the companion's own radio params while relaying on a dedicated profile silently retuned the live radio off that profile. Both now route through applyRepeaterRadio(), the single decision point already used at boot and by the on-device repeater toggle. Also: overhear-suppression matched queued packets by payload hash alone, so it could cancel a queued direct-route retransmit that happened to share a hash with an overheard flood packet — now scoped to flood-queued entries only. repeaterProfileValid()'s frequency floor (100 MHz) is raised to 150 MHz to match the radio's actual validated range. RepeaterScreen's preset-name lookup now uses the same epsilon-tolerant float comparison as Settings instead of exact ==, avoiding inconsistent "Custom" labeling between the two screens. Dedupe: the BW-options table, the value-column x-offset math, and the default-profile-seeding block had each drifted into two or three independent copies (RepeaterScreen vs Settings, MyMesh constructor vs DataStore.cpp upgrade path); factored into shared helpers in RadioPresets.h / NodePrefs.h. Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
This commit is contained in:
co-authored by
Claude Sonnet 4.6
parent
afe7b8a0ca
commit
4999620fba
@@ -1,4 +1,5 @@
|
||||
#pragma once
|
||||
#include <math.h>
|
||||
|
||||
// Community-suggested per-region RF presets (freq/bw/sf/cr), sourced from the
|
||||
// MeshCore app's "suggested_radio_settings" config plus a few community additions.
|
||||
@@ -33,3 +34,17 @@ static const RadioPreset RADIO_PRESETS[] = {
|
||||
{ "Vietnam (Narrow)", 920.250f, 62.5f, 8, 5 },
|
||||
};
|
||||
static const int RADIO_PRESET_COUNT = sizeof(RADIO_PRESETS) / sizeof(RADIO_PRESETS[0]);
|
||||
|
||||
// Standard SX126x/SX127x LoRa bandwidths (kHz) — manual BW fields (companion and
|
||||
// repeater profile alike) cycle through these rather than a free-form value, so
|
||||
// they can't land on an unsupported setting.
|
||||
static const float LORA_BW_OPTS[] = { 7.8f, 10.4f, 15.6f, 20.8f, 31.25f, 41.7f, 62.5f, 125.0f, 250.0f, 500.0f };
|
||||
static const int LORA_BW_OPT_COUNT = sizeof(LORA_BW_OPTS) / sizeof(LORA_BW_OPTS[0]);
|
||||
|
||||
// True if (freq, bw, sf, cr) matches the radio's currently-applied (cur_*) params.
|
||||
// Floats are compared with a small epsilon since they may have round-tripped
|
||||
// through unit conversions (e.g. kHz integers from the companion app).
|
||||
static inline bool radioParamsMatchPreset(float cur_freq, float cur_bw, uint8_t cur_sf, uint8_t cur_cr,
|
||||
float freq, float bw, uint8_t sf, uint8_t cr) {
|
||||
return fabsf(cur_freq - freq) < 0.001f && fabsf(cur_bw - bw) < 0.001f && cur_sf == sf && cur_cr == cr;
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user