mirror of
https://github.com/meshcore-dev/MeshCore.git
synced 2026-04-20 22:13:47 +00:00
* repeater and room server: login password now using strcmp(), new 'set direct.txdelay ..' config
This commit is contained in:
parent
d81bbe56a0
commit
c4cc3dd1ec
4 changed files with 45 additions and 7 deletions
|
|
@ -145,6 +145,7 @@ struct NodePrefs { // persisted to file
|
|||
float rx_delay_base;
|
||||
float tx_delay_factor;
|
||||
char guest_password[16];
|
||||
float direct_tx_delay_factor;
|
||||
};
|
||||
|
||||
class MyMesh : public mesh::Mesh {
|
||||
|
|
@ -295,6 +296,10 @@ protected:
|
|||
uint32_t t = (_radio->getEstAirtimeFor(packet->path_len + packet->payload_len + 2) * _prefs.tx_delay_factor);
|
||||
return getRNG()->nextInt(0, 6)*t;
|
||||
}
|
||||
uint32_t getDirectRetransmitDelay(const mesh::Packet* packet) override {
|
||||
uint32_t t = (_radio->getEstAirtimeFor(packet->path_len + packet->payload_len + 2) * _prefs.direct_tx_delay_factor);
|
||||
return getRNG()->nextInt(0, 6)*t;
|
||||
}
|
||||
|
||||
bool allowPacketForward(const mesh::Packet* packet) override {
|
||||
return !_prefs.disable_fwd;
|
||||
|
|
@ -307,12 +312,12 @@ protected:
|
|||
memcpy(&sender_sync_since, &data[4], 4); // sender's "sync messags SINCE x" timestamp
|
||||
|
||||
bool is_admin;
|
||||
if (memcmp(&data[8], _prefs.password, strlen(_prefs.password)) == 0) { // check for valid admin password
|
||||
data[len] = 0; // ensure null terminator
|
||||
if (strcmp((char *) &data[8], _prefs.password) == 0) { // check for valid admin password
|
||||
is_admin = true;
|
||||
} else {
|
||||
is_admin = false;
|
||||
int len = strlen(_prefs.guest_password);
|
||||
if (len > 0 && memcmp(&data[8], _prefs.guest_password, len) != 0) { // check the room/public password
|
||||
if (strcmp((char *) &data[8], _prefs.guest_password) != 0) { // check the room/public password
|
||||
MESH_DEBUG_PRINTLN("Incorrect room password");
|
||||
return; // no response. Client will timeout
|
||||
}
|
||||
|
|
@ -694,6 +699,15 @@ public:
|
|||
} else {
|
||||
strcpy(reply, "Error, cannot be negative");
|
||||
}
|
||||
} else if (memcmp(config, "direct.txdelay ", 15) == 0) {
|
||||
float f = atof(&config[15]);
|
||||
if (f >= 0) {
|
||||
_prefs.direct_tx_delay_factor = f;
|
||||
savePrefs();
|
||||
strcpy(reply, "OK");
|
||||
} else {
|
||||
strcpy(reply, "Error, cannot be negative");
|
||||
}
|
||||
} else if (memcmp(config, "tx ", 3) == 0) {
|
||||
_prefs.tx_power_dbm = atoi(&config[3]);
|
||||
savePrefs();
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue