Skip to content

Commit

Permalink
first test backupDigiMode
Browse files Browse the repository at this point in the history
  • Loading branch information
richonguzman committed May 22, 2024
1 parent 35fbd7a commit 5296b19
Show file tree
Hide file tree
Showing 8 changed files with 62 additions and 40 deletions.
3 changes: 2 additions & 1 deletion data/igate_conf.json
Original file line number Diff line number Diff line change
Expand Up @@ -71,6 +71,7 @@
"externalVoltageMeasurement": false,
"externalVoltagePin": 34,
"lowPowerMode": false,
"lowVoltageCutOff": 0
"lowVoltageCutOff": 0,
"backupDigiMode": false
}
}
18 changes: 18 additions & 0 deletions data_embed/index.html
Original file line number Diff line number Diff line change
Expand Up @@ -1348,6 +1348,24 @@ <h5>
</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">
When "only" iGate Mode loses WiFi, it will change into a Digirepeater Mode and after 15 min check if WiFi available and return to "only" iGate Mode.
</div>
<input
type="checkbox"
name="other.backupDigiMode"
id="other.backupDigiMode"
class="form-check-input"
/>
<label
for="other.backupDigiMode"
class="form-label"
>Backup Digirepeater Mode</label
>
</div>
</div>
<div class="col-12">
<div class="form-check form-switch">
<div class="form-text">
Expand Down
7 changes: 2 additions & 5 deletions src/LoRa_APRS_iGate.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -46,16 +46,13 @@ int myWiFiAPSize = Config.wifiAPs.size();
WiFi_AP *currentWiFi = &Config.wifiAPs[myWiFiAPIndex];

bool isUpdatingOTA = false;
uint32_t lastScreenOn = millis();

uint32_t lastBatteryCheck = 0;
String batteryVoltage;

std::vector<ReceivedPacket> receivedPackets;

bool backUpDigiMode = false;
bool modemLoggedToAPRSIS = false;

std::vector<ReceivedPacket> receivedPackets;

String firstLine, secondLine, thirdLine, fourthLine, fifthLine, sixthLine, seventhLine;

//#define STARTUP_DELAY 5 //min
Expand Down
8 changes: 7 additions & 1 deletion src/configuration.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -105,6 +105,8 @@ void Configuration::writeFile() {
data["other"]["lowPowerMode"] = lowPowerMode;
data["other"]["lowVoltageCutOff"] = lowVoltageCutOff;

data["other"]["backupDigiMode"] = backupDigiMode;

serializeJson(data, configFile);

configFile.close();
Expand Down Expand Up @@ -174,6 +176,8 @@ bool Configuration::readFile() {
lowPowerMode = data["other"]["lowPowerMode"].as<bool>();
lowVoltageCutOff = data["other"]["lowVoltageCutOff"].as<double>();

backupDigiMode = data["other"]["backupDigiMode"].as<bool>();

int stationMode = data["stationMode"].as<int>(); // deprecated but need to specify config version

if (stationMode == 0) {
Expand Down Expand Up @@ -354,7 +358,9 @@ void Configuration::init() {
lowPowerMode = false;
lowVoltageCutOff = 0;

Serial.println("todo escrito");
backupDigiMode = false;

Serial.println("All is Written!");
}

Configuration::Configuration() {
Expand Down
39 changes: 20 additions & 19 deletions src/configuration.h
Original file line number Diff line number Diff line change
Expand Up @@ -107,30 +107,31 @@ class OTA {

class Configuration {
public:
bool reload;
String callsign;
bool reload;
String callsign;
// int stationMode; // deprecated
// String iGateComment; // deprecated
// int beaconInterval; // deprecated
// bool igateSendsLoRaBeacons; // deprecated
// bool igateRepeatsLoRaPackets; // deprecated
int rememberStationTime;
bool sendBatteryVoltage;
bool externalVoltageMeasurement;
int externalVoltagePin;
bool lowPowerMode;
double lowVoltageCutOff;
std::vector<WiFi_AP> wifiAPs;
WiFi_Auto_AP wifiAutoAP;
Beacon beacon; // new
DIGI digi;
TNC tnc; // new
APRS_IS aprs_is;
LoraModule loramodule;
Display display;
SYSLOG syslog;
BME bme;
OTA ota;
int rememberStationTime;
bool sendBatteryVoltage;
bool externalVoltageMeasurement;
int externalVoltagePin;
bool lowPowerMode;
double lowVoltageCutOff;
bool backupDigiMode;
std::vector<WiFi_AP> wifiAPs;
WiFi_Auto_AP wifiAutoAP;
Beacon beacon; // new
DIGI digi;
TNC tnc; // new
APRS_IS aprs_is;
LoraModule loramodule;
Display display;
SYSLOG syslog;
BME bme;
OTA ota;

void init();
void writeFile();
Expand Down
2 changes: 1 addition & 1 deletion src/utils.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,6 @@ extern String fourthLine;
extern String fifthLine;
extern String sixthLine;
extern String seventhLine;
extern uint32_t lastScreenOn;
extern String iGateBeaconPacket;
extern String iGateLoRaBeaconPacket;
extern std::vector<String> lastHeardStation;
Expand All @@ -39,6 +38,7 @@ extern bool backUpDigiMode;
bool statusAfterBoot = true;
bool beaconUpdate = true;
uint32_t lastBeaconTx = 0;
uint32_t lastScreenOn = millis();


namespace Utils {
Expand Down
2 changes: 2 additions & 0 deletions src/web_utils.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -182,6 +182,8 @@ namespace WEB_Utils {
Config.lowPowerMode = request->hasParam("other.lowPowerMode", true);
Config.lowVoltageCutOff = request->getParam("other.lowVoltageCutOff", true)->value().toDouble();

Config.backupDigiMode = request->hasParam("other.backupDigiMode", true);

if (Config.bme.active) {
Config.beacon.symbol = "_";
}
Expand Down
23 changes: 10 additions & 13 deletions src/wifi_utils.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -5,29 +5,26 @@
#include "display.h"
#include "utils.h"

extern Configuration Config;
extern Configuration Config;

extern uint8_t myWiFiAPIndex;
extern int myWiFiAPSize;
extern WiFi_AP *currentWiFi;
extern uint8_t myWiFiAPIndex;
extern int myWiFiAPSize;
extern WiFi_AP *currentWiFi;
extern bool backUpDigiMode;

bool WiFiConnected = false;
uint32_t WiFiAutoAPTime = millis();
bool WiFiAutoAPStarted = false;
uint32_t previousWiFiMillis = 0;
uint8_t wifiCounter = 0;
uint32_t lastBackupDigiTime = millis();

//
uint8_t wifiCounter = 0;
bool backupDigiModeActive = true;
extern bool backUpDigiMode;
uint32_t lastWiFiCheckBackupDigiMode = millis();
//

namespace WIFI_Utils {

void checkWiFi() {
if (backUpDigiMode) {
uint32_t WiFiCheck = millis() - lastWiFiCheckBackupDigiMode;
uint32_t WiFiCheck = millis() - lastBackupDigiTime;
if (WiFi.status() != WL_CONNECTED && WiFiCheck >= 15 * 60 * 1000) {
Serial.println("*** Stoping BackUp Digi Mode ***");
backUpDigiMode = false;
Expand All @@ -46,13 +43,13 @@ namespace WIFI_Utils {
WiFi.reconnect();
previousWiFiMillis = millis();

if (backupDigiModeActive) {
if (Config.backupDigiMode) {
wifiCounter++;
}
if (wifiCounter >= 2) {
Serial.println("*** Starting BackUp Digi Mode ***");
backUpDigiMode = true;
lastWiFiCheckBackupDigiMode = millis();
lastBackupDigiTime = millis();
}
}
}
Expand Down

0 comments on commit 5296b19

Please sign in to comment.