mirror of
https://github.com/richonguzman/LoRa_APRS_iGate.git
synced 2026-03-17 18:54:47 +01:00
feat: low power mode
This commit is contained in:
parent
a8a7c3e3a3
commit
14999d1b66
|
|
@ -65,6 +65,7 @@
|
|||
"rememberStationTime": 30,
|
||||
"sendBatteryVoltage": false,
|
||||
"externalVoltageMeasurement": false,
|
||||
"externalVoltagePin": 34
|
||||
"externalVoltagePin": 34,
|
||||
"lowPowerMode": false
|
||||
}
|
||||
}
|
||||
|
|
@ -1236,6 +1236,53 @@
|
|||
</div>
|
||||
</div>
|
||||
</div>
|
||||
<hr />
|
||||
|
||||
<div class="row my-5 d-flex align-items-top">
|
||||
<div class="col-lg-3 col-sm-12">
|
||||
<h5>
|
||||
<svg
|
||||
xmlns="http://www.w3.org/2000/svg"
|
||||
width="20"
|
||||
height="20"
|
||||
fill="currentColor"
|
||||
class="bi bi-heart-pulse-fill"
|
||||
viewBox="0 0 16 16"
|
||||
>
|
||||
<path
|
||||
d="M1.475 9C2.702 10.84 4.779 12.871 8 15c3.221-2.129 5.298-4.16 6.525-6H12a.5.5 0 0 1-.464-.314l-1.457-3.642-1.598 5.593a.5.5 0 0 1-.945.049L5.889 6.568l-1.473 2.21A.5.5 0 0 1 4 9z"
|
||||
/>
|
||||
<path
|
||||
d="M.88 8C-2.427 1.68 4.41-2 7.823 1.143q.09.083.176.171a3 3 0 0 1 .176-.17C11.59-2 18.426 1.68 15.12 8h-2.783l-1.874-4.686a.5.5 0 0 0-.945.049L7.921 8.956 6.464 5.314a.5.5 0 0 0-.88-.091L3.732 8z"
|
||||
/>
|
||||
</svg>
|
||||
Experimental
|
||||
</h5>
|
||||
<small>You can test new features. <u>Use at your own risk!</u></small>
|
||||
</div>
|
||||
<div class="col-lg-9 col-sm-12">
|
||||
<div class="row">
|
||||
<div class="col-12">
|
||||
<div class="form-check form-switch">
|
||||
<div class="form-text">
|
||||
WiFi disabled. Sleep mode. Best for solar Digi with SX126X.
|
||||
</div>
|
||||
<input
|
||||
type="checkbox"
|
||||
name="other.lowPowerMode"
|
||||
id="other.lowPowerMode"
|
||||
class="form-check-input"
|
||||
/>
|
||||
<label
|
||||
for="other.lowPowerMode"
|
||||
class="form-label"
|
||||
>Low power mode</label
|
||||
>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</main>
|
||||
<footer
|
||||
|
|
|
|||
|
|
@ -213,6 +213,9 @@ function loadSettings(settings) {
|
|||
settings.lora.codingRate4;
|
||||
document.getElementById("lora.power").value = settings.lora.power;
|
||||
|
||||
// Experimental
|
||||
document.getElementById("other.lowPowerMode").checked = settings.other.lowPowerMode;
|
||||
|
||||
updateImage();
|
||||
refreshSpeedStandard();
|
||||
toggleFields();
|
||||
|
|
|
|||
|
|
@ -75,13 +75,71 @@ void setup() {
|
|||
|
||||
Config.check();
|
||||
|
||||
WIFI_Utils::setup();
|
||||
LoRa_Utils::setup();
|
||||
Utils::validateFreqs();
|
||||
|
||||
iGateBeaconPacket = GPS_Utils::generateBeacon();
|
||||
iGateLoRaBeaconPacket = GPS_Utils::generateiGateLoRaBeacon();
|
||||
|
||||
#ifdef HELTEC_WSL
|
||||
if (Config.lowPowerMode) {
|
||||
gpio_wakeup_enable(GPIO_NUM_3, GPIO_INTR_HIGH_LEVEL);
|
||||
esp_deep_sleep_enable_gpio_wakeup(GPIO_NUM_3, ESP_GPIO_WAKEUP_GPIO_HIGH);
|
||||
|
||||
long lastBeacon = 0;
|
||||
|
||||
LoRa_Utils::startReceive();
|
||||
|
||||
while (true) {
|
||||
auto wakeup_reason = esp_sleep_get_wakeup_cause();
|
||||
|
||||
if (wakeup_reason == 7) { // packet received
|
||||
Serial.println("Received packet");
|
||||
|
||||
String packet = LoRa_Utils::receivePacket();
|
||||
|
||||
Serial.println(packet);
|
||||
|
||||
if (Config.digi.mode == 2) { // If Digi enabled
|
||||
DIGI_Utils::loop(packet); // Send received packet to Digi
|
||||
}
|
||||
|
||||
if (packet.indexOf(Config.callsign + ":STOP{") != -1) {
|
||||
Serial.println("Got STOP message, exiting from low power mode");
|
||||
break;
|
||||
};
|
||||
}
|
||||
|
||||
long time = esp_timer_get_time() / 1000000;
|
||||
|
||||
if (lastBeacon == 0 || time - lastBeacon >= Config.beacon.interval * 60) {
|
||||
Serial.println("Sending beacon");
|
||||
|
||||
LoRa_Utils::sendNewPacket("APRS", iGateLoRaBeaconPacket + Config.beacon.comment + " Batt=" + String(BATTERY_Utils::checkBattery(),2) + "V");
|
||||
|
||||
lastBeacon = time;
|
||||
}
|
||||
|
||||
LoRa_Utils::startReceive();
|
||||
|
||||
Serial.println("Sleeping");
|
||||
|
||||
long sleep = (Config.beacon.interval * 60) - (time - lastBeacon);
|
||||
|
||||
Serial.flush();
|
||||
|
||||
esp_sleep_enable_timer_wakeup(sleep * 1000000);
|
||||
esp_light_sleep_start();
|
||||
|
||||
Serial.println("Waked up");
|
||||
}
|
||||
|
||||
Config.loramodule.rxActive = false;
|
||||
}
|
||||
#endif
|
||||
|
||||
WIFI_Utils::setup();
|
||||
|
||||
SYSLOG_Utils::setup();
|
||||
BME_Utils::setup();
|
||||
WEB_Utils::setup();
|
||||
|
|
|
|||
|
|
@ -96,6 +96,8 @@ void Configuration::writeFile() {
|
|||
data["ota"]["username"] = ota.username;
|
||||
data["ota"]["password"] = ota.password;
|
||||
|
||||
data["other"]["lowPowerMode"] = lowPowerMode;
|
||||
|
||||
serializeJson(data, configFile);
|
||||
|
||||
configFile.close();
|
||||
|
|
@ -160,6 +162,8 @@ bool Configuration::readFile() {
|
|||
tnc.enableSerial = data["tnc"]["enableSerial"].as<bool>();
|
||||
tnc.acceptOwn = data["tnc"]["acceptOwn"].as<bool>();
|
||||
|
||||
lowPowerMode = data["other"]["lowPowerMode"].as<bool>();
|
||||
|
||||
int stationMode = data["stationMode"].as<int>(); // deprecated but need to specify config version
|
||||
|
||||
if (stationMode == 0) {
|
||||
|
|
@ -331,6 +335,8 @@ void Configuration::init() {
|
|||
externalVoltageMeasurement = false;
|
||||
externalVoltagePin = 34;
|
||||
|
||||
lowPowerMode = false;
|
||||
|
||||
Serial.println("todo escrito");
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -114,6 +114,7 @@ public:
|
|||
bool sendBatteryVoltage;
|
||||
bool externalVoltageMeasurement;
|
||||
int externalVoltagePin;
|
||||
bool lowPowerMode;
|
||||
std::vector<WiFi_AP> wifiAPs;
|
||||
WiFi_Auto_AP wifiAutoAP;
|
||||
Beacon beacon; // new
|
||||
|
|
|
|||
|
|
@ -63,7 +63,11 @@ namespace LoRa_Utils {
|
|||
Serial.println("Starting LoRa failed!");
|
||||
while (true);
|
||||
}
|
||||
radio.setDio1Action(setFlag);
|
||||
if (!Config.lowPowerMode) {
|
||||
radio.setDio1Action(setFlag);
|
||||
} else {
|
||||
radio.setDIOMapping(1, RADIOLIB_SX126X_IRQ_RX_DONE);
|
||||
}
|
||||
radio.setSpreadingFactor(Config.loramodule.spreadingFactor);
|
||||
float signalBandwidth = Config.loramodule.signalBandwidth/1000;
|
||||
radio.setBandwidth(signalBandwidth);
|
||||
|
|
@ -178,6 +182,12 @@ namespace LoRa_Utils {
|
|||
return packet;
|
||||
}
|
||||
|
||||
void startReceive() {
|
||||
#ifdef HAS_SX126X
|
||||
radio.startReceive();
|
||||
#endif
|
||||
}
|
||||
|
||||
String receivePacket() {
|
||||
String loraPacket = "";
|
||||
#ifdef HAS_SX127X
|
||||
|
|
@ -205,7 +215,7 @@ namespace LoRa_Utils {
|
|||
return loraPacket;
|
||||
#endif
|
||||
#ifdef HAS_SX126X
|
||||
if (transmissionFlag) {
|
||||
if (transmissionFlag || Config.lowPowerMode) {
|
||||
transmissionFlag = false;
|
||||
radio.startReceive();
|
||||
int state = radio.readData(loraPacket);
|
||||
|
|
|
|||
|
|
@ -13,6 +13,7 @@ namespace LoRa_Utils {
|
|||
String receivePacket();
|
||||
void changeFreqTx();
|
||||
void changeFreqRx();
|
||||
void startReceive();
|
||||
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -155,6 +155,8 @@ namespace WEB_Utils {
|
|||
Config.externalVoltagePin = request->getParam("other.externalVoltagePin", true)->value().toInt();
|
||||
}
|
||||
|
||||
Config.lowPowerMode = request->hasParam("other.lowPowerMode", true);
|
||||
|
||||
Config.writeFile();
|
||||
|
||||
AsyncWebServerResponse *response = request->beginResponse(302, "text/html", "");
|
||||
|
|
|
|||
Loading…
Reference in a new issue