Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add Olimex ESP32-PoE-ISO Board with DIY LoRa Board #192

Open
wants to merge 4 commits into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 4 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -48,10 +48,13 @@ ____________________________________________________

- Wemos Lolin32 Oled + SX1278 DIY Version.

- Olimex ESP32-PoE-ISO Board with DIY-LoRa

<br />

## Timeline (Versions):

- 2024.11.09 Added Olimex-PoE-Iso Board with DIY-LoRa (https://github.com/dl1lmh/LoRa-Board-for-Olimex-UEXT)
- 2024.11.06 (Silent Update) Working now with Board "VARIANTS".
- 2024.10.29 Added LILYGO Lora32 T3S3 support.
- 2024.10.25 Added QRP Labs LightGateway 1.0 support.
Expand Down Expand Up @@ -123,4 +126,4 @@ ____________________________________________________

__________________________________________

# Hope You Enjoy this, 73! CA2RXU, Valparaiso, Chile
# Hope You Enjoy this, 73! CA2RXU, Valparaiso, Chile
3 changes: 3 additions & 0 deletions data/igate_conf.json
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,9 @@
},
"AP": []
},
"ethernet": {
"use_lan": false
},
"beacon": {
"latitude": 0.0,
"longitude": 0.0,
Expand Down
20 changes: 19 additions & 1 deletion data_embed/index.html
Original file line number Diff line number Diff line change
Expand Up @@ -290,8 +290,26 @@ <h5>
<small
>Add all Wi-Fi Networks intended to be used.</small
>
</div>
</div>
<div class="col-lg-9 col-sm-12">
<div class="row">
<div class="col-12">
<div class="form-check form-switch">
<input
type="checkbox"
name="ethernet.use_lan"
id="ethernet.use_lan"
class="form-check-input"
/>
<label
for="ethernet.use_lan"
class="form-label"
>Use LAN instead (Enable ONLY if LAN-Port present, deactivates WiFi!)
</label>
</div>
</div>
</div>
<br>
<input
type="hidden"
name="wifi.APs"
Expand Down
3 changes: 3 additions & 0 deletions data_embed/script.js
Original file line number Diff line number Diff line change
Expand Up @@ -134,6 +134,9 @@ function loadSettings(settings) {
document.getElementById("beacon.sendViaAPRSIS").checked = settings.beacon.sendViaAPRSIS;
document.getElementById("beacon.sendViaRF").checked = settings.beacon.sendViaRF;

// Ethernet
document.getElementById("ethernet.use_lan").checked = settings.ethernet.use_lan;

document.getElementById("beacon.gpsActive").checked = settings.beacon.gpsActive;
document.getElementById("beacon.gpsAmbiguity").checked = settings.beacon.gpsAmbiguity;

Expand Down
10 changes: 8 additions & 2 deletions src/LoRa_APRS_iGate.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,7 @@ ___________________________________________________________________*/
#include "power_utils.h"
#include "lora_utils.h"
#include "wifi_utils.h"
#include "eth_utils.h"
#include "digi_utils.h"
#include "gps_utils.h"
#include "web_utils.h"
Expand Down Expand Up @@ -66,6 +67,8 @@ uint32_t lastBatteryCheck = 0;
bool backUpDigiMode = false;
bool modemLoggedToAPRSIS = false;

extern bool EthConnected;

std::vector<ReceivedPacket> receivedPackets;

String firstLine, secondLine, thirdLine, fourthLine, fifthLine, sixthLine, seventhLine;
Expand Down Expand Up @@ -127,6 +130,7 @@ void setup() {
#endif
DIGI_Utils::checkEcoMode();
WIFI_Utils::setup();
ETH_Utils::setup();
NTP_Utils::setup();
SYSLOG_Utils::setup();
WX_Utils::setup();
Expand All @@ -152,12 +156,14 @@ void loop() {

thirdLine = Utils::getLocalIP();

WIFI_Utils::checkWiFi();
if (!Config.ethernet.use_lan) WIFI_Utils::checkWiFi();
if (Config.ethernet.use_lan) ETH_Utils::checkETH();

#ifdef HAS_A7670
if (Config.aprs_is.active && !modemLoggedToAPRSIS) A7670_Utils::APRS_IS_connect();
#else
if (Config.aprs_is.active && (WiFi.status() == WL_CONNECTED) && !espClient.connected()) APRS_IS_Utils::connect();
if (!Config.ethernet.use_lan && Config.aprs_is.active && (WiFi.status() == WL_CONNECTED) && !espClient.connected()) APRS_IS_Utils::connect();
if (Config.ethernet.use_lan && Config.aprs_is.active && EthConnected && !espClient.connected()) APRS_IS_Utils::connect();
#endif

NTP_Utils::update();
Expand Down
22 changes: 12 additions & 10 deletions src/aprs_is_utils.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@ extern String sixthLine;
extern String seventhLine;
extern bool modemLoggedToAPRSIS;
extern bool backUpDigiMode;
extern bool EthConnected;

uint32_t lastRxTime = millis();

Expand All @@ -35,7 +36,7 @@ namespace APRS_IS_Utils {
espClient.print(line + "\r\n");
}

void connect() {
void connect() {
Serial.print("Connecting to APRS-IS ... ");
uint8_t count = 0;
while (!espClient.connect(Config.aprs_is.server.c_str(), Config.aprs_is.port) && count < 20) {
Expand Down Expand Up @@ -67,14 +68,16 @@ namespace APRS_IS_Utils {
}

void checkStatus() {
String wifiState, aprsisState;
if (WiFi.status() == WL_CONNECTED) {
wifiState = "OK";
String netState, aprsisState;
if (!Config.ethernet.use_lan && (WiFi.status() == WL_CONNECTED)) {
netState = "WiFi: OK";
} else if (Config.ethernet.use_lan && EthConnected) {
netState = "LAN: OK";
} else {
if (backUpDigiMode || Config.digi.ecoMode) {
wifiState = "--";
if (backUpDigiMode || Config.digi.ecoMode || (Config.ethernet.use_lan && !EthConnected) ) {
netState = "Net: -- ";
} else {
wifiState = "AP";
netState = "WiFi: AP";
}
if (!Config.display.alwaysOn && Config.display.timeout != 0) {
displayToggle(true);
Expand All @@ -101,10 +104,9 @@ namespace APRS_IS_Utils {
if(aprsisState == "--" && !Config.display.alwaysOn && Config.display.timeout != 0) {
displayToggle(true);
lastScreenOn = millis();
}
}
}
secondLine = "WiFi: ";
secondLine += wifiState;
secondLine = netState;
secondLine += " APRS-IS: ";
secondLine += aprsisState;
}
Expand Down
6 changes: 6 additions & 0 deletions src/configuration.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,8 @@ void Configuration::writeFile() {
data["wifi"]["autoAP"]["password"] = wifiAutoAP.password;
data["wifi"]["autoAP"]["timeout"] = wifiAutoAP.timeout;

data["ethernet"]["use_lan"] = ethernet.use_lan;

data["callsign"] = callsign;

data["aprs_is"]["active"] = aprs_is.active;
Expand Down Expand Up @@ -137,6 +139,8 @@ bool Configuration::readFile() {
wifiAutoAP.password = data["wifi"]["autoAP"]["password"] | "1234567890";
wifiAutoAP.timeout = data["wifi"]["autoAP"]["timeout"] | 10;

ethernet.use_lan = data["ethernet"]["use_lan"] | false;

callsign = data["callsign"] | "NOCALL-10";
rememberStationTime = data["other"]["rememberStationTime"] | 30;

Expand Down Expand Up @@ -248,6 +252,8 @@ void Configuration::init() {
wifiAutoAP.password = "1234567890";
wifiAutoAP.timeout = 10;

ethernet.use_lan = false;

callsign = "N0CALL-10";

beacon.comment = "LoRa APRS";
Expand Down
6 changes: 6 additions & 0 deletions src/configuration.h
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,11 @@ class WiFi_Auto_AP {
int timeout;
};

class ETHERNET {
public:
bool use_lan;
};

class BEACON {
public:
double latitude;
Expand Down Expand Up @@ -137,6 +142,7 @@ class Configuration {
String personalNote;
std::vector<WiFi_AP> wifiAPs;
WiFi_Auto_AP wifiAutoAP;
ETHERNET ethernet;
BEACON beacon;
APRS_IS aprs_is;
DIGI digi;
Expand Down
122 changes: 122 additions & 0 deletions src/eth_utils.cpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,122 @@
#include <ETH.h>
#include <SPI.h>

#include "configuration.h"
#include "display.h"

extern Configuration Config;
extern bool backUpDigiMode;
extern uint32_t lastBackupDigiTime;

uint32_t previousEthMillis = 0;
uint8_t EthCounter = 0;

bool EthLink = false;
bool EthGotIP = false;
bool EthConnected = false;


namespace ETH_Utils {

void EthEvent(WiFiEvent_t event) {
String hostname = "iGate-" + Config.callsign;
switch (event) {
case ARDUINO_EVENT_ETH_START:
ETH.setHostname(hostname.c_str());
break;

case ARDUINO_EVENT_ETH_CONNECTED:
EthLink = true;
break;

case ARDUINO_EVENT_ETH_GOT_IP:
EthGotIP = true;
EthConnected = true;
break;

case ARDUINO_EVENT_ETH_DISCONNECTED:
EthConnected = false;
break;

case ARDUINO_EVENT_ETH_STOP:
EthLink = false;
EthGotIP = false;
EthConnected = false;
break;

default:
break;
}

}

void checkETH() {
if (!Config.digi.ecoMode) {
if (backUpDigiMode) {
uint32_t EthCheck = millis() - lastBackupDigiTime;
if (!EthConnected && EthCheck >= 15 * 60 * 1000) {
Serial.println("*** Stopping BackUp Digi Mode ***");
backUpDigiMode = false;
} else if (EthConnected) {
Serial.println("*** LAN Reconnect Success (Stopping Backup Digi Mode) ***");
backUpDigiMode = false;
EthCounter = 0;
}
}

if (!backUpDigiMode && !EthConnected && ((millis() - previousEthMillis) >= 30 * 1000)) {
Serial.print(millis());
Serial.println("Waiting for LAN Reconnect...");
previousEthMillis = millis();

if (Config.backupDigiMode) {
EthCounter++;
}
if (EthCounter >= 2) {
Serial.println("*** LAN lost. Starting BackUp Digi Mode ***");
backUpDigiMode = true;
lastBackupDigiTime = millis();
}
}
}
}

void startETH() {
u_int8_t counter = 0;
WiFi.onEvent(ETH_Utils::EthEvent);
displayShow("", "Connecting to LAN:", "", " ...", 0);
Serial.print("Connecting to LAN: ");
ETH.begin();
while (((EthLink && EthGotIP) == false) || (counter <= 10))
{
delay(500);
#ifdef INTERNAL_LED_PIN
digitalWrite(INTERNAL_LED_PIN,HIGH);
#endif
Serial.print('.');
delay(500);
#ifdef INTERNAL_LED_PIN
digitalWrite(INTERNAL_LED_PIN,LOW);
#endif
counter++;
}
if (EthLink && EthGotIP) EthConnected = true;
#ifdef INTERNAL_LED_PIN
digitalWrite(INTERNAL_LED_PIN,LOW);
#endif
if (EthConnected) {
Serial.print("\nConnected as ");
Serial.print(ETH.localIP());
Serial.print(" / MAC: ");
Serial.println(ETH.macAddress());
displayShow("", " LAN connected!!", "" , " loading ...", 1000);
} else {
Serial.println("\nNot connected to LAN!");
displayShow("", " LAN not connected!", "" , " loading ...", 1000);
}
}

void setup() {
if (Config.ethernet.use_lan && !Config.digi.ecoMode) startETH();
}
}
15 changes: 15 additions & 0 deletions src/eth_utils.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
#ifndef ETH_UTILS_H_
#define ETH_UTILS_H_

#include <Arduino.h>

namespace ETH_Utils {
void checkETH();
void setup();
void startETH();
void EthEvent();
}



#endif
11 changes: 8 additions & 3 deletions src/lora_utils.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,8 @@
extern Configuration Config;
extern uint32_t lastRxTime;

extern bool EthConnected;

extern std::vector<ReceivedPacket> receivedPackets;

bool operationDone = true;
Expand Down Expand Up @@ -136,7 +138,8 @@ namespace LoRa_Utils {
int state = radio.transmit("\x3c\xff\x01" + newPacket);
transmitFlag = true;
if (state == RADIOLIB_ERR_NONE) {
if (Config.syslog.active && WiFi.status() == WL_CONNECTED) {
if ((!Config.ethernet.use_lan && Config.syslog.active && WiFi.status() == WL_CONNECTED) ||
(Config.ethernet.use_lan && Config.syslog.active && EthConnected)) {
SYSLOG_Utils::log(3, newPacket, 0, 0.0, 0); // TX
}
Utils::print("---> LoRa Packet Tx : ");
Expand Down Expand Up @@ -200,7 +203,8 @@ namespace LoRa_Utils {
receivedPackets.push_back(receivedPacket);
}

if (Config.syslog.active && WiFi.status() == WL_CONNECTED) {
if ((!Config.ethernet.use_lan && Config.syslog.active && WiFi.status() == WL_CONNECTED) ||
(Config.ethernet.use_lan && Config.syslog.active && EthConnected)) {
SYSLOG_Utils::log(1, packet, rssi, snr, freqError); // RX
}
lastRxTime = millis();
Expand All @@ -211,7 +215,8 @@ namespace LoRa_Utils {
snr = radio.getSNR();
freqError = radio.getFrequencyError();
Utils::println(F("CRC error!"));
if (Config.syslog.active && WiFi.status() == WL_CONNECTED) {
if ((!Config.ethernet.use_lan && Config.syslog.active && WiFi.status() == WL_CONNECTED) ||
(Config.ethernet.use_lan && Config.syslog.active && EthConnected)) {
SYSLOG_Utils::log(0, packet, rssi, snr, freqError); // CRC
}
packet = "";
Expand Down
Loading