mirror of
https://github.com/lora-aprs/LoRa_APRS_iGate.git
synced 2026-04-20 22:05:09 +00:00
add new features:
- turn of OLED after x sec - activate OLED with key - more LoRa settings
This commit is contained in:
parent
d3c0936c8d
commit
7bfcc0a5a5
8 changed files with 112 additions and 11 deletions
|
|
@ -1,5 +1,5 @@
|
||||||
{
|
{
|
||||||
"version":1,
|
"version":2,
|
||||||
"callsign":"NOCALL-10",
|
"callsign":"NOCALL-10",
|
||||||
"wifi":
|
"wifi":
|
||||||
{
|
{
|
||||||
|
|
@ -32,5 +32,17 @@
|
||||||
"forward_timeout":5,
|
"forward_timeout":5,
|
||||||
"beacon":true,
|
"beacon":true,
|
||||||
"beacon_timeout":30
|
"beacon_timeout":30
|
||||||
|
},
|
||||||
|
"lora":
|
||||||
|
{
|
||||||
|
"frequency_rx":433775000,
|
||||||
|
"frequency_tx":433775000,
|
||||||
|
"power":20
|
||||||
|
},
|
||||||
|
"display":
|
||||||
|
{
|
||||||
|
"always_on": true,
|
||||||
|
"timeout":10,
|
||||||
|
"overwrite_pin":0
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -12,7 +12,7 @@ lib_deps =
|
||||||
APRS-Decoder-Lib
|
APRS-Decoder-Lib
|
||||||
APRS-IS-Lib
|
APRS-IS-Lib
|
||||||
LoRa
|
LoRa
|
||||||
LoRa-APRS-Lib
|
https://github.com/lora-aprs/LoRa-APRS-Lib@0.0.4
|
||||||
NTPClient
|
NTPClient
|
||||||
ArduinoJson
|
ArduinoJson
|
||||||
AXP202X_Library
|
AXP202X_Library
|
||||||
|
|
|
||||||
|
|
@ -24,6 +24,7 @@ hw_timer_t * timer = NULL;
|
||||||
volatile uint secondsSinceLastAPRSISBeacon = 0;
|
volatile uint secondsSinceLastAPRSISBeacon = 0;
|
||||||
volatile uint secondsSinceLastDigiBeacon = 0;
|
volatile uint secondsSinceLastDigiBeacon = 0;
|
||||||
volatile uint secondsSinceStartup = 0;
|
volatile uint secondsSinceStartup = 0;
|
||||||
|
volatile uint secondsSinceDisplay = 0;
|
||||||
|
|
||||||
WiFiMulti WiFiMulti;
|
WiFiMulti WiFiMulti;
|
||||||
WiFiUDP ntpUDP;
|
WiFiUDP ntpUDP;
|
||||||
|
|
@ -82,13 +83,34 @@ void setup()
|
||||||
if(Config.aprs_is.active) setup_aprs_is();
|
if(Config.aprs_is.active) setup_aprs_is();
|
||||||
setup_timer();
|
setup_timer();
|
||||||
|
|
||||||
|
if(Config.display.overwritePin != 0)
|
||||||
|
{
|
||||||
|
pinMode(Config.display.overwritePin, INPUT);
|
||||||
|
pinMode(Config.display.overwritePin, INPUT_PULLUP);
|
||||||
|
}
|
||||||
|
|
||||||
delay(500);
|
delay(500);
|
||||||
Serial.println("setup done...");
|
Serial.println("setup done...");
|
||||||
|
secondsSinceDisplay = 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
// cppcheck-suppress unusedFunction
|
// cppcheck-suppress unusedFunction
|
||||||
void loop()
|
void loop()
|
||||||
{
|
{
|
||||||
|
static bool display_is_on = true;
|
||||||
|
if(Config.display.overwritePin != 0 && !digitalRead(Config.display.overwritePin))
|
||||||
|
{
|
||||||
|
secondsSinceDisplay = 0;
|
||||||
|
display_is_on = true;
|
||||||
|
setup_display();
|
||||||
|
} else
|
||||||
|
if(!Config.display.alwaysOn && secondsSinceDisplay > Config.display.timeout && display_is_on)
|
||||||
|
{
|
||||||
|
turn_off_display();
|
||||||
|
display_is_on = false;
|
||||||
|
Serial.println("-");
|
||||||
|
}
|
||||||
|
|
||||||
static bool beacon_aprs_is = Config.aprs_is.active && Config.aprs_is.beacon;
|
static bool beacon_aprs_is = Config.aprs_is.active && Config.aprs_is.beacon;
|
||||||
static bool beacon_digi = Config.digi.active && Config.digi.beacon;
|
static bool beacon_digi = Config.digi.active && Config.digi.beacon;
|
||||||
|
|
||||||
|
|
@ -110,6 +132,7 @@ void loop()
|
||||||
if(Config.wifi.active) ArduinoOTA.handle();
|
if(Config.wifi.active) ArduinoOTA.handle();
|
||||||
if(Config.wifi.active && WiFiMulti.run() != WL_CONNECTED)
|
if(Config.wifi.active && WiFiMulti.run() != WL_CONNECTED)
|
||||||
{
|
{
|
||||||
|
setup_display(); secondsSinceDisplay = 0; display_is_on = true;
|
||||||
Serial.println("[ERROR] WiFi not connected!");
|
Serial.println("[ERROR] WiFi not connected!");
|
||||||
show_display("ERROR", "WiFi not connected!");
|
show_display("ERROR", "WiFi not connected!");
|
||||||
delay(1000);
|
delay(1000);
|
||||||
|
|
@ -117,6 +140,7 @@ void loop()
|
||||||
}
|
}
|
||||||
if(Config.aprs_is.active && !aprs_is->connected())
|
if(Config.aprs_is.active && !aprs_is->connected())
|
||||||
{
|
{
|
||||||
|
setup_display(); secondsSinceDisplay = 0; display_is_on = true;
|
||||||
Serial.print("[INFO] connecting to server: ");
|
Serial.print("[INFO] connecting to server: ");
|
||||||
Serial.print(Config.aprs_is.server);
|
Serial.print(Config.aprs_is.server);
|
||||||
Serial.print(" on port: ");
|
Serial.print(" on port: ");
|
||||||
|
|
@ -142,6 +166,7 @@ void loop()
|
||||||
{
|
{
|
||||||
std::shared_ptr<APRSMessage> msg = lora_aprs.getMessage();
|
std::shared_ptr<APRSMessage> msg = lora_aprs.getMessage();
|
||||||
|
|
||||||
|
setup_display(); secondsSinceDisplay = 0; display_is_on = true;
|
||||||
show_display(Config.callsign, timeClient.getFormattedTime() + " LoRa", "RSSI: " + String(lora_aprs.getMessageRssi()) + ", SNR: " + String(lora_aprs.getMessageSnr()), msg->toString());
|
show_display(Config.callsign, timeClient.getFormattedTime() + " LoRa", "RSSI: " + String(lora_aprs.getMessageRssi()) + ", SNR: " + String(lora_aprs.getMessageSnr()), msg->toString());
|
||||||
Serial.print("[" + timeClient.getFormattedTime() + "] ");
|
Serial.print("[" + timeClient.getFormattedTime() + "] ");
|
||||||
Serial.print(" Received packet '");
|
Serial.print(" Received packet '");
|
||||||
|
|
@ -182,6 +207,7 @@ void loop()
|
||||||
|
|
||||||
if(foundMsg == lastMessages.end())
|
if(foundMsg == lastMessages.end())
|
||||||
{
|
{
|
||||||
|
setup_display(); secondsSinceDisplay = 0; display_is_on = true;
|
||||||
show_display(Config.callsign, "RSSI: " + String(lora_aprs.getMessageRssi()) + ", SNR: " + String(lora_aprs.getMessageSnr()), msg->toString(), 0);
|
show_display(Config.callsign, "RSSI: " + String(lora_aprs.getMessageRssi()) + ", SNR: " + String(lora_aprs.getMessageSnr()), msg->toString(), 0);
|
||||||
Serial.print("Received packet '");
|
Serial.print("Received packet '");
|
||||||
Serial.print(msg->toString());
|
Serial.print(msg->toString());
|
||||||
|
|
@ -222,19 +248,23 @@ void loop()
|
||||||
if(beacon_digi)
|
if(beacon_digi)
|
||||||
{
|
{
|
||||||
beacon_digi = false;
|
beacon_digi = false;
|
||||||
|
setup_display(); secondsSinceDisplay = 0; display_is_on = true;
|
||||||
show_display(Config.callsign, "Beacon to HF...");
|
show_display(Config.callsign, "Beacon to HF...");
|
||||||
Serial.print("[" + timeClient.getFormattedTime() + "] ");
|
Serial.print("[" + timeClient.getFormattedTime() + "] ");
|
||||||
Serial.print(BeaconMsg->encode());
|
Serial.print(BeaconMsg->encode());
|
||||||
lora_aprs.sendMessage(BeaconMsg);
|
lora_aprs.sendMessage(BeaconMsg);
|
||||||
Serial.println("finished TXing...");
|
Serial.println("finished TXing...");
|
||||||
|
show_display(Config.callsign, "Standby...");
|
||||||
}
|
}
|
||||||
if(beacon_aprs_is)
|
if(beacon_aprs_is)
|
||||||
{
|
{
|
||||||
beacon_aprs_is = false;
|
beacon_aprs_is = false;
|
||||||
|
setup_display(); secondsSinceDisplay = 0; display_is_on = true;
|
||||||
show_display(Config.callsign, "Beacon to APRS IS Server...");
|
show_display(Config.callsign, "Beacon to APRS IS Server...");
|
||||||
Serial.print("[" + timeClient.getFormattedTime() + "] ");
|
Serial.print("[" + timeClient.getFormattedTime() + "] ");
|
||||||
Serial.print(BeaconMsg->encode());
|
Serial.print(BeaconMsg->encode());
|
||||||
aprs_is->sendMessage(BeaconMsg);
|
aprs_is->sendMessage(BeaconMsg);
|
||||||
|
show_display(Config.callsign, "Standby...");
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -257,6 +287,11 @@ void load_config()
|
||||||
while (true)
|
while (true)
|
||||||
{}
|
{}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if(KEY_BUILTIN != 0 && Config.display.overwritePin == 0)
|
||||||
|
{
|
||||||
|
Config.display.overwritePin = KEY_BUILTIN;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void setup_wifi()
|
void setup_wifi()
|
||||||
|
|
@ -323,13 +358,15 @@ void setup_ota()
|
||||||
|
|
||||||
void setup_lora()
|
void setup_lora()
|
||||||
{
|
{
|
||||||
lora_aprs.tx_frequency = LORA_RX_FREQUENCY;
|
lora_aprs.rx_frequency = Config.lora.frequencyRx;
|
||||||
|
lora_aprs.tx_frequency = Config.lora.frequencyTx;
|
||||||
if (!lora_aprs.begin())
|
if (!lora_aprs.begin())
|
||||||
{
|
{
|
||||||
Serial.println("[ERROR] Starting LoRa failed!");
|
Serial.println("[ERROR] Starting LoRa failed!");
|
||||||
show_display("ERROR", "Starting LoRa failed!");
|
show_display("ERROR", "Starting LoRa failed!");
|
||||||
while (1);
|
while (1);
|
||||||
}
|
}
|
||||||
|
lora_aprs.setTxPower(Config.lora.power);
|
||||||
Serial.println("[INFO] LoRa init done!");
|
Serial.println("[INFO] LoRa init done!");
|
||||||
show_display("INFO", "LoRa init done!", 2000);
|
show_display("INFO", "LoRa init done!", 2000);
|
||||||
|
|
||||||
|
|
@ -364,6 +401,7 @@ void IRAM_ATTR onTimer()
|
||||||
secondsSinceLastAPRSISBeacon++;
|
secondsSinceLastAPRSISBeacon++;
|
||||||
secondsSinceLastDigiBeacon++;
|
secondsSinceLastDigiBeacon++;
|
||||||
secondsSinceStartup++;
|
secondsSinceStartup++;
|
||||||
|
secondsSinceDisplay++;
|
||||||
portEXIT_CRITICAL_ISR(&timerMux);
|
portEXIT_CRITICAL_ISR(&timerMux);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -37,7 +37,6 @@ Configuration ConfigurationManagement::readConfiguration()
|
||||||
file.close();
|
file.close();
|
||||||
|
|
||||||
Configuration conf;
|
Configuration conf;
|
||||||
conf.version = data["version"];
|
|
||||||
conf.callsign = data["callsign"].as<String>();
|
conf.callsign = data["callsign"].as<String>();
|
||||||
conf.wifi.active = data["wifi"]["active"];
|
conf.wifi.active = data["wifi"]["active"];
|
||||||
JsonArray aps = data["wifi"]["AP"].as<JsonArray>();
|
JsonArray aps = data["wifi"]["AP"].as<JsonArray>();
|
||||||
|
|
@ -62,6 +61,16 @@ Configuration ConfigurationManagement::readConfiguration()
|
||||||
conf.digi.beacon = data["digi"]["beacon"];
|
conf.digi.beacon = data["digi"]["beacon"];
|
||||||
conf.digi.beaconTimeout = data["digi"]["beacon_timeout"];
|
conf.digi.beaconTimeout = data["digi"]["beacon_timeout"];
|
||||||
|
|
||||||
|
if(data["version"] >= 2)
|
||||||
|
{
|
||||||
|
conf.lora.frequencyRx = data["lora"]["frequency_rx"];
|
||||||
|
conf.lora.frequencyTx = data["lora"]["frequency_tx"];
|
||||||
|
conf.lora.power = data["lora"]["power"];
|
||||||
|
conf.display.alwaysOn = data["display"]["always_on"];
|
||||||
|
conf.display.timeout = data["display"]["timeout"];
|
||||||
|
conf.display.overwritePin = data["display"]["overwrite_pin"];
|
||||||
|
}
|
||||||
|
|
||||||
return conf;
|
return conf;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -99,6 +108,12 @@ void ConfigurationManagement::writeConfiguration(Configuration conf)
|
||||||
data["digi"]["forward_timeout"] = conf.digi.forwardTimeout;
|
data["digi"]["forward_timeout"] = conf.digi.forwardTimeout;
|
||||||
data["digi"]["beacon"] = conf.digi.beacon;
|
data["digi"]["beacon"] = conf.digi.beacon;
|
||||||
data["digi"]["beacon_timeout"] = conf.digi.beaconTimeout;
|
data["digi"]["beacon_timeout"] = conf.digi.beaconTimeout;
|
||||||
|
data["lora"]["frequency_rx"] = conf.lora.frequencyRx;
|
||||||
|
data["lora"]["frequency_tx"] = conf.lora.frequencyTx;
|
||||||
|
data["lora"]["power"] = conf.lora.power;
|
||||||
|
data["display"]["always_on"] = conf.display.alwaysOn;
|
||||||
|
data["display"]["timeout"] = conf.display.timeout;
|
||||||
|
data["display"]["overwrite_pin"] = conf.display.overwritePin;
|
||||||
|
|
||||||
serializeJson(data, file);
|
serializeJson(data, file);
|
||||||
serializeJson(data, Serial);
|
serializeJson(data, Serial);
|
||||||
|
|
|
||||||
|
|
@ -59,7 +59,27 @@ public:
|
||||||
int beaconTimeout;
|
int beaconTimeout;
|
||||||
};
|
};
|
||||||
|
|
||||||
Configuration() : version(1), callsign("NOCALL-10") {};
|
class LoRa
|
||||||
|
{
|
||||||
|
public:
|
||||||
|
LoRa() : frequencyRx(433775000), frequencyTx(433775000), power(20) {}
|
||||||
|
|
||||||
|
long frequencyRx;
|
||||||
|
long frequencyTx;
|
||||||
|
int power;
|
||||||
|
};
|
||||||
|
|
||||||
|
class Display
|
||||||
|
{
|
||||||
|
public:
|
||||||
|
Display() : alwaysOn(true), timeout(10), overwritePin(0) {}
|
||||||
|
|
||||||
|
bool alwaysOn;
|
||||||
|
int timeout;
|
||||||
|
int overwritePin;
|
||||||
|
};
|
||||||
|
|
||||||
|
Configuration() : version(2), callsign("NOCALL-10") {};
|
||||||
|
|
||||||
int version;
|
int version;
|
||||||
String callsign;
|
String callsign;
|
||||||
|
|
@ -67,6 +87,8 @@ public:
|
||||||
Beacon beacon;
|
Beacon beacon;
|
||||||
APRS_IS aprs_is;
|
APRS_IS aprs_is;
|
||||||
Digi digi;
|
Digi digi;
|
||||||
|
LoRa lora;
|
||||||
|
Display display;
|
||||||
};
|
};
|
||||||
|
|
||||||
class ConfigurationManagement
|
class ConfigurationManagement
|
||||||
|
|
|
||||||
|
|
@ -21,13 +21,11 @@ void setup_display()
|
||||||
Serial.println("SSD1306 allocation failed");
|
Serial.println("SSD1306 allocation failed");
|
||||||
while (1);
|
while (1);
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
display.clearDisplay();
|
void turn_off_display()
|
||||||
display.setTextColor(WHITE);
|
{
|
||||||
display.setTextSize(1);
|
display.ssd1306_command(SSD1306_DISPLAYOFF);
|
||||||
display.setCursor(0,0);
|
|
||||||
display.print("LORA SENDER ");
|
|
||||||
display.display();
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void show_display(String header, int wait)
|
void show_display(String header, int wait)
|
||||||
|
|
|
||||||
|
|
@ -3,6 +3,7 @@
|
||||||
#define DISPLAY_H_
|
#define DISPLAY_H_
|
||||||
|
|
||||||
void setup_display();
|
void setup_display();
|
||||||
|
void turn_off_display();
|
||||||
|
|
||||||
void show_display(String header, int wait = 0);
|
void show_display(String header, int wait = 0);
|
||||||
void show_display(String header, String line1, int wait = 0);
|
void show_display(String header, String line1, int wait = 0);
|
||||||
|
|
|
||||||
15
src/pins.h
15
src/pins.h
|
|
@ -23,4 +23,19 @@
|
||||||
#define OLED_RST 25
|
#define OLED_RST 25
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
#undef KEY_BUILTIN
|
||||||
|
#if defined(TTGO_T_Beam_V0_7)
|
||||||
|
#define KEY_BUILTIN 39
|
||||||
|
#endif
|
||||||
|
|
||||||
|
#if defined(TTGO_T_Beam_V1_0)
|
||||||
|
#define KEY_BUILTIN 38
|
||||||
|
#endif
|
||||||
|
|
||||||
|
#ifndef KEY_BUILTIN
|
||||||
|
#define KEY_BUILTIN 0
|
||||||
|
#endif
|
||||||
|
|
||||||
#endif
|
#endif
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue