mirror of
https://github.com/meshcore-dev/MeshCore.git
synced 2026-03-30 17:05:52 +00:00
* repeater and room server, new "set repeat {on|off}" CLI command
This commit is contained in:
@@ -137,7 +137,8 @@ struct NodePrefs { // persisted to file
|
||||
char password[16];
|
||||
float freq;
|
||||
uint8_t tx_power_dbm;
|
||||
uint8_t unused[3];
|
||||
uint8_t disable_fwd;
|
||||
uint8_t unused[2];
|
||||
};
|
||||
|
||||
class MyMesh : public mesh::Mesh {
|
||||
@@ -246,11 +247,9 @@ protected:
|
||||
return _prefs.airtime_factor;
|
||||
}
|
||||
|
||||
#if ROOM_IS_ALSO_REPEATER
|
||||
bool allowPacketForward(const mesh::Packet* packet) override {
|
||||
return true; // Yes, allow packet to be forwarded
|
||||
return !_prefs.disable_fwd;
|
||||
}
|
||||
#endif
|
||||
|
||||
void onAnonDataRecv(mesh::Packet* packet, uint8_t type, const mesh::Identity& sender, uint8_t* data, size_t len) override {
|
||||
if (type == PAYLOAD_TYPE_ANON_REQ) { // received an initial request by a possible admin client (unknown at this stage)
|
||||
@@ -483,6 +482,7 @@ public:
|
||||
my_radio = &radio;
|
||||
|
||||
// defaults
|
||||
memset(&_prefs, 0, sizeof(_prefs));
|
||||
_prefs.airtime_factor = 1.0; // one half
|
||||
strncpy(_prefs.node_name, ADVERT_NAME, sizeof(_prefs.node_name)-1);
|
||||
_prefs.node_name[sizeof(_prefs.node_name)-1] = 0; // truncate if necessary
|
||||
@@ -492,7 +492,7 @@ public:
|
||||
_prefs.password[sizeof(_prefs.password)-1] = 0; // truncate if necessary
|
||||
_prefs.freq = LORA_FREQ;
|
||||
_prefs.tx_power_dbm = LORA_TX_POWER;
|
||||
memset(_prefs.unused, 0, sizeof(_prefs.unused));
|
||||
_prefs.disable_fwd = 1;
|
||||
|
||||
num_clients = 0;
|
||||
next_post_idx = 0;
|
||||
@@ -592,6 +592,10 @@ public:
|
||||
_prefs.node_name[sizeof(_prefs.node_name)-1] = 0; // truncate if nec
|
||||
savePrefs();
|
||||
strcpy(reply, "OK");
|
||||
} else if (memcmp(config, "repeat ", 7) == 0) {
|
||||
_prefs.disable_fwd = memcmp(&config[7], "off", 3) == 0;
|
||||
savePrefs();
|
||||
strcpy(reply, _prefs.disable_fwd ? "OK - repeat is now OFF" : "OK - repeat is now ON");
|
||||
} else if (memcmp(config, "lat ", 4) == 0) {
|
||||
_prefs.node_lat = atof(&config[4]);
|
||||
savePrefs();
|
||||
|
||||
Reference in New Issue
Block a user