kopia lustrzana https://github.com/lora-aprs/LoRa_APRS_iGate
add new features:
- turn of OLED after x sec - activate OLED with key - more LoRa settingspull/11/head
rodzic
d3c0936c8d
commit
7bfcc0a5a5
|
@ -1,5 +1,5 @@
|
|||
{
|
||||
"version":1,
|
||||
"version":2,
|
||||
"callsign":"NOCALL-10",
|
||||
"wifi":
|
||||
{
|
||||
|
@ -32,5 +32,17 @@
|
|||
"forward_timeout":5,
|
||||
"beacon":true,
|
||||
"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-IS-Lib
|
||||
LoRa
|
||||
LoRa-APRS-Lib
|
||||
https://github.com/lora-aprs/LoRa-APRS-Lib@0.0.4
|
||||
NTPClient
|
||||
ArduinoJson
|
||||
AXP202X_Library
|
||||
|
|
|
@ -24,6 +24,7 @@ hw_timer_t * timer = NULL;
|
|||
volatile uint secondsSinceLastAPRSISBeacon = 0;
|
||||
volatile uint secondsSinceLastDigiBeacon = 0;
|
||||
volatile uint secondsSinceStartup = 0;
|
||||
volatile uint secondsSinceDisplay = 0;
|
||||
|
||||
WiFiMulti WiFiMulti;
|
||||
WiFiUDP ntpUDP;
|
||||
|
@ -82,13 +83,34 @@ void setup()
|
|||
if(Config.aprs_is.active) setup_aprs_is();
|
||||
setup_timer();
|
||||
|
||||
if(Config.display.overwritePin != 0)
|
||||
{
|
||||
pinMode(Config.display.overwritePin, INPUT);
|
||||
pinMode(Config.display.overwritePin, INPUT_PULLUP);
|
||||
}
|
||||
|
||||
delay(500);
|
||||
Serial.println("setup done...");
|
||||
secondsSinceDisplay = 0;
|
||||
}
|
||||
|
||||
// cppcheck-suppress unusedFunction
|
||||
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_digi = Config.digi.active && Config.digi.beacon;
|
||||
|
||||
|
@ -110,6 +132,7 @@ void loop()
|
|||
if(Config.wifi.active) ArduinoOTA.handle();
|
||||
if(Config.wifi.active && WiFiMulti.run() != WL_CONNECTED)
|
||||
{
|
||||
setup_display(); secondsSinceDisplay = 0; display_is_on = true;
|
||||
Serial.println("[ERROR] WiFi not connected!");
|
||||
show_display("ERROR", "WiFi not connected!");
|
||||
delay(1000);
|
||||
|
@ -117,6 +140,7 @@ void loop()
|
|||
}
|
||||
if(Config.aprs_is.active && !aprs_is->connected())
|
||||
{
|
||||
setup_display(); secondsSinceDisplay = 0; display_is_on = true;
|
||||
Serial.print("[INFO] connecting to server: ");
|
||||
Serial.print(Config.aprs_is.server);
|
||||
Serial.print(" on port: ");
|
||||
|
@ -142,6 +166,7 @@ void loop()
|
|||
{
|
||||
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());
|
||||
Serial.print("[" + timeClient.getFormattedTime() + "] ");
|
||||
Serial.print(" Received packet '");
|
||||
|
@ -182,6 +207,7 @@ void loop()
|
|||
|
||||
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);
|
||||
Serial.print("Received packet '");
|
||||
Serial.print(msg->toString());
|
||||
|
@ -222,19 +248,23 @@ void loop()
|
|||
if(beacon_digi)
|
||||
{
|
||||
beacon_digi = false;
|
||||
setup_display(); secondsSinceDisplay = 0; display_is_on = true;
|
||||
show_display(Config.callsign, "Beacon to HF...");
|
||||
Serial.print("[" + timeClient.getFormattedTime() + "] ");
|
||||
Serial.print(BeaconMsg->encode());
|
||||
lora_aprs.sendMessage(BeaconMsg);
|
||||
Serial.println("finished TXing...");
|
||||
show_display(Config.callsign, "Standby...");
|
||||
}
|
||||
if(beacon_aprs_is)
|
||||
{
|
||||
beacon_aprs_is = false;
|
||||
setup_display(); secondsSinceDisplay = 0; display_is_on = true;
|
||||
show_display(Config.callsign, "Beacon to APRS IS Server...");
|
||||
Serial.print("[" + timeClient.getFormattedTime() + "] ");
|
||||
Serial.print(BeaconMsg->encode());
|
||||
aprs_is->sendMessage(BeaconMsg);
|
||||
show_display(Config.callsign, "Standby...");
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -257,6 +287,11 @@ void load_config()
|
|||
while (true)
|
||||
{}
|
||||
}
|
||||
|
||||
if(KEY_BUILTIN != 0 && Config.display.overwritePin == 0)
|
||||
{
|
||||
Config.display.overwritePin = KEY_BUILTIN;
|
||||
}
|
||||
}
|
||||
|
||||
void setup_wifi()
|
||||
|
@ -323,13 +358,15 @@ void setup_ota()
|
|||
|
||||
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())
|
||||
{
|
||||
Serial.println("[ERROR] Starting LoRa failed!");
|
||||
show_display("ERROR", "Starting LoRa failed!");
|
||||
while (1);
|
||||
}
|
||||
lora_aprs.setTxPower(Config.lora.power);
|
||||
Serial.println("[INFO] LoRa init done!");
|
||||
show_display("INFO", "LoRa init done!", 2000);
|
||||
|
||||
|
@ -364,6 +401,7 @@ void IRAM_ATTR onTimer()
|
|||
secondsSinceLastAPRSISBeacon++;
|
||||
secondsSinceLastDigiBeacon++;
|
||||
secondsSinceStartup++;
|
||||
secondsSinceDisplay++;
|
||||
portEXIT_CRITICAL_ISR(&timerMux);
|
||||
}
|
||||
|
||||
|
|
|
@ -37,7 +37,6 @@ Configuration ConfigurationManagement::readConfiguration()
|
|||
file.close();
|
||||
|
||||
Configuration conf;
|
||||
conf.version = data["version"];
|
||||
conf.callsign = data["callsign"].as<String>();
|
||||
conf.wifi.active = data["wifi"]["active"];
|
||||
JsonArray aps = data["wifi"]["AP"].as<JsonArray>();
|
||||
|
@ -62,6 +61,16 @@ Configuration ConfigurationManagement::readConfiguration()
|
|||
conf.digi.beacon = data["digi"]["beacon"];
|
||||
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;
|
||||
}
|
||||
|
||||
|
@ -99,6 +108,12 @@ void ConfigurationManagement::writeConfiguration(Configuration conf)
|
|||
data["digi"]["forward_timeout"] = conf.digi.forwardTimeout;
|
||||
data["digi"]["beacon"] = conf.digi.beacon;
|
||||
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, Serial);
|
||||
|
|
|
@ -59,7 +59,27 @@ public:
|
|||
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;
|
||||
String callsign;
|
||||
|
@ -67,6 +87,8 @@ public:
|
|||
Beacon beacon;
|
||||
APRS_IS aprs_is;
|
||||
Digi digi;
|
||||
LoRa lora;
|
||||
Display display;
|
||||
};
|
||||
|
||||
class ConfigurationManagement
|
||||
|
|
|
@ -21,13 +21,11 @@ void setup_display()
|
|||
Serial.println("SSD1306 allocation failed");
|
||||
while (1);
|
||||
}
|
||||
}
|
||||
|
||||
display.clearDisplay();
|
||||
display.setTextColor(WHITE);
|
||||
display.setTextSize(1);
|
||||
display.setCursor(0,0);
|
||||
display.print("LORA SENDER ");
|
||||
display.display();
|
||||
void turn_off_display()
|
||||
{
|
||||
display.ssd1306_command(SSD1306_DISPLAYOFF);
|
||||
}
|
||||
|
||||
void show_display(String header, int wait)
|
||||
|
|
|
@ -3,6 +3,7 @@
|
|||
#define DISPLAY_H_
|
||||
|
||||
void setup_display();
|
||||
void turn_off_display();
|
||||
|
||||
void show_display(String header, 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
|
||||
#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
|
||||
|
|
Ładowanie…
Reference in New Issue