mirror of
https://github.com/mikecarper/MeshCore.git
synced 2026-09-30 04:17:57 +00:00
Guard T096 transmit default and retry setting persistence
This commit is contained in:
+23
@@ -9,6 +9,7 @@
|
||||
#include <helpers/PrefsSaveReplyGuard.h>
|
||||
|
||||
#define MIN_LOCAL_ADVERT_INTERVAL 60
|
||||
#define RETRY_PRESET_CUSTOM 0xFF
|
||||
#define PUB_KEY_SIZE 32
|
||||
#define PRV_KEY_SIZE 64
|
||||
namespace mesh {
|
||||
@@ -26,6 +27,7 @@ struct Utils {
|
||||
}
|
||||
struct Prefs {
|
||||
uint8_t advert_interval = 30, flood_advert_interval = 12, multi_acks = 0;
|
||||
uint8_t flood_retry_attempts = 8, retry_preset = 0;
|
||||
char password[16] = "old-admin", guest_password[16] = "old-guest";
|
||||
bool dirty = true;
|
||||
void clearDirty() { dirty = false; }
|
||||
@@ -45,6 +47,7 @@ struct Callbacks {
|
||||
void savePrefs(PrefsSaveRouting::Scope);
|
||||
void updateAdvertTimer();
|
||||
void updateFloodAdvertTimer();
|
||||
void onRetryConfigChanged() { ++flood_updates; }
|
||||
bool saveIdentity(const mesh::LocalIdentity&) { ++identity_saves; return identity_ok; }
|
||||
};
|
||||
struct CommonCLI {
|
||||
@@ -58,6 +61,7 @@ struct CommonCLI {
|
||||
void savePrefs(PrefsSaveRouting::Scope scope = PrefsSaveRouting::Scope::Common);
|
||||
bool trySavePrefs(PrefsSaveRouting::Scope scope = PrefsSaveRouting::Scope::Common);
|
||||
bool saveObserverPrefs();
|
||||
int _atoi(const char* value) { return std::atoi(value); }
|
||||
void set(const char* config, char* reply);
|
||||
void password(const char* command, char* reply);
|
||||
};
|
||||
@@ -151,6 +155,25 @@ int main() {
|
||||
}
|
||||
assert(flood ? cli.callbacks.flood_updates == 3 : cli.callbacks.local_updates == 3);
|
||||
}
|
||||
{
|
||||
CommonCLI cli;
|
||||
cli.callbacks.common_ok = false;
|
||||
cli.set("flood.retry.count 2", reply);
|
||||
assert(error(reply) && cli.prefs.flood_retry_attempts == 2);
|
||||
assert(cli.callbacks.persisted.flood_retry_attempts == 8);
|
||||
assert(cli.callbacks.flood_updates == 1);
|
||||
cli.callbacks.common_ok = true;
|
||||
for (const char* value : {"2", "0", "15"}) {
|
||||
cli.set((std::string("flood.retry.count ") + value).c_str(), reply);
|
||||
assert(strcmp(reply, "OK") == 0);
|
||||
assert(cli.prefs.flood_retry_attempts == std::atoi(value));
|
||||
assert(cli.callbacks.persisted.flood_retry_attempts == std::atoi(value));
|
||||
assert(cli.callbacks.persisted.retry_preset == RETRY_PRESET_CUSTOM);
|
||||
}
|
||||
CommonCLI reboot;
|
||||
reboot.prefs = cli.callbacks.persisted;
|
||||
assert(reboot.prefs.flood_retry_attempts == 15);
|
||||
}
|
||||
{
|
||||
CommonCLI cli;
|
||||
const std::string key = "prv.key " + std::string(128, '1');
|
||||
|
||||
@@ -112,7 +112,7 @@ import sys
|
||||
sections = {section: dict(options) for section, options in json.load(sys.stdin)}
|
||||
|
||||
def option_text(env_name, option_name):
|
||||
section = sections.get(f"env:{env_name}")
|
||||
section = sections.get(f"env:{env_name}", sections.get(env_name))
|
||||
if section is None:
|
||||
raise SystemExit(f"test_build_profiles: missing PlatformIO environment {env_name}")
|
||||
value = section.get(option_name, [])
|
||||
@@ -241,6 +241,8 @@ reject(rc32_repeater, "build_flags", "ESP32_CPU_FREQ=160")
|
||||
# creating a second Wire instance on the same pins as the board bus.
|
||||
require("Heltec_t096_companion_radio_usb_femon", "build_flags", "ENV_PIN_SDA=PIN_WIRE1_SDA")
|
||||
require("Heltec_t096_companion_radio_usb_femon", "build_flags", "ENV_PIN_SCL=PIN_WIRE1_SCL")
|
||||
require("Heltec_t096", "build_flags", "LORA_TX_POWER=22")
|
||||
reject("Heltec_t096", "build_flags", "LORA_TX_POWER=9")
|
||||
require("Heltec_v3_companion_radio_wifi", "build_flags", "ENV_PIN_SDA=33")
|
||||
require("Heltec_v3_companion_radio_wifi", "build_flags", "ENV_PIN_SCL=34")
|
||||
|
||||
|
||||
@@ -35,6 +35,7 @@ class CommonCLISaveResultsTest(unittest.TestCase):
|
||||
branches = '\nelse '.join(extract_braced(source, signature) for signature in (
|
||||
'if (memcmp(config, "flood.advert.interval ", 22) == 0)',
|
||||
'if (memcmp(config, "advert.interval ", 16) == 0)',
|
||||
'if (memcmp(config, "flood.retry.count ", 18) == 0)',
|
||||
'if (memcmp(config, "guest.password ", 15) == 0)',
|
||||
'if (memcmp(config, "prv.key ", 8) == 0)',
|
||||
'if (memcmp(config, "multi.acks ", 11) == 0)'))
|
||||
|
||||
Reference in New Issue
Block a user