fix: default advert location to stored preferences
This commit is contained in:
1 parent
f1515ef1c6
commit
b7e0445451
7 files changed
+33
-5
No files matched your search
@@ -3239,7 +3239,9 @@ sleep, this command schedules a sync and wakes it; after `gps off`, it reports
|
||||
- `share`: share gps location (from SensorManager)
|
||||
- `prefs`: location stored in node's lat and lon settings
|
||||
|
||||
**Default:** `prefs`
|
||||
**Default:** `prefs` on every repeater, room-server, and sensor build that uses
|
||||
the common advert policy. A previously saved `none`, `share`, or `prefs` choice
|
||||
still overrides the first-boot default after an update.
|
||||
|
||||
---
|
||||
|
||||
|
||||
@@ -119,6 +119,10 @@ Policies:
|
||||
- `share`: use the live/shared sensor manager location
|
||||
- `prefs`: use the stored node latitude and longitude preferences
|
||||
|
||||
`prefs` is the first-boot default for every repeater, room-server, and sensor
|
||||
build. Firmware updates retain an explicitly saved policy from the existing
|
||||
preferences filesystem.
|
||||
|
||||
Telemetry GPS can be fresh while advert location is fixed or disabled, depending
|
||||
on this policy.
|
||||
|
||||
|
||||
@@ -3319,7 +3319,7 @@ MyMesh::MyMesh(mesh::MainBoard &board, mesh::Radio &radio, mesh::MillisecondCloc
|
||||
// GPS defaults
|
||||
_prefs.gps_enabled = 0;
|
||||
_prefs.gps_interval = 0;
|
||||
_prefs.advert_loc_policy = ADVERT_LOC_PREFS;
|
||||
_prefs.advert_loc_policy = DEFAULT_ADVERT_LOC_POLICY;
|
||||
|
||||
// MQTT/WiFi/timezone/radio_watchdog defaults live in /mqtt_prefs now (see applyMQTTDefaults).
|
||||
|
||||
|
||||
@@ -1212,7 +1212,7 @@ MyMesh::MyMesh(mesh::MainBoard &board, mesh::Radio &radio, mesh::MillisecondCloc
|
||||
// GPS defaults
|
||||
_prefs.gps_enabled = 0;
|
||||
_prefs.gps_interval = 0;
|
||||
_prefs.advert_loc_policy = ADVERT_LOC_PREFS;
|
||||
_prefs.advert_loc_policy = DEFAULT_ADVERT_LOC_POLICY;
|
||||
|
||||
#if defined(USE_SX1262) || defined(USE_SX1268) || defined(USE_LR1110) \
|
||||
|| defined(USE_LR2021) || defined(SX126X_RX_BOOSTED_GAIN) \
|
||||
|
||||
@@ -953,7 +953,7 @@ SensorMesh::SensorMesh(mesh::MainBoard& board, mesh::Radio& radio, mesh::Millise
|
||||
// GPS defaults
|
||||
_prefs.gps_enabled = 0;
|
||||
_prefs.gps_interval = 0;
|
||||
_prefs.advert_loc_policy = ADVERT_LOC_PREFS;
|
||||
_prefs.advert_loc_policy = DEFAULT_ADVERT_LOC_POLICY;
|
||||
_prefs.radio_fem_rxgain = 1;
|
||||
_prefs.radio_fem_txgain = 0;
|
||||
|
||||
|
||||
@@ -29,6 +29,8 @@
|
||||
#define ADVERT_LOC_SHARE 1
|
||||
#define ADVERT_LOC_PREFS 2
|
||||
|
||||
static constexpr uint8_t DEFAULT_ADVERT_LOC_POLICY = ADVERT_LOC_PREFS;
|
||||
|
||||
#define LOOP_DETECT_OFF 0
|
||||
#define LOOP_DETECT_MINIMAL 1
|
||||
#define LOOP_DETECT_MODERATE 2
|
||||
@@ -149,7 +151,7 @@ public:
|
||||
// Gps settings
|
||||
uint8_t gps_enabled = 0;
|
||||
uint32_t gps_interval = 0; // seconds; 0 uses the 1-second default
|
||||
uint8_t advert_loc_policy = 0;
|
||||
uint8_t advert_loc_policy = DEFAULT_ADVERT_LOC_POLICY;
|
||||
uint32_t discovery_mod_timestamp = 0;
|
||||
float adc_multiplier = 0;
|
||||
char owner_info[120] = {};
|
||||
|
||||
@@ -192,6 +192,26 @@ TEST(ConfigSerializer, LoadSerial_IgnoreUnknowns) {
|
||||
EXPECT_TRUE(match);
|
||||
}
|
||||
|
||||
TEST(NodePrefs, AdvertLocationDefaultsToStoredPrefs) {
|
||||
NodePrefs prefs;
|
||||
EXPECT_EQ(ADVERT_LOC_PREFS, prefs.advert_loc_policy);
|
||||
EXPECT_EQ(ADVERT_LOC_PREFS, DEFAULT_ADVERT_LOC_POLICY);
|
||||
|
||||
// An explicit privacy choice remains persistent and is not replaced by
|
||||
// the first-boot default when preferences are loaded.
|
||||
prefs.advert_loc_policy = ADVERT_LOC_NONE;
|
||||
MockPrintStream output;
|
||||
ASSERT_TRUE(prefs.saveSerial(output));
|
||||
|
||||
std::string serialised(reinterpret_cast<const char*>(output.getBytes()),
|
||||
output.getLength());
|
||||
MockInputStream input(serialised.c_str());
|
||||
NodePrefs loaded;
|
||||
ASSERT_EQ(ADVERT_LOC_PREFS, loaded.advert_loc_policy);
|
||||
ASSERT_TRUE(loaded.loadSerial(input));
|
||||
EXPECT_EQ(ADVERT_LOC_NONE, loaded.advert_loc_policy);
|
||||
}
|
||||
|
||||
TEST(NodePrefs, FemGainSettingsRoundTrip) {
|
||||
NodePrefs saved;
|
||||
saved.radio_fem_rxgain = 0;
|
||||
|
||||
Reference in new issue
Block a user