mirror of
https://github.com/meshcore-dev/MeshCore.git
synced 2026-03-30 14:55:46 +00:00
* repeater & room server: new config "flood.advert.interval"
This commit is contained in:
@@ -139,7 +139,7 @@ class MyMesh : public mesh::Mesh, public CommonCLICallbacks {
|
||||
FILESYSTEM* _fs;
|
||||
RADIO_CLASS* _phy;
|
||||
mesh::MainBoard* _board;
|
||||
unsigned long next_local_advert;
|
||||
unsigned long next_local_advert, next_flood_advert;
|
||||
NodePrefs _prefs;
|
||||
CommonCLI _cli;
|
||||
uint8_t reply_data[MAX_PACKET_PAYLOAD];
|
||||
@@ -584,7 +584,7 @@ public:
|
||||
_phy(&phy), _board(&board), _cli(board, this, &_prefs, this)
|
||||
{
|
||||
my_radio = &radio;
|
||||
next_local_advert = 0;
|
||||
next_local_advert = next_flood_advert = 0;
|
||||
|
||||
// defaults
|
||||
memset(&_prefs, 0, sizeof(_prefs));
|
||||
@@ -602,6 +602,7 @@ public:
|
||||
_prefs.tx_power_dbm = LORA_TX_POWER;
|
||||
_prefs.disable_fwd = 1;
|
||||
_prefs.advert_interval = 1; // default to 2 minutes for NEW installs
|
||||
_prefs.flood_advert_interval = 3; // 3 hours
|
||||
_prefs.flood_max = 64;
|
||||
#ifdef ROOM_PASSWORD
|
||||
StrHelper::strncpy(_prefs.guest_password, ROOM_PASSWORD, sizeof(_prefs.guest_password));
|
||||
@@ -667,6 +668,13 @@ public:
|
||||
next_local_advert = 0; // stop the timer
|
||||
}
|
||||
}
|
||||
void updateFloodAdvertTimer() override {
|
||||
if (_prefs.flood_advert_interval > 0) { // schedule flood advert timer
|
||||
next_flood_advert = futureMillis( ((uint32_t)_prefs.flood_advert_interval) * 60 * 60 * 1000);
|
||||
} else {
|
||||
next_flood_advert = 0; // stop the timer
|
||||
}
|
||||
}
|
||||
|
||||
void setLoggingOn(bool enable) override { /* no-op */ }
|
||||
void eraseLogFile() override { /* no-op */ }
|
||||
@@ -711,11 +719,15 @@ public:
|
||||
next_push = futureMillis(SYNC_PUSH_INTERVAL);
|
||||
}
|
||||
|
||||
if (next_local_advert && millisHasNowPassed(next_local_advert)) {
|
||||
if (next_flood_advert && millisHasNowPassed(next_flood_advert)) {
|
||||
mesh::Packet* pkt = createSelfAdvert();
|
||||
if (pkt) {
|
||||
sendZeroHop(pkt);
|
||||
}
|
||||
if (pkt) sendFlood(pkt);
|
||||
|
||||
updateFloodAdvertTimer(); // schedule next flood advert
|
||||
updateAdvertTimer(); // also schedule local advert (so they don't overlap)
|
||||
} else if (next_local_advert && millisHasNowPassed(next_local_advert)) {
|
||||
mesh::Packet* pkt = createSelfAdvert();
|
||||
if (pkt) sendZeroHop(pkt);
|
||||
|
||||
updateAdvertTimer(); // schedule next local advert
|
||||
}
|
||||
@@ -791,7 +803,7 @@ void setup() {
|
||||
#endif
|
||||
|
||||
// send out initial Advertisement to the mesh
|
||||
the_mesh.sendSelfAdvertisement(2000);
|
||||
the_mesh.sendSelfAdvertisement(16000);
|
||||
}
|
||||
|
||||
void loop() {
|
||||
|
||||
Reference in New Issue
Block a user