Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 6 additions & 0 deletions examples/simple_repeater/MyMesh.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -428,6 +428,10 @@ void MyMesh::sendFloodReply(mesh::Packet* packet, unsigned long delay_millis, ui

bool MyMesh::allowPacketForward(const mesh::Packet *packet) {
if (_prefs.disable_fwd) return false;
if (packet->getPathHashCount() > _prefs.repeat_unrestricted_hops) {
if (packet->getRouteType() == ROUTE_TYPE_FLOOD) return false;
if (packet->getPathHashSize() < _prefs.repeat_restrict_path_hash_size) return false;
}
if (packet->isRouteFlood()) {
if (packet->getPathHashCount() >= _prefs.flood_max) return false;
if (packet->getRouteType() == ROUTE_TYPE_FLOOD && packet->getPathHashCount() >= _prefs.flood_max_unscoped) return false;
Expand Down Expand Up @@ -892,6 +896,8 @@ MyMesh::MyMesh(mesh::MainBoard &board, mesh::Radio &radio, mesh::MillisecondCloc
_prefs.flood_max = 64;
_prefs.flood_max_unscoped = 64;
_prefs.flood_max_advert = 8;
_prefs.repeat_unrestricted_hops = 64; // disabled
_prefs.repeat_restrict_path_hash_size = 1; // min x for x-Byte paths
_prefs.interference_threshold = 0; // disabled
_prefs.cad_enabled = 0; // hardware CAD before TX (off by default; 'set cad on')

Expand Down
30 changes: 28 additions & 2 deletions src/helpers/CommonCLI.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -93,7 +93,9 @@ void CommonCLI::loadPrefsInt(FILESYSTEM* fs, const char* filename) {
file.read((uint8_t *)&_prefs->flood_max_advert, sizeof(_prefs->flood_max_advert)); // 292
file.read((uint8_t *)&_prefs->radio_fem_rxgain, sizeof(_prefs->radio_fem_rxgain)); // 293
file.read((uint8_t *)&_prefs->cad_enabled, sizeof(_prefs->cad_enabled)); // 294
// next: 295
file.read((uint8_t *)&_prefs->repeat_unrestricted_hops, sizeof(_prefs->repeat_unrestricted_hops)); // 295
file.read((uint8_t *)&_prefs->repeat_restrict_path_hash_size, sizeof(_prefs->repeat_restrict_path_hash_size)); // 296
// next: 297

// sanitise bad pref values
_prefs->rx_delay_base = constrain(_prefs->rx_delay_base, 0, 20.0f);
Expand Down Expand Up @@ -190,7 +192,9 @@ void CommonCLI::savePrefs(FILESYSTEM* fs) {
file.write((uint8_t *)&_prefs->flood_max_advert, sizeof(_prefs->flood_max_advert)); // 292
file.write((uint8_t *)&_prefs->radio_fem_rxgain, sizeof(_prefs->radio_fem_rxgain)); // 293
file.write((uint8_t *)&_prefs->cad_enabled, sizeof(_prefs->cad_enabled)); // 294
// next: 295
file.write((uint8_t *)&_prefs->repeat_unrestricted_hops, sizeof(_prefs->repeat_unrestricted_hops)); // 295
file.write((uint8_t *)&_prefs->repeat_restrict_path_hash_size, sizeof(_prefs->repeat_restrict_path_hash_size)); // 296
// next: 297

file.close();
}
Expand Down Expand Up @@ -662,6 +666,24 @@ void CommonCLI::handleSetCmd(uint32_t sender_timestamp, char* command, char* rep
} else {
strcpy(reply, "Error, max 64");
}
} else if (memcmp(config, "repeat.unrestricted.hops ", 25) == 0) {
uint8_t m = atoi(&config[25]);
if (m <= 64) {
_prefs->repeat_unrestricted_hops = m;
savePrefs();
strcpy(reply, "OK");
} else {
strcpy(reply, "Error, max 64");
}
} else if (memcmp(config, "repeat.restrict.path.hash.size ", 31) == 0) {
uint8_t m = atoi(&config[31]);
if (m >= 1 && m <= 3) {
_prefs->repeat_restrict_path_hash_size = m;
savePrefs();
strcpy(reply, "OK");
} else {
strcpy(reply, "Error, between 1 and 3");
}
} else if (memcmp(config, "flood.max ", 10) == 0) {
uint8_t m = atoi(&config[10]);
if (m <= 64) {
Expand Down Expand Up @@ -829,6 +851,10 @@ void CommonCLI::handleGetCmd(uint32_t sender_timestamp, char* command, char* rep
sprintf(reply, "> %s", tmp);
} else if (memcmp(config, "name", 4) == 0) {
sprintf(reply, "> %s", _prefs->node_name);
} else if (memcmp(config, "repeat.restrict.path.hash.size", 30) == 0) {
sprintf(reply, "> %d", _prefs->repeat_restrict_path_hash_size);
} else if (memcmp(config, "repeat.unrestricted.hops", 24) == 0) {
sprintf(reply, "> %d", _prefs->repeat_unrestricted_hops);
} else if (memcmp(config, "repeat", 6) == 0) {
sprintf(reply, "> %s", _prefs->disable_fwd ? "off" : "on");
} else if (memcmp(config, "lat", 3) == 0) {
Expand Down
2 changes: 2 additions & 0 deletions src/helpers/CommonCLI.h
Original file line number Diff line number Diff line change
Expand Up @@ -42,6 +42,8 @@ struct NodePrefs { // persisted to file
uint8_t flood_max;
uint8_t flood_max_unscoped;
uint8_t flood_max_advert;
uint8_t repeat_unrestricted_hops;
uint8_t repeat_restrict_path_hash_size;
uint8_t interference_threshold;
uint8_t agc_reset_interval; // secs / 4
// Bridge settings
Expand Down