diff --git a/examples/simple_repeater/main.cpp b/examples/simple_repeater/main.cpp index c41bbee5..80cae6a6 100644 --- a/examples/simple_repeater/main.cpp +++ b/examples/simple_repeater/main.cpp @@ -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); diff --git a/examples/simple_room_server/main.cpp b/examples/simple_room_server/main.cpp index 4afa6e14..b905a7a2 100644 --- a/examples/simple_room_server/main.cpp +++ b/examples/simple_room_server/main.cpp @@ -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();