mirror of
https://github.com/MarekZegare4/MeshCore-Solo.git
synced 2026-11-02 19:02:00 +00:00
feat(companion): advert position precision (privacy)
Settings > Privacy > Precision: Exact / ~100 m / ~500 m / ~1 km, beside "Position in adverts", which stays the on/off. With the position shared, it is snapped to a fixed grid (0.0009 / 0.0045 / 0.009 degrees) rather than jittered, so repeated adverts from one spot send the same value and can't be averaged back to the exact fix. A schema row (NodePrefs::advert_loc_prec), so both UIs show it, factory reset clears it and the console has it as advert.loc.precision. Every self-advert -- manual, flood, auto, the phone app's and contact export -- now goes through MyMesh::createOwnAdvert(), so the precision applies everywhere. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
@@ -16,6 +16,7 @@ struct Key { const char* key; uint16_t offset; uint8_t bit; };
|
||||
#define KB(name, f, mask) { name, (uint16_t)offsetof(NodePrefs, f), mask }
|
||||
static const Key KEYS[] = {
|
||||
K("advert.interval", advert_auto_interval_sec), K("advert.loc", advert_loc_policy),
|
||||
K("advert.loc.precision", advert_loc_prec),
|
||||
K("telemetry.base", telemetry_mode_base), K("telemetry.loc", telemetry_mode_loc), K("telemetry.env", telemetry_mode_env),
|
||||
K("autoadd", manual_add_contacts), KB("autoadd.chat", autoadd_config, 0x02), KB("autoadd.repeater", autoadd_config, 0x04),
|
||||
KB("autoadd.room", autoadd_config, 0x08), KB("autoadd.sensor", autoadd_config, 0x10),
|
||||
|
||||
@@ -161,6 +161,10 @@ static void optAdvertScope(uint8_t v, char* b, int n, const NodePrefs&) {
|
||||
snprintf(b, n, "%s", v == ADVERT_SOUND_SCOPE_ZERO_HOP ? "Direct" : "All");
|
||||
}
|
||||
|
||||
static void optLocPrec(uint8_t v, char* b, int n, const NodePrefs&) {
|
||||
static const char* const L[NodePrefs::ADV_LOC_PREC_COUNT] = { "Exact", "~100 m", "~500 m", "~1 km" };
|
||||
snprintf(b, n, "%s", L[v < NodePrefs::ADV_LOC_PREC_COUNT ? v : 0]);
|
||||
}
|
||||
static void optTelemetry(uint8_t v, char* b, int n, const NodePrefs&) {
|
||||
static const char* const L[] = { "Nobody", "Allowed", "Everyone" }; // TELEM_MODE_*
|
||||
snprintf(b, n, "%s", L[v < 3 ? v : 0]);
|
||||
@@ -281,6 +285,8 @@ static const Setting ALL[] = {
|
||||
IDX("Advert sound for", "Direct: no repeaters", SEC_SOUND_FOR, advert_sound_scope, 2, optAdvertScope, nullptr),
|
||||
|
||||
SW("Position in adverts", "Your adverts carry your location", SEC_PRIVACY, advert_loc_policy, nullptr),
|
||||
IDX("Precision", "Rounded so it can't be pinpointed", SEC_PRIVACY, advert_loc_prec,
|
||||
NodePrefs::ADV_LOC_PREC_COUNT, optLocPrec, nullptr),
|
||||
// TELEM_MODE_*: "Allowed" is the contacts given that permission.
|
||||
IDX("Status", "Battery; the two below need it", SEC_TELEMETRY, telemetry_mode_base, 3, optTelemetry, nullptr),
|
||||
IDX("Location", nullptr, SEC_TELEMETRY, telemetry_mode_loc, 3, optTelemetry, nullptr),
|
||||
@@ -315,7 +321,7 @@ static const struct { uint16_t offset; const char* text; } SHORT_LABELS[] = {
|
||||
{ NP_OFF(notif_melody_ch), "Ch sound" }, { NP_OFF(notif_melody_ad), "AD sound" },
|
||||
{ NP_OFF(advert_sound_scope), "AD scope" },
|
||||
{ NP_OFF(manual_add_contacts), "Auto-add" }, { NP_OFF(autoadd_max_hops), " up to" },
|
||||
{ NP_OFF(advert_loc_policy), "Advert pos" }, { NP_OFF(telemetry_mode_base), "Ask status" },
|
||||
{ NP_OFF(advert_loc_policy), "Advert pos" }, { NP_OFF(advert_loc_prec), " precision" }, { NP_OFF(telemetry_mode_base), "Ask status" },
|
||||
{ NP_OFF(telemetry_mode_loc), "Ask loc" }, { NP_OFF(telemetry_mode_env), "Ask sens" },
|
||||
{ NP_OFF(path_hash_mode), "Hash size" }, { NP_OFF(multi_acks), "Double ACK" },
|
||||
{ NP_OFF(cad_enabled), "LBT (CAD)" }, { NP_OFF(interference_threshold), "Interf." },
|
||||
|
||||
Reference in New Issue
Block a user