* repeater and room server: added "set tx .." CLI command
This commit is contained in:
@@ -119,6 +119,8 @@ struct NodePrefs { // persisted to file
|
|||||||
double node_lat, node_lon;
|
double node_lat, node_lon;
|
||||||
char password[16];
|
char password[16];
|
||||||
float freq;
|
float freq;
|
||||||
|
uint8_t tx_power_dbm;
|
||||||
|
uint8_t unused[3];
|
||||||
};
|
};
|
||||||
|
|
||||||
class MyMesh : public mesh::Mesh {
|
class MyMesh : public mesh::Mesh {
|
||||||
@@ -375,9 +377,12 @@ public:
|
|||||||
strncpy(_prefs.password, ADMIN_PASSWORD, sizeof(_prefs.password)-1);
|
strncpy(_prefs.password, ADMIN_PASSWORD, sizeof(_prefs.password)-1);
|
||||||
_prefs.password[sizeof(_prefs.password)-1] = 0; // truncate if necessary
|
_prefs.password[sizeof(_prefs.password)-1] = 0; // truncate if necessary
|
||||||
_prefs.freq = LORA_FREQ;
|
_prefs.freq = LORA_FREQ;
|
||||||
|
_prefs.tx_power_dbm = LORA_TX_POWER;
|
||||||
|
memset(_prefs.unused, 0, sizeof(_prefs.unused));
|
||||||
}
|
}
|
||||||
|
|
||||||
float getFreqPref() const { return _prefs.freq; }
|
float getFreqPref() const { return _prefs.freq; }
|
||||||
|
uint8_t getTxPowerPref() const { return _prefs.tx_power_dbm; }
|
||||||
|
|
||||||
void begin(FILESYSTEM* fs) {
|
void begin(FILESYSTEM* fs) {
|
||||||
mesh::Mesh::begin();
|
mesh::Mesh::begin();
|
||||||
@@ -475,6 +480,10 @@ public:
|
|||||||
_prefs.node_lon = atof(&config[4]);
|
_prefs.node_lon = atof(&config[4]);
|
||||||
savePrefs();
|
savePrefs();
|
||||||
strcpy(reply, "OK");
|
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) {
|
} else if (sender_timestamp == 0 && memcmp(config, "freq ", 5) == 0) {
|
||||||
_prefs.freq = atof(&config[5]);
|
_prefs.freq = atof(&config[5]);
|
||||||
savePrefs();
|
savePrefs();
|
||||||
@@ -581,6 +590,9 @@ void setup() {
|
|||||||
if (LORA_FREQ != the_mesh.getFreqPref()) {
|
if (LORA_FREQ != the_mesh.getFreqPref()) {
|
||||||
radio.setFrequency(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
|
// send out initial Advertisement to the mesh
|
||||||
the_mesh.sendSelfAdvertisement(2000);
|
the_mesh.sendSelfAdvertisement(2000);
|
||||||
|
|||||||
@@ -136,6 +136,8 @@ struct NodePrefs { // persisted to file
|
|||||||
double node_lat, node_lon;
|
double node_lat, node_lon;
|
||||||
char password[16];
|
char password[16];
|
||||||
float freq;
|
float freq;
|
||||||
|
uint8_t tx_power_dbm;
|
||||||
|
uint8_t unused[3];
|
||||||
};
|
};
|
||||||
|
|
||||||
class MyMesh : public mesh::Mesh {
|
class MyMesh : public mesh::Mesh {
|
||||||
@@ -489,6 +491,8 @@ public:
|
|||||||
strncpy(_prefs.password, ADMIN_PASSWORD, sizeof(_prefs.password)-1);
|
strncpy(_prefs.password, ADMIN_PASSWORD, sizeof(_prefs.password)-1);
|
||||||
_prefs.password[sizeof(_prefs.password)-1] = 0; // truncate if necessary
|
_prefs.password[sizeof(_prefs.password)-1] = 0; // truncate if necessary
|
||||||
_prefs.freq = LORA_FREQ;
|
_prefs.freq = LORA_FREQ;
|
||||||
|
_prefs.tx_power_dbm = LORA_TX_POWER;
|
||||||
|
memset(_prefs.unused, 0, sizeof(_prefs.unused));
|
||||||
|
|
||||||
num_clients = 0;
|
num_clients = 0;
|
||||||
next_post_idx = 0;
|
next_post_idx = 0;
|
||||||
@@ -498,6 +502,7 @@ public:
|
|||||||
}
|
}
|
||||||
|
|
||||||
float getFreqPref() const { return _prefs.freq; }
|
float getFreqPref() const { return _prefs.freq; }
|
||||||
|
uint8_t getTxPowerPref() const { return _prefs.tx_power_dbm; }
|
||||||
|
|
||||||
void begin(FILESYSTEM* fs) {
|
void begin(FILESYSTEM* fs) {
|
||||||
mesh::Mesh::begin();
|
mesh::Mesh::begin();
|
||||||
@@ -595,6 +600,10 @@ public:
|
|||||||
_prefs.node_lon = atof(&config[4]);
|
_prefs.node_lon = atof(&config[4]);
|
||||||
savePrefs();
|
savePrefs();
|
||||||
strcpy(reply, "OK");
|
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) {
|
} else if (sender_timestamp == 0 && memcmp(config, "freq ", 5) == 0) {
|
||||||
_prefs.freq = atof(&config[5]);
|
_prefs.freq = atof(&config[5]);
|
||||||
savePrefs();
|
savePrefs();
|
||||||
@@ -739,6 +748,9 @@ void setup() {
|
|||||||
if (LORA_FREQ != the_mesh.getFreqPref()) {
|
if (LORA_FREQ != the_mesh.getFreqPref()) {
|
||||||
radio.setFrequency(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
|
// send out initial Advertisement to the mesh
|
||||||
the_mesh.sendSelfAdvertisement();
|
the_mesh.sendSelfAdvertisement();
|
||||||
|
|||||||
Reference in New Issue
Block a user