forked from iarv/LoRa_APRS_iGate
Compare commits
1 Commits
NTP-server
...
ethernet_0
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
bf7f136e56 |
13
include/ethernet_utils.h
Normal file
13
include/ethernet_utils.h
Normal file
@@ -0,0 +1,13 @@
|
||||
#ifndef ETHERNET_UTILS_H_
|
||||
#define ETHERNET_UTILS_H_
|
||||
|
||||
#include <Arduino.h>
|
||||
|
||||
|
||||
namespace ETHERNET_Utils {
|
||||
|
||||
void setup();
|
||||
|
||||
}
|
||||
|
||||
#endif
|
||||
@@ -23,7 +23,6 @@ ___________________________________________________________________*/
|
||||
#include <ElegantOTA.h>
|
||||
#include <TinyGPS++.h>
|
||||
#include <Arduino.h>
|
||||
#include <WiFi.h>
|
||||
#include <vector>
|
||||
#include "configuration.h"
|
||||
#include "battery_utils.h"
|
||||
@@ -35,7 +34,13 @@ ___________________________________________________________________*/
|
||||
#include "query_utils.h"
|
||||
#include "power_utils.h"
|
||||
#include "lora_utils.h"
|
||||
#include "wifi_utils.h"
|
||||
#ifdef HAS_ETHERNET
|
||||
#include <Ethernet.h>
|
||||
#include "ethernet_utils.h"
|
||||
#else
|
||||
#include <WiFi.h>
|
||||
#include "wifi_utils.h"
|
||||
#endif
|
||||
#include "digi_utils.h"
|
||||
#include "gps_utils.h"
|
||||
#include "web_utils.h"
|
||||
@@ -48,9 +53,15 @@ ___________________________________________________________________*/
|
||||
#include "A7670_utils.h"
|
||||
#endif
|
||||
|
||||
String versionDate = "2025.03.03";
|
||||
String versionDate = "2025.03.06";
|
||||
Configuration Config;
|
||||
WiFiClient espClient;
|
||||
|
||||
#ifdef HAS_ETHERNET
|
||||
EthernetClient espClient;
|
||||
#else
|
||||
WiFiClient espClient;
|
||||
#endif
|
||||
|
||||
#ifdef HAS_GPS
|
||||
HardwareSerial gpsSerial(1);
|
||||
TinyGPSPlus gps;
|
||||
@@ -80,9 +91,10 @@ String firstLine, secondLine, thirdLine, fourthLine, fifthLine, sixthLine, seven
|
||||
|
||||
void setup() {
|
||||
Serial.begin(115200);
|
||||
delay(5000);
|
||||
POWER_Utils::setup();
|
||||
Utils::setupDisplay();
|
||||
LoRa_Utils::setup();
|
||||
//LoRa_Utils::setup();
|
||||
Utils::validateFreqs();
|
||||
GPS_Utils::setup();
|
||||
STATION_Utils::loadBlackList();
|
||||
@@ -133,7 +145,12 @@ void setup() {
|
||||
}
|
||||
#endif
|
||||
DIGI_Utils::checkEcoMode();
|
||||
WIFI_Utils::setup();
|
||||
#ifdef HAS_ETHERNET
|
||||
ETHERNET_Utils::setup();
|
||||
#else
|
||||
WIFI_Utils::setup();
|
||||
#endif
|
||||
LoRa_Utils::setup();
|
||||
NTP_Utils::setup();
|
||||
SYSLOG_Utils::setup();
|
||||
WX_Utils::setup();
|
||||
@@ -147,14 +164,16 @@ void setup() {
|
||||
}
|
||||
|
||||
void loop() {
|
||||
WIFI_Utils::checkAutoAPTimeout();
|
||||
#ifndef HAS_ETHERNET
|
||||
WIFI_Utils::checkAutoAPTimeout();
|
||||
#endif
|
||||
|
||||
if (isUpdatingOTA) {
|
||||
/*if (isUpdatingOTA) {
|
||||
ElegantOTA.loop();
|
||||
return; // Don't process IGate and Digi during OTA update
|
||||
}
|
||||
}*/
|
||||
|
||||
if (Config.lowVoltageCutOff > 0) {
|
||||
/*if (Config.lowVoltageCutOff > 0) {
|
||||
BATTERY_Utils::checkIfShouldSleep();
|
||||
}
|
||||
|
||||
@@ -182,8 +201,12 @@ void loop() {
|
||||
#ifdef HAS_A7670
|
||||
if (Config.aprs_is.active && !modemLoggedToAPRSIS) A7670_Utils::APRS_IS_connect();
|
||||
#else
|
||||
WIFI_Utils::checkWiFi();
|
||||
if (Config.aprs_is.active && (WiFi.status() == WL_CONNECTED) && !espClient.connected()) APRS_IS_Utils::connect();
|
||||
#ifdef HAS_ETHERNET
|
||||
if (Config.aprs_is.active && !espClient.connected()) APRS_IS_Utils::connect();
|
||||
#else
|
||||
WIFI_Utils::checkWiFi();
|
||||
if (Config.aprs_is.active && (WiFi.status() == WL_CONNECTED) && !espClient.connected()) APRS_IS_Utils::connect();
|
||||
#endif
|
||||
#endif
|
||||
|
||||
NTP_Utils::update();
|
||||
@@ -237,5 +260,5 @@ void loop() {
|
||||
#endif
|
||||
|
||||
Utils::checkRebootTime();
|
||||
Utils::checkSleepByLowBatteryVoltage(1);
|
||||
Utils::checkSleepByLowBatteryVoltage(1);*/
|
||||
}
|
||||
@@ -1,7 +1,7 @@
|
||||
#include <WiFi.h>
|
||||
#include "configuration.h"
|
||||
#include "aprs_is_utils.h"
|
||||
#include "station_utils.h"
|
||||
#include "board_pinout.h"
|
||||
#include "syslog_utils.h"
|
||||
#include "query_utils.h"
|
||||
#include "A7670_utils.h"
|
||||
@@ -10,7 +10,15 @@
|
||||
#include "utils.h"
|
||||
|
||||
extern Configuration Config;
|
||||
extern WiFiClient espClient;
|
||||
|
||||
#ifdef HAS_ETHERNET
|
||||
#include <Ethernet.h>
|
||||
extern EthernetClient espClient;
|
||||
#else
|
||||
#include <WiFi.h>
|
||||
extern WiFiClient espClient;
|
||||
#endif
|
||||
|
||||
extern uint32_t lastScreenOn;
|
||||
extern String firstLine;
|
||||
extern String secondLine;
|
||||
@@ -58,7 +66,7 @@ namespace APRS_IS_Utils {
|
||||
aprsAuth += Config.callsign;
|
||||
aprsAuth += " pass ";
|
||||
aprsAuth += Config.aprs_is.passcode;
|
||||
aprsAuth += " vers CA2RXU_LoRa_iGate 2.0 filter ";
|
||||
aprsAuth += " vers CA2RXU_LoRa_iGate 2.1 filter ";
|
||||
aprsAuth += Config.aprs_is.filter;
|
||||
upload(aprsAuth);
|
||||
}
|
||||
@@ -66,8 +74,14 @@ namespace APRS_IS_Utils {
|
||||
|
||||
void checkStatus() {
|
||||
String wifiState, aprsisState;
|
||||
if (WiFi.status() == WL_CONNECTED) {
|
||||
wifiState = "OK";
|
||||
if (true) {
|
||||
/*#ifdef HAS_ETHERNET
|
||||
if (Ethernet.linkStatus() == LinkON) {
|
||||
wifiState = "ET";
|
||||
#else
|
||||
if (WiFi.status() == WL_CONNECTED) {
|
||||
wifiState = "OK";
|
||||
#endif*/
|
||||
} else {
|
||||
if (backUpDigiMode || Config.digi.ecoMode) {
|
||||
wifiState = "--";
|
||||
@@ -362,7 +376,12 @@ namespace APRS_IS_Utils {
|
||||
}
|
||||
|
||||
void firstConnection() {
|
||||
if (Config.aprs_is.active && (WiFi.status() == WL_CONNECTED) && !espClient.connected()) {
|
||||
|
||||
//#ifdef HAS_ETHERNET
|
||||
if (Config.aprs_is.active && !espClient.connected()) {
|
||||
//#else
|
||||
// if (Config.aprs_is.active && (WiFi.status() == WL_CONNECTED) && !espClient.connected()) {
|
||||
//#endif
|
||||
connect();
|
||||
while (!passcodeValid) {
|
||||
listenAPRSIS();
|
||||
|
||||
62
src/ethernet_utils.cpp
Normal file
62
src/ethernet_utils.cpp
Normal file
@@ -0,0 +1,62 @@
|
||||
/*#include <WiFi.h>
|
||||
#include "configuration.h"
|
||||
#include "station_utils.h"
|
||||
#include "aprs_is_utils.h"
|
||||
#include "query_utils.h"
|
||||
#include "digi_utils.h"
|
||||
#include "wifi_utils.h"
|
||||
#include "lora_utils.h"
|
||||
#include "gps_utils.h"
|
||||
#include "display.h"
|
||||
#include "utils.h"*/
|
||||
#include <Ethernet.h>
|
||||
#include <SPI.h>
|
||||
#include "ethernet_utils.h"
|
||||
#include "board_pinout.h"
|
||||
|
||||
/*extern Configuration Config;
|
||||
extern uint32_t lastScreenOn;
|
||||
extern String iGateBeaconPacket;
|
||||
extern String firstLine;
|
||||
extern String secondLine;
|
||||
extern String thirdLine;
|
||||
extern String fourthLine;
|
||||
extern String fifthLine;
|
||||
extern String sixthLine;
|
||||
extern String seventhLine;
|
||||
extern bool backUpDigiMode;*/
|
||||
|
||||
|
||||
byte mac[] = {0xDE, 0xAD, 0xBE, 0xEF, 0xFE, 0xED};
|
||||
|
||||
namespace ETHERNET_Utils {
|
||||
|
||||
void setup() {
|
||||
SPI.beginTransaction(SPISettings(1000000, MSBFIRST, SPI_MODE0));
|
||||
pinMode(Ethernet_CS, OUTPUT);
|
||||
pinMode(Ethernet_MOSI, OUTPUT);
|
||||
pinMode(Ethernet_MISO, INPUT);
|
||||
pinMode(Ethernet_SCK, OUTPUT);
|
||||
SPI.endTransaction();
|
||||
Ethernet.init(Ethernet_CS);
|
||||
Ethernet.begin(mac);
|
||||
delay(1000);
|
||||
Serial.println(Ethernet.localIP());
|
||||
|
||||
delay(1000);
|
||||
Serial.println(Ethernet.linkStatus());
|
||||
delay(1000);
|
||||
Serial.println(Ethernet.linkStatus());
|
||||
delay(1000);
|
||||
Serial.println(Ethernet.linkStatus());
|
||||
delay(1000);
|
||||
Serial.println(Ethernet.linkStatus());
|
||||
delay(1000);
|
||||
if (Ethernet.linkStatus() == LinkON) {
|
||||
Serial.println("Ethernet connected...");
|
||||
} else {
|
||||
Serial.println("Ethernet not connected...");
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
22
variants/ESP32C3_DIY_Ethernet_LoRa/board_pinout.h
Normal file
22
variants/ESP32C3_DIY_Ethernet_LoRa/board_pinout.h
Normal file
@@ -0,0 +1,22 @@
|
||||
#ifndef BOARD_PINOUT_H_
|
||||
#define BOARD_PINOUT_H_
|
||||
|
||||
// LoRa Radio
|
||||
#define HAS_SX1278
|
||||
#define RADIO_SCLK_PIN 4
|
||||
#define RADIO_MISO_PIN 5
|
||||
#define RADIO_MOSI_PIN 6
|
||||
#define RADIO_CS_PIN 20
|
||||
#define RADIO_RST_PIN 3
|
||||
#define RADIO_BUSY_PIN 2
|
||||
|
||||
// Ethernet W5500
|
||||
#define HAS_ETHERNET
|
||||
#define Ethernet_SCK 4 // W5550 SCK
|
||||
#define Ethernet_MISO 5 // W5550 MI
|
||||
#define Ethernet_MOSI 6 // W5550 MO
|
||||
#define Ethernet_CS 7 // W5550 CS (CS = NSS = SS)
|
||||
//#define Ethernet_VCC 3.3v
|
||||
//#define Ethernet_GND GND
|
||||
|
||||
#endif
|
||||
10
variants/ESP32C3_DIY_Ethernet_LoRa/platformio.ini
Normal file
10
variants/ESP32C3_DIY_Ethernet_LoRa/platformio.ini
Normal file
@@ -0,0 +1,10 @@
|
||||
[env:ESP32C3_DIY_Ethernet_LoRa]
|
||||
board = esp32-c3-devkitm-1
|
||||
board_build.mcu = esp32c3
|
||||
build_flags =
|
||||
${common.build_flags}
|
||||
${common.usb_flags}
|
||||
-D ESP32C3_DIY_Ethernet_LoRa
|
||||
lib_deps =
|
||||
${common.lib_deps}
|
||||
arduino-libraries/Ethernet @ 2.0.2
|
||||
Reference in New Issue
Block a user