mirror of
https://github.com/richonguzman/LoRa_APRS_iGate.git
synced 2026-02-09 09:14:19 +01:00
Beacon Freq on Digi Mode
This commit is contained in:
parent
61409ce683
commit
d334164b6f
|
|
@ -35,7 +35,8 @@
|
|||
"blacklist": "",
|
||||
"digi": {
|
||||
"mode": 0,
|
||||
"ecoMode": 0
|
||||
"ecoMode": 0,
|
||||
"beaconOnRxFreq": false
|
||||
},
|
||||
"lora": {
|
||||
"txFreq": 433775000,
|
||||
|
|
|
|||
|
|
@ -716,6 +716,21 @@
|
|||
</option>
|
||||
</select>
|
||||
</div>
|
||||
<div class="col-12 mt-3">
|
||||
<div class="form-check form-switch">
|
||||
<input
|
||||
type="checkbox"
|
||||
name="digi.beaconOnRxFreq"
|
||||
id="digi.beaconOnRxFreq"
|
||||
class="form-check-input"
|
||||
/>
|
||||
<label
|
||||
for="digi.beaconOnRxFreq"
|
||||
class="form-label"
|
||||
>Which Frequency to send Beacon: <small>(Disable: Tx Freq / Enable: Rx Freq)</small>
|
||||
</label>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
|
|
|
|||
|
|
@ -134,6 +134,7 @@ function loadSettings(settings) {
|
|||
// Digi
|
||||
document.getElementById("digi.mode").value = settings.digi.mode;
|
||||
document.getElementById("digi.ecoMode").value = settings.digi.ecoMode;
|
||||
document.getElementById("digi.beaconOnRxFreq").value = settings.digi.beaconOnRxFreq;
|
||||
|
||||
// LoRa
|
||||
document.getElementById("lora.txFreq").value = settings.lora.txFreq;
|
||||
|
|
|
|||
|
|
@ -68,6 +68,7 @@ class DIGI {
|
|||
public:
|
||||
int mode;
|
||||
int ecoMode; // 0 = Not Active | 1 = Ultra EcoMode | 2 = Not Active (WiFi OFF, Serial ON)
|
||||
bool beaconOnRxFreq;
|
||||
};
|
||||
|
||||
class LoraModule {
|
||||
|
|
|
|||
|
|
@ -23,12 +23,6 @@
|
|||
#include <Arduino.h>
|
||||
|
||||
|
||||
struct Packet25SegBuffer {
|
||||
uint32_t receivedTime;
|
||||
String station;
|
||||
String payload;
|
||||
};
|
||||
|
||||
struct LastHeardStation {
|
||||
uint32_t lastHeardTime;
|
||||
String station;
|
||||
|
|
@ -47,7 +41,7 @@ namespace STATION_Utils {
|
|||
bool check25SegBuffer(const String& station, const String& textMessage);
|
||||
void processOutputPacketBufferUltraEcoMode();
|
||||
void processOutputPacketBuffer();
|
||||
void addToOutputPacketBuffer(const String& packet);
|
||||
void addToOutputPacketBuffer(const String& packet, bool flag = false);
|
||||
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -35,7 +35,7 @@ namespace Utils {
|
|||
void processStatus();
|
||||
String getLocalIP();
|
||||
void setupDisplay();
|
||||
void activeStations();
|
||||
void showActiveStations();
|
||||
void checkBeaconInterval();
|
||||
void checkDisplayInterval();
|
||||
void validateFreqs();
|
||||
|
|
|
|||
|
|
@ -85,6 +85,7 @@ bool Configuration::writeFile() {
|
|||
#if defined(HAS_A7670)
|
||||
if (digi.ecoMode == 1) data["digi"]["ecoMode"] = 2;
|
||||
#endif
|
||||
data["digi"]["beaconOnRxFreq"] = digi.beaconOnRxFreq;
|
||||
|
||||
data["lora"]["rxFreq"] = loramodule.rxFreq;
|
||||
data["lora"]["txFreq"] = loramodule.txFreq;
|
||||
|
|
@ -242,10 +243,12 @@ bool Configuration::readFile() {
|
|||
blacklist = data["blacklist"] | "station callsign";
|
||||
|
||||
if (!data["digi"].containsKey("mode") ||
|
||||
!data["digi"].containsKey("ecoMode")) needsRewrite = true;
|
||||
!data["digi"].containsKey("ecoMode") ||
|
||||
!data["digi"].containsKey("beaconOnRxFreq")) needsRewrite = true;
|
||||
digi.mode = data["digi"]["mode"] | 0;
|
||||
digi.ecoMode = data["digi"]["ecoMode"] | 0;
|
||||
if (digi.ecoMode == 1) shouldSleepStop = false;
|
||||
digi.beaconOnRxFreq = data["digi"]["beaconOnRxFreq"] | false;
|
||||
|
||||
#if defined(HAS_A7670)
|
||||
if (digi.ecoMode == 1) digi.ecoMode = 2;
|
||||
|
|
@ -433,6 +436,7 @@ void Configuration::setDefaultValues() {
|
|||
|
||||
digi.mode = 0;
|
||||
digi.ecoMode = 0;
|
||||
digi.beaconOnRxFreq = false;
|
||||
|
||||
loramodule.txFreq = 433775000;
|
||||
loramodule.rxFreq = 433775000;
|
||||
|
|
|
|||
|
|
@ -30,6 +30,7 @@
|
|||
|
||||
extern Configuration Config;
|
||||
extern uint32_t lastRxTime;
|
||||
extern bool packetIsBeacon;
|
||||
|
||||
extern std::vector<ReceivedPacket> receivedPackets;
|
||||
|
||||
|
|
@ -143,7 +144,9 @@ namespace LoRa_Utils {
|
|||
if (!Config.loramodule.txActive) return;
|
||||
|
||||
if (Config.loramodule.txFreq != Config.loramodule.rxFreq) {
|
||||
changeFreqTx();
|
||||
if (!packetIsBeacon || (packetIsBeacon && !Config.digi.beaconOnRxFreq)) {
|
||||
changeFreqTx();
|
||||
}
|
||||
}
|
||||
|
||||
#ifdef INTERNAL_LED_PIN
|
||||
|
|
@ -165,7 +168,9 @@ namespace LoRa_Utils {
|
|||
if (Config.digi.ecoMode != 1) digitalWrite(INTERNAL_LED_PIN, LOW); // disabled in Ultra Eco Mode
|
||||
#endif
|
||||
if (Config.loramodule.txFreq != Config.loramodule.rxFreq) {
|
||||
changeFreqRx();
|
||||
if (!packetIsBeacon || (packetIsBeacon && !Config.digi.beaconOnRxFreq)) {
|
||||
changeFreqRx();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -33,13 +33,26 @@ extern bool shouldSleepLowVoltage;
|
|||
|
||||
uint32_t lastTxTime = millis();
|
||||
std::vector<LastHeardStation> lastHeardStations;
|
||||
std::vector<String> outputPacketBuffer;
|
||||
std::vector<Packet25SegBuffer> packet25SegBuffer;
|
||||
std::vector<String> blacklist;
|
||||
std::vector<String> managers;
|
||||
std::vector<LastHeardStation> lastHeardObjects;
|
||||
|
||||
struct OutputPacketBuffer {
|
||||
String packet;
|
||||
bool isBeacon;
|
||||
};
|
||||
std::vector<OutputPacketBuffer> outputPacketBuffer;
|
||||
|
||||
struct Packet25SegBuffer {
|
||||
uint32_t receivedTime;
|
||||
String station;
|
||||
String payload;
|
||||
};
|
||||
std::vector<Packet25SegBuffer> packet25SegBuffer;
|
||||
|
||||
|
||||
bool saveNewDigiEcoModeConfig = false;
|
||||
bool packetIsBeacon = false;
|
||||
|
||||
|
||||
namespace STATION_Utils {
|
||||
|
|
@ -138,7 +151,7 @@ namespace STATION_Utils {
|
|||
}
|
||||
}
|
||||
if (!stationHeard) lastHeardStations.emplace_back(LastHeardStation{millis(), station});
|
||||
Utils::activeStations();
|
||||
Utils::showActiveStations();
|
||||
}
|
||||
|
||||
bool wasHeard(const String& station) {
|
||||
|
|
@ -171,7 +184,9 @@ namespace STATION_Utils {
|
|||
size_t currentIndex = 0;
|
||||
while (currentIndex < outputPacketBuffer.size()) { // this sends all packets from output buffer
|
||||
delay(3000); // and cleans buffer to avoid sending packets with time offset
|
||||
LoRa_Utils::sendNewPacket(outputPacketBuffer[currentIndex]); // next time it wakes up
|
||||
if (outputPacketBuffer[currentIndex].isBeacon) packetIsBeacon = true;
|
||||
LoRa_Utils::sendNewPacket(outputPacketBuffer[currentIndex].packet); // next time it wakes up
|
||||
if (outputPacketBuffer[currentIndex].isBeacon) packetIsBeacon = false;
|
||||
currentIndex++;
|
||||
}
|
||||
outputPacketBuffer.clear();
|
||||
|
|
@ -190,13 +205,17 @@ namespace STATION_Utils {
|
|||
uint32_t lastRx = millis() - lastRxTime;
|
||||
uint32_t lastTx = millis() - lastTxTime;
|
||||
if (outputPacketBuffer.size() > 0 && lastTx > timeToWait && lastRx > timeToWait) {
|
||||
LoRa_Utils::sendNewPacket(outputPacketBuffer[0]);
|
||||
if (outputPacketBuffer[0].isBeacon) packetIsBeacon = true;
|
||||
LoRa_Utils::sendNewPacket(outputPacketBuffer[0].packet);
|
||||
if (outputPacketBuffer[0].isBeacon) packetIsBeacon = false;
|
||||
outputPacketBuffer.erase(outputPacketBuffer.begin());
|
||||
lastTxTime = millis();
|
||||
}
|
||||
if (shouldSleepLowVoltage) {
|
||||
while (outputPacketBuffer.size() > 0) {
|
||||
LoRa_Utils::sendNewPacket(outputPacketBuffer[0]);
|
||||
if (outputPacketBuffer[0].isBeacon) packetIsBeacon = true;
|
||||
LoRa_Utils::sendNewPacket(outputPacketBuffer[0].packet);
|
||||
if (outputPacketBuffer[0].isBeacon) packetIsBeacon = false;
|
||||
outputPacketBuffer.erase(outputPacketBuffer.begin());
|
||||
delay(4000);
|
||||
}
|
||||
|
|
@ -209,8 +228,12 @@ namespace STATION_Utils {
|
|||
}
|
||||
}
|
||||
|
||||
void addToOutputPacketBuffer(const String& packet) {
|
||||
outputPacketBuffer.push_back(packet);
|
||||
void addToOutputPacketBuffer(const String& packet, bool flag) {
|
||||
OutputPacketBuffer entry;
|
||||
entry.packet = packet;
|
||||
entry.isBeacon = flag;
|
||||
|
||||
outputPacketBuffer.push_back(entry);
|
||||
}
|
||||
|
||||
}
|
||||
|
|
@ -127,7 +127,7 @@ namespace Utils {
|
|||
seventhLine = " listening...";
|
||||
}
|
||||
|
||||
void activeStations() {
|
||||
void showActiveStations() {
|
||||
char buffer[30]; // Adjust size as needed
|
||||
sprintf(buffer, "Stations (%dmin) = %2d", Config.rememberStationTime, lastHeardStations.size());
|
||||
fourthLine = buffer;
|
||||
|
|
@ -159,7 +159,7 @@ namespace Utils {
|
|||
|
||||
STATION_Utils::deleteNotHeard();
|
||||
|
||||
activeStations();
|
||||
showActiveStations();
|
||||
|
||||
beaconPacket = iGateBeaconPacket;
|
||||
secondaryBeaconPacket = iGateLoRaBeaconPacket;
|
||||
|
|
@ -259,7 +259,7 @@ namespace Utils {
|
|||
Utils::println("-- Sending Beacon to RF --");
|
||||
displayShow(firstLine, secondLine, thirdLine, fourthLine, fifthLine, sixthLine, "SENDING DIGI BEACON", 0);
|
||||
seventhLine = " listening...";
|
||||
STATION_Utils::addToOutputPacketBuffer(secondaryBeaconPacket);
|
||||
STATION_Utils::addToOutputPacketBuffer(secondaryBeaconPacket, true);
|
||||
}
|
||||
|
||||
lastBeaconTx = millis();
|
||||
|
|
|
|||
|
|
@ -196,6 +196,7 @@ namespace WEB_Utils {
|
|||
|
||||
Config.digi.mode = getParamIntSafe("digi.mode", Config.digi.mode);
|
||||
Config.digi.ecoMode = getParamIntSafe("digi.ecoMode", Config.digi.ecoMode);
|
||||
Config.digi.beaconOnRxFreq = request->hasParam("digi.beaconOnRxFreq", true);
|
||||
|
||||
Config.loramodule.txFreq = getParamIntSafe("lora.txFreq", Config.loramodule.txFreq);
|
||||
Config.loramodule.rxFreq = getParamIntSafe("lora.rxFreq", Config.loramodule.rxFreq);
|
||||
|
|
|
|||
Loading…
Reference in a new issue