diff --git a/.github/workflows/pub-release.yml b/.github/workflows/pub-release.yml index a69e5bfe..ad43b95b 100644 --- a/.github/workflows/pub-release.yml +++ b/.github/workflows/pub-release.yml @@ -5,6 +5,10 @@ # password ("password") -- change both on the node after flashing. Nothing # here carries a site's identity or real secrets. # +# Defaults follow the Czech mesh (meshcore.cz wiki: nastaveni_site_meshcore_cz, +# instalace_repeateru, regiony), PUB_FLAGS below. They apply to a node with +# no saved settings (fresh, or after an erase); a reflash keeps what is set. +# # Runs on every push to main -- the export pushes there only after an # upstream merge (private repo, tth-upstream-sync) -- and by hand. # Release tag tth-, titled with the stamped version (v1.18.0-tth); @@ -34,6 +38,13 @@ concurrency: env: GITEA: https://git.rfa.cz KEEP: 5 + # 869.432/62.5/SF7/CR5; repeater + room server: zero-hop advert off, flood + # advert 25 h, af 9 (= 10 % duty cycle); repeater: regions cz,cs next to *. + # Path hash 2 B is this fork's default anyway. TX power stays the board's. + PUB_FLAGS: >- + -D LORA_FREQ=869.432 -D LORA_BW=62.5 -D LORA_SF=7 -D LORA_CR=5 + -D ADVERT_INTERVAL_DEFAULT=0 -D FLOOD_ADVERT_INTERVAL_DEFAULT=25 + -D AIRTIME_FACTOR_DEFAULT=9.0 -D DEFAULT_REGIONS=\"cz,cs\" ENVS: >- Xiao_nrf52_repeater Xiao_nrf52_companion_radio_ble Xiao_nrf52_room_server Xiao_nrf52_sensor SenseCap_Solar_repeater SenseCap_Solar_companion_radio_ble @@ -90,6 +101,8 @@ jobs: run: | set -euo pipefail sha=$(git rev-parse --short=8 HEAD) + # PlatformIO appends these after each env's flags: last -D wins + export PLATFORMIO_BUILD_FLAGS="$PUB_FLAGS" dist="$GITHUB_WORKSPACE/dist" mkdir -p "$dist" version="" @@ -126,7 +139,9 @@ jobs: set -euo pipefail api="$GITEA/api/v1/repos/$GITHUB_REPOSITORY" auth="header = \"Authorization: token $TOKEN\"" - note='BLE PIN 123456 and admin password "password" are placeholders: change them after flashing.' + note='BLE PIN 123456 and admin password "password" are placeholders: change them after flashing. + Czech mesh defaults (meshcore.cz): 869.432 MHz / 62.5 kHz / SF7 / CR5; repeater: zero-hop advert off, + flood advert 25 h, af 9 (10 % duty cycle), regions cz + cs. Apply to a fresh or erased node only.' body=$(printf '%s\n\ncommit %s, run %s\n\n%s\nWhat this fork changes against upstream: see README.md.\n' \ "$VERSION" "$SHA" "$GITHUB_RUN_NUMBER" "$note") jq -n --arg t "$TAG" --arg c "$SHA" --arg n "$VERSION" --arg b "$body" \ diff --git a/README.md b/README.md index edea03a8..16bf883a 100644 --- a/README.md +++ b/README.md @@ -70,6 +70,23 @@ twice a day; everything below is on top of that. Our code is marked * Companion: `gps duty` persists, key export / PIN gated on an unauthenticated USB link, bounded build-date copy. KISS modem: off-by-one in the name clamp. +### Public builds: Czech mesh defaults + +Releases built from this repository (`pub-release`) come preset for the +Czech mesh, following the [meshcore.cz](https://meshcore.cz/) wiki, so a +freshly flashed node does not need the usual round of settings: + +* radio 869.432 MHz / 62.5 kHz / SF7 / CR5 (all builds); +* repeater and room server: zero-hop advert off, flood advert every 25 h, + `af 9` (10 % duty cycle); +* repeater: regions `cz` and `cs` next to `*` -- add your own `cz-` + with `region put cz-xxx cz` + `region save`; +* 2-byte path hashes (this fork's default). + +They apply only to a node with no saved settings (new, or after an erase): +a reflash keeps whatever the node already has, and regions you removed and +saved stay removed. Set a name, an admin password and the BLE PIN yourself. + ### Build * Version stamping in every nRF52 env (`v1.18.0-tth`, `+` = dirty tree), diff --git a/examples/simple_repeater/MyMesh.cpp b/examples/simple_repeater/MyMesh.cpp index ca4d027d..499d2d70 100644 --- a/examples/simple_repeater/MyMesh.cpp +++ b/examples/simple_repeater/MyMesh.cpp @@ -1344,6 +1344,9 @@ MyMesh::MyMesh(mesh::MainBoard &board, mesh::Radio &radio, mesh::MillisecondCloc // defaults _prefs.airtime_factor = 1.0; +#ifdef AIRTIME_FACTOR_DEFAULT // CUSTOM (TeTeHacko): e.g. 9 = 10 % duty cycle (meshcore.cz) + _prefs.airtime_factor = AIRTIME_FACTOR_DEFAULT; +#endif _prefs.rx_delay_base = 0.0f; // turn off by default, was 10.0; _prefs.tx_delay_factor = 0.5f; // was 0.25f _prefs.direct_tx_delay_factor = 0.3f; // was 0.2 @@ -1463,7 +1466,18 @@ void MyMesh::begin(FILESYSTEM *fs) { next_fair_sender_low_refill = futureMillis(fairAdvertRefillMs()); next_fair_group_refill = futureMillis(fairGroupRefillMs()); // TODO: key_store.begin(); +#ifdef DEFAULT_REGIONS + // CUSTOM (TeTeHacko): a node that never saved regions gets DEFAULT_REGIONS + // (e.g. "cz,cs", meshcore.cz/regiony) -- as if `region put` each + `region + // save`. Once /regions2 exists the operator's list wins, removals included. + bool regions_saved = _fs->exists("/regions2"); +#endif region_map.load(_fs); +#ifdef DEFAULT_REGIONS + if (!regions_saved && region_map.putDefaults(DEFAULT_REGIONS) > 0) { + region_map.save(_fs); + } +#endif // establish default-scope { diff --git a/examples/simple_room_server/MyMesh.cpp b/examples/simple_room_server/MyMesh.cpp index 935fd7f9..d14a8545 100644 --- a/examples/simple_room_server/MyMesh.cpp +++ b/examples/simple_room_server/MyMesh.cpp @@ -646,6 +646,9 @@ MyMesh::MyMesh(mesh::MainBoard &board, mesh::Radio &radio, mesh::MillisecondCloc // defaults _prefs.airtime_factor = 1.0; +#ifdef AIRTIME_FACTOR_DEFAULT // CUSTOM (TeTeHacko): e.g. 9 = 10 % duty cycle (meshcore.cz) + _prefs.airtime_factor = AIRTIME_FACTOR_DEFAULT; +#endif _prefs.rx_delay_base = 0.0f; // off by default, was 10.0 _prefs.tx_delay_factor = 0.5f; // was 0.25f; _prefs.direct_tx_delay_factor = 0.2f; // was zero @@ -661,6 +664,12 @@ MyMesh::MyMesh(mesh::MainBoard &board, mesh::Radio &radio, mesh::MillisecondCloc _prefs.disable_fwd = 1; _prefs.advert_interval = 1; // default to 2 minutes for NEW installs _prefs.flood_advert_interval = 47; // 47 hours +#ifdef ADVERT_INTERVAL_DEFAULT // CUSTOM (TeTeHacko): same knobs as simple_repeater + _prefs.advert_interval = ADVERT_INTERVAL_DEFAULT; +#endif +#ifdef FLOOD_ADVERT_INTERVAL_DEFAULT + _prefs.flood_advert_interval = FLOOD_ADVERT_INTERVAL_DEFAULT; +#endif _prefs.flood_max = 64; _prefs.flood_max_unscoped = 64; _prefs.flood_max_advert = 8; diff --git a/src/helpers/RegionMap.cpp b/src/helpers/RegionMap.cpp index 16a8e1ff..e7efd9e1 100644 --- a/src/helpers/RegionMap.cpp +++ b/src/helpers/RegionMap.cpp @@ -280,6 +280,27 @@ bool RegionMap::removeRegion(const RegionEntry& region) { return true; // success } +int RegionMap::putDefaults(const char* csv) { + int n = 0; + char name[sizeof(regions[0].name)]; + while (csv && *csv) { + int len = 0; + while (csv[len] && csv[len] != ',') len++; + if (len > 0 && len < (int)sizeof(name)) { + memcpy(name, csv, len); + name[len] = 0; + auto r = putRegion(name, wildcard.id); + if (r) { + r->flags = 0; // flood allowed, same as `region put` + n++; + } + } + csv += len; + if (*csv == ',') csv++; + } + return n; +} + bool RegionMap::clear() { num_regions = 0; return true; // success diff --git a/src/helpers/RegionMap.h b/src/helpers/RegionMap.h index 5eb14429..6c247711 100644 --- a/src/helpers/RegionMap.h +++ b/src/helpers/RegionMap.h @@ -49,6 +49,9 @@ public: void setDefaultRegion(const RegionEntry* def); bool removeRegion(const RegionEntry& region); bool clear(); + // CUSTOM (TeTeHacko): `region put ` for each name of a comma-separated + // list (flood allowed, parent = wildcard). Returns how many it put. + int putDefaults(const char* csv); void resetFrom(const RegionMap& src) { num_regions = 0; next_id = src.next_id; } int getCount() const { return num_regions; } const RegionEntry* getByIdx(int i) const { return ®ions[i]; }