mirror of
https://github.com/meshcore-dev/MeshCore.git
synced 2026-04-20 22:13:47 +00:00
* repeater and room server: added "set tx .." CLI command
This commit is contained in:
parent
01fc05f496
commit
c7f9fa95e1
2 changed files with 24 additions and 0 deletions
|
|
@ -119,6 +119,8 @@ struct NodePrefs { // persisted to file
|
|||
double node_lat, node_lon;
|
||||
char password[16];
|
||||
float freq;
|
||||
uint8_t tx_power_dbm;
|
||||
uint8_t unused[3];
|
||||
};
|
||||
|
||||
class MyMesh : public mesh::Mesh {
|
||||
|
|
@ -375,9 +377,12 @@ public:
|
|||
strncpy(_prefs.password, ADMIN_PASSWORD, sizeof(_prefs.password)-1);
|
||||
_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));
|
||||
}
|
||||
|
||||
float getFreqPref() const { return _prefs.freq; }
|
||||
uint8_t getTxPowerPref() const { return _prefs.tx_power_dbm; }
|
||||
|
||||
void begin(FILESYSTEM* fs) {
|
||||
mesh::Mesh::begin();
|
||||
|
|
@ -475,6 +480,10 @@ public:
|
|||
_prefs.node_lon = atof(&config[4]);
|
||||
savePrefs();
|
||||
strcpy(reply, "OK");
|
||||
} else if (memcmp(config, "tx ", 3) == 0) {
|
||||
_prefs.tx_power_dbm = atoi(&config[3]);
|
||||
savePrefs();
|
||||
strcpy(reply, "OK - reboot to apply");
|
||||
} else if (sender_timestamp == 0 && memcmp(config, "freq ", 5) == 0) {
|
||||
_prefs.freq = atof(&config[5]);
|
||||
savePrefs();
|
||||
|
|
@ -581,6 +590,9 @@ void setup() {
|
|||
if (LORA_FREQ != the_mesh.getFreqPref()) {
|
||||
radio.setFrequency(the_mesh.getFreqPref());
|
||||
}
|
||||
if (LORA_TX_POWER != the_mesh.getTxPowerPref()) {
|
||||
radio.setOutputPower(the_mesh.getTxPowerPref());
|
||||
}
|
||||
|
||||
// send out initial Advertisement to the mesh
|
||||
the_mesh.sendSelfAdvertisement(2000);
|
||||
|
|
|
|||
|
|
@ -136,6 +136,8 @@ struct NodePrefs { // persisted to file
|
|||
double node_lat, node_lon;
|
||||
char password[16];
|
||||
float freq;
|
||||
uint8_t tx_power_dbm;
|
||||
uint8_t unused[3];
|
||||
};
|
||||
|
||||
class MyMesh : public mesh::Mesh {
|
||||
|
|
@ -489,6 +491,8 @@ public:
|
|||
strncpy(_prefs.password, ADMIN_PASSWORD, sizeof(_prefs.password)-1);
|
||||
_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));
|
||||
|
||||
num_clients = 0;
|
||||
next_post_idx = 0;
|
||||
|
|
@ -498,6 +502,7 @@ public:
|
|||
}
|
||||
|
||||
float getFreqPref() const { return _prefs.freq; }
|
||||
uint8_t getTxPowerPref() const { return _prefs.tx_power_dbm; }
|
||||
|
||||
void begin(FILESYSTEM* fs) {
|
||||
mesh::Mesh::begin();
|
||||
|
|
@ -595,6 +600,10 @@ public:
|
|||
_prefs.node_lon = atof(&config[4]);
|
||||
savePrefs();
|
||||
strcpy(reply, "OK");
|
||||
} else if (memcmp(config, "tx ", 3) == 0) {
|
||||
_prefs.tx_power_dbm = atoi(&config[3]);
|
||||
savePrefs();
|
||||
strcpy(reply, "OK - reboot to apply");
|
||||
} else if (sender_timestamp == 0 && memcmp(config, "freq ", 5) == 0) {
|
||||
_prefs.freq = atof(&config[5]);
|
||||
savePrefs();
|
||||
|
|
@ -739,6 +748,9 @@ void setup() {
|
|||
if (LORA_FREQ != the_mesh.getFreqPref()) {
|
||||
radio.setFrequency(the_mesh.getFreqPref());
|
||||
}
|
||||
if (LORA_TX_POWER != the_mesh.getTxPowerPref()) {
|
||||
radio.setOutputPower(the_mesh.getTxPowerPref());
|
||||
}
|
||||
|
||||
// send out initial Advertisement to the mesh
|
||||
the_mesh.sendSelfAdvertisement();
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue