mirror of
https://github.com/meshcore-dev/MeshCore.git
synced 2026-03-30 14:55:46 +00:00
* repeater, room server: new prefs: sf, cr, bw. "set tx ..." now instant, no reboot needed.
This commit is contained in:
@@ -118,6 +118,7 @@ struct ClientInfo {
|
||||
class MyMesh : public mesh::Mesh, public CommonCLICallbacks {
|
||||
RadioLibWrapper* my_radio;
|
||||
FILESYSTEM* _fs;
|
||||
RADIO_CLASS* _phy;
|
||||
mesh::MainBoard* _board;
|
||||
unsigned long next_local_advert;
|
||||
bool _logging;
|
||||
@@ -466,9 +467,9 @@ protected:
|
||||
}
|
||||
|
||||
public:
|
||||
MyMesh(mesh::MainBoard& board, RadioLibWrapper& radio, mesh::MillisecondClock& ms, mesh::RNG& rng, mesh::RTCClock& rtc, SimpleMeshTables& tables)
|
||||
MyMesh(RADIO_CLASS& phy, mesh::MainBoard& board, RadioLibWrapper& radio, mesh::MillisecondClock& ms, mesh::RNG& rng, mesh::RTCClock& rtc, SimpleMeshTables& tables)
|
||||
: mesh::Mesh(radio, ms, rng, rtc, *new StaticPoolPacketManager(32), tables),
|
||||
_board(&board), _cli(board, this, &_prefs, this)
|
||||
_phy(&phy), _board(&board), _cli(board, this, &_prefs, this)
|
||||
{
|
||||
my_radio = &radio;
|
||||
memset(known_clients, 0, sizeof(known_clients));
|
||||
@@ -485,13 +486,13 @@ public:
|
||||
_prefs.node_lon = ADVERT_LON;
|
||||
StrHelper::strncpy(_prefs.password, ADMIN_PASSWORD, sizeof(_prefs.password));
|
||||
_prefs.freq = LORA_FREQ;
|
||||
_prefs.sf = LORA_SF;
|
||||
_prefs.bw = LORA_BW;
|
||||
_prefs.cr = LORA_CR;
|
||||
_prefs.tx_power_dbm = LORA_TX_POWER;
|
||||
_prefs.advert_interval = 1; // default to 2 minutes for NEW installs
|
||||
}
|
||||
|
||||
float getFreqPref() const { return _prefs.freq; }
|
||||
uint8_t getTxPowerPref() const { return _prefs.tx_power_dbm; }
|
||||
|
||||
CommonCLI* getCLI() { return &_cli; }
|
||||
|
||||
void begin(FILESYSTEM* fs) {
|
||||
@@ -506,6 +507,12 @@ public:
|
||||
}
|
||||
}
|
||||
|
||||
_phy->setFrequency(_prefs.freq);
|
||||
_phy->setSpreadingFactor(_prefs.sf);
|
||||
_phy->setBandwidth(_prefs.bw);
|
||||
_phy->setCodingRate(_prefs.cr);
|
||||
_phy->setOutputPower(_prefs.tx_power_dbm);
|
||||
|
||||
updateAdvertTimer();
|
||||
}
|
||||
|
||||
@@ -570,6 +577,10 @@ public:
|
||||
}
|
||||
}
|
||||
|
||||
void setTxPower(uint8_t power_dbm) override {
|
||||
_phy->setOutputPower(power_dbm);
|
||||
}
|
||||
|
||||
void loop() {
|
||||
mesh::Mesh::loop();
|
||||
|
||||
@@ -602,7 +613,7 @@ VolatileRTCClock fallback_clock;
|
||||
#endif
|
||||
AutoDiscoverRTCClock rtc_clock(fallback_clock);
|
||||
|
||||
MyMesh the_mesh(board, *new WRAPPER_CLASS(radio, board), *new ArduinoMillis(), fast_rng, rtc_clock, tables);
|
||||
MyMesh the_mesh(radio, board, *new WRAPPER_CLASS(radio, board), *new ArduinoMillis(), fast_rng, rtc_clock, tables);
|
||||
|
||||
void halt() {
|
||||
while (1) ;
|
||||
@@ -678,13 +689,6 @@ void setup() {
|
||||
|
||||
the_mesh.begin(fs);
|
||||
|
||||
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);
|
||||
}
|
||||
|
||||
@@ -124,6 +124,7 @@ struct PostInfo {
|
||||
class MyMesh : public mesh::Mesh, public CommonCLICallbacks {
|
||||
RadioLibWrapper* my_radio;
|
||||
FILESYSTEM* _fs;
|
||||
RADIO_CLASS* _phy;
|
||||
mesh::MainBoard* _board;
|
||||
unsigned long next_local_advert;
|
||||
NodePrefs _prefs;
|
||||
@@ -493,9 +494,9 @@ protected:
|
||||
}
|
||||
|
||||
public:
|
||||
MyMesh(mesh::MainBoard& board, RadioLibWrapper& radio, mesh::MillisecondClock& ms, mesh::RNG& rng, mesh::RTCClock& rtc, mesh::MeshTables& tables)
|
||||
MyMesh(RADIO_CLASS& phy, mesh::MainBoard& board, RadioLibWrapper& radio, mesh::MillisecondClock& ms, mesh::RNG& rng, mesh::RTCClock& rtc, mesh::MeshTables& tables)
|
||||
: mesh::Mesh(radio, ms, rng, rtc, *new StaticPoolPacketManager(32), tables),
|
||||
_board(&board), _cli(board, this, &_prefs, this)
|
||||
_phy(&phy), _board(&board), _cli(board, this, &_prefs, this)
|
||||
{
|
||||
my_radio = &radio;
|
||||
next_local_advert = 0;
|
||||
@@ -510,6 +511,9 @@ public:
|
||||
_prefs.node_lon = ADVERT_LON;
|
||||
StrHelper::strncpy(_prefs.password, ADMIN_PASSWORD, sizeof(_prefs.password));
|
||||
_prefs.freq = LORA_FREQ;
|
||||
_prefs.sf = LORA_SF;
|
||||
_prefs.bw = LORA_BW;
|
||||
_prefs.cr = LORA_CR;
|
||||
_prefs.tx_power_dbm = LORA_TX_POWER;
|
||||
_prefs.disable_fwd = 1;
|
||||
_prefs.advert_interval = 1; // default to 2 minutes for NEW installs
|
||||
@@ -524,9 +528,6 @@ public:
|
||||
memset(posts, 0, sizeof(posts));
|
||||
}
|
||||
|
||||
float getFreqPref() const { return _prefs.freq; }
|
||||
uint8_t getTxPowerPref() const { return _prefs.tx_power_dbm; }
|
||||
|
||||
CommonCLI* getCLI() { return &_cli; }
|
||||
|
||||
void begin(FILESYSTEM* fs) {
|
||||
@@ -541,6 +542,12 @@ public:
|
||||
}
|
||||
}
|
||||
|
||||
_phy->setFrequency(_prefs.freq);
|
||||
_phy->setSpreadingFactor(_prefs.sf);
|
||||
_phy->setBandwidth(_prefs.bw);
|
||||
_phy->setCodingRate(_prefs.cr);
|
||||
_phy->setOutputPower(_prefs.tx_power_dbm);
|
||||
|
||||
updateAdvertTimer();
|
||||
}
|
||||
|
||||
@@ -591,6 +598,10 @@ public:
|
||||
void eraseLogFile() override { /* no-op */ }
|
||||
void dumpLogFile() override { /* no-op */ }
|
||||
|
||||
void setTxPower(uint8_t power_dbm) override {
|
||||
_phy->setOutputPower(power_dbm);
|
||||
}
|
||||
|
||||
void loop() {
|
||||
mesh::Mesh::loop();
|
||||
|
||||
@@ -657,7 +668,7 @@ VolatileRTCClock fallback_clock;
|
||||
#endif
|
||||
AutoDiscoverRTCClock rtc_clock(fallback_clock);
|
||||
|
||||
MyMesh the_mesh(board, *new WRAPPER_CLASS(radio, board), *new ArduinoMillis(), fast_rng, rtc_clock, tables);
|
||||
MyMesh the_mesh(radio, board, *new WRAPPER_CLASS(radio, board), *new ArduinoMillis(), fast_rng, rtc_clock, tables);
|
||||
|
||||
void halt() {
|
||||
while (1) ;
|
||||
@@ -732,13 +743,6 @@ void setup() {
|
||||
|
||||
the_mesh.begin(fs);
|
||||
|
||||
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);
|
||||
}
|
||||
|
||||
@@ -168,7 +168,8 @@ void CommonCLI::handleCommand(uint32_t sender_timestamp, const char* command, ch
|
||||
} else if (memcmp(config, "tx ", 3) == 0) {
|
||||
_prefs->tx_power_dbm = atoi(&config[3]);
|
||||
savePrefs();
|
||||
strcpy(reply, "OK - reboot to apply");
|
||||
_callbacks->setTxPower(_prefs->tx_power_dbm);
|
||||
strcpy(reply, "OK");
|
||||
} else if (sender_timestamp == 0 && memcmp(config, "freq ", 5) == 0) {
|
||||
_prefs->freq = atof(&config[5]);
|
||||
savePrefs();
|
||||
|
||||
@@ -16,6 +16,11 @@ struct NodePrefs { // persisted to file
|
||||
float tx_delay_factor;
|
||||
char guest_password[16];
|
||||
float direct_tx_delay_factor;
|
||||
uint8_t sf;
|
||||
uint8_t cr;
|
||||
uint8_t reserved1;
|
||||
uint8_t reserved2;
|
||||
float bw;
|
||||
};
|
||||
|
||||
class CommonCLICallbacks {
|
||||
@@ -28,6 +33,7 @@ public:
|
||||
virtual void setLoggingOn(bool enable) = 0;
|
||||
virtual void eraseLogFile() = 0;
|
||||
virtual void dumpLogFile() = 0;
|
||||
virtual void setTxPower(uint8_t power_dbm) = 0;
|
||||
};
|
||||
|
||||
class CommonCLI {
|
||||
|
||||
Reference in New Issue
Block a user