mirror of
https://github.com/richonguzman/LoRa_APRS_iGate.git
synced 2026-03-20 12:15:21 +01:00
2
This commit is contained in:
parent
3617da4e8a
commit
51e210540b
|
|
@ -4,12 +4,16 @@
|
|||
"wifi": {
|
||||
"active": true,
|
||||
"AP": [
|
||||
{ "SSID": "Jimenicita", "password": "mg6wyMhqRnxk" },
|
||||
{ "SSID": "Richon", "password": "k4fPnmg5qnyf" }
|
||||
],
|
||||
"wifiPositions": [
|
||||
{ "latitude": -33.0312173, "longitude": -71.5795816 },
|
||||
{ "latitude": -33.0337121, "longitude": -71.5738217 }
|
||||
{ "SSID": "Jimenicita",
|
||||
"Password": "mg6wyMhqRnxk",
|
||||
"Latitude": -33.0312173,
|
||||
"Longitude": -71.5795816
|
||||
},
|
||||
{ "SSID": "Richon",
|
||||
"Password": "k4fPnmg5qnyf",
|
||||
"Latitude": -33.0337121,
|
||||
"Longitude": -71.5738217
|
||||
}
|
||||
]
|
||||
},
|
||||
"aprs_is": {
|
||||
|
|
@ -27,6 +31,6 @@
|
|||
},
|
||||
"display": {
|
||||
"always_on": true,
|
||||
"timeout": 10
|
||||
"timeout": 5
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -2,19 +2,30 @@
|
|||
#include <SPI.h>
|
||||
#include <LoRa.h>
|
||||
#include <WiFi.h>
|
||||
#include "iGate_config.h"
|
||||
#include "pins_config.h"
|
||||
#include <Wire.h>
|
||||
#include <Adafruit_GFX.h>
|
||||
#include <Adafruit_SSD1306.h>
|
||||
#include "display.h"
|
||||
#include <Wire.h>
|
||||
|
||||
#include "pins_config.h"
|
||||
#include "igate_config.h"
|
||||
#include "display.h"
|
||||
#include "iGate_config_OLD.h"
|
||||
|
||||
WiFiClient espClient;
|
||||
String ConfigurationFilePath = "/igate_conf.json";
|
||||
Configuration Config(ConfigurationFilePath);
|
||||
|
||||
|
||||
WiFiClient espClient;
|
||||
uint32_t lastTxTime = 0;
|
||||
static bool beacon_update = true;
|
||||
unsigned long previousWiFiMillis = 0;
|
||||
static uint32_t lastRxTxTime = millis();
|
||||
static bool displayEcoMode = true;
|
||||
|
||||
static int myWiFiAPIndex = 0;
|
||||
int myWiFiAPSize = Config.wifiAPs.size();
|
||||
WiFi_AP *currentWiFi = &Config.wifiAPs[myWiFiAPIndex];
|
||||
|
||||
String firstLine, secondLine, thirdLine, fourthLine;
|
||||
|
||||
void load_config() {
|
||||
|
|
@ -118,6 +129,23 @@ String process_aprsisPacket(String aprsisMessage) {
|
|||
return newLoraPacket;
|
||||
}
|
||||
|
||||
void showConfig() {
|
||||
Serial.println(myWiFiAPSize);
|
||||
Serial.println(myWiFiAPIndex);
|
||||
if(myWiFiAPIndex >= (myWiFiAPSize-1)) {
|
||||
myWiFiAPIndex = 0;
|
||||
} else {
|
||||
myWiFiAPIndex++;
|
||||
}
|
||||
Serial.println(myWiFiAPIndex);
|
||||
currentWiFi = &Config.wifiAPs[myWiFiAPIndex];
|
||||
Serial.println(currentWiFi->ssid);
|
||||
Serial.println(currentWiFi->password);
|
||||
Serial.println(currentWiFi->latitude);
|
||||
Serial.println(currentWiFi->longitude);
|
||||
Serial.println(Config.callsign);
|
||||
}
|
||||
|
||||
void setup() {
|
||||
Serial.begin(115200);
|
||||
Serial.println("Starting iGate: " + iGateCallsign + "\n");
|
||||
|
|
@ -129,7 +157,9 @@ void setup() {
|
|||
}
|
||||
|
||||
void loop() {
|
||||
String wifiState, aprsisState;
|
||||
showConfig();
|
||||
delay(2000);
|
||||
/*String wifiState, aprsisState;
|
||||
firstLine = "LoRa iGate: " + iGateCallsign;
|
||||
secondLine = " ";
|
||||
thirdLine = " ";
|
||||
|
|
@ -216,4 +246,6 @@ void loop() {
|
|||
}
|
||||
}
|
||||
}
|
||||
|
||||
*/
|
||||
}
|
||||
|
|
@ -1,32 +1,166 @@
|
|||
#ifndef IGATE_CONFIG_H_
|
||||
#define IGATE_CONFIG_H_
|
||||
#ifndef GPS_CONFIG_H_
|
||||
#define GPS_CONFIG_H_
|
||||
|
||||
#include <Arduino.h>
|
||||
#include <SPIFFS.h>
|
||||
#include <FS.h>
|
||||
#include <ArduinoJson.h>
|
||||
#include <vector>
|
||||
|
||||
#define VERSION "V.0.0.1" //MEGA BETA
|
||||
class WiFi_AP {
|
||||
public:
|
||||
String ssid;
|
||||
String password;
|
||||
double latitude;
|
||||
double longitude;
|
||||
};
|
||||
|
||||
#define WIFI_SSID "Richon"
|
||||
#define WIFI_PASSWORD "k4fPnmg5qnyf"
|
||||
class APRS_IS {
|
||||
public:
|
||||
bool active;
|
||||
int passcode;
|
||||
String server;
|
||||
int port;
|
||||
|
||||
#define BeaconInterval 900000 // 15 minutes = 900000 seg
|
||||
#define WifiCheckInterval 60000 // wificheck after one minute
|
||||
};
|
||||
|
||||
#define EcoModeDisplayTime 5000 // after 5 segs Display goes off
|
||||
class LoRa {
|
||||
public:
|
||||
long frequency;
|
||||
int spreadingFactor;
|
||||
long signalBandwidth;
|
||||
int codingRate4;
|
||||
int power;
|
||||
};
|
||||
|
||||
const String iGateCallsign = "CD2RXU-11"; // use your own iGate Callsign
|
||||
const String iGatePasscode = "23201"; // use your one iGate Callsign Passcode
|
||||
const String AprsServer = "radioaficion.pro"; // write the address of the aprs server near you , like "brazil.aprs2.net";
|
||||
const int AprsServerPort = 14580;
|
||||
const String AprsSoftwareName = "ESP32_LoRa_iGate";
|
||||
const String AprsSoftwareVersion = "0.0.9";
|
||||
const int AprsReportingDistance = 20; // kms
|
||||
const String AprsFilter = "t/m/" + iGateCallsign + "/" + (String)AprsReportingDistance;
|
||||
class Display {
|
||||
public:
|
||||
bool always_on;
|
||||
int timeout;
|
||||
};
|
||||
|
||||
const String iGateComment = "LoRa_APRS_iGate https://github.com/richonguzman/LoRa_APRS_iGate";
|
||||
class Configuration {
|
||||
public:
|
||||
|
||||
const String Latitude = "3302.02S"; // write your own iGate latitude and longitude
|
||||
const String Longitude = "07134.42W";
|
||||
String callsign;
|
||||
String comment;
|
||||
std::vector<WiFi_AP> wifiAPs;
|
||||
|
||||
String iGateBeaconPacket = iGateCallsign + ">APRS,TCPIP*,qAC,CHILE:=" + Latitude + "L" + Longitude+ "&" + iGateComment + "\n";
|
||||
Configuration(String &filePath) {
|
||||
_filePath = filePath;
|
||||
if (!SPIFFS.begin(false)) {
|
||||
Serial.println("SPIFFS Mount Failed");
|
||||
return;
|
||||
}
|
||||
readFile(SPIFFS, _filePath.c_str());
|
||||
}
|
||||
|
||||
#endif
|
||||
private:
|
||||
String _filePath;
|
||||
|
||||
void readFile(fs::FS &fs, const char *fileName) {
|
||||
StaticJsonDocument<1024> data;
|
||||
File configFile = fs.open(fileName, "r");
|
||||
DeserializationError error = deserializeJson(data, configFile);
|
||||
if (error) {
|
||||
Serial.println("Failed to read file, using default configuration");
|
||||
}
|
||||
|
||||
JsonArray WiFiArray = data["wifi"]["AP"];
|
||||
for (int i = 0; i < WiFiArray.size(); i++) {
|
||||
WiFi_AP wifiap;
|
||||
wifiap.ssid = WiFiArray[i]["SSID"].as<String>();
|
||||
wifiap.password = WiFiArray[i]["Password"].as<String>();
|
||||
wifiap.latitude = WiFiArray[i]["Latitude"].as<double>();
|
||||
wifiap.longitude = WiFiArray[i]["Longitude"].as<double>();
|
||||
|
||||
wifiAPs.push_back(wifiap);
|
||||
}
|
||||
|
||||
callsign = data["callsign"].as<String>();
|
||||
comment = data["comment"].as<String>();
|
||||
|
||||
|
||||
/*conf.aprs_is.active = data["aprs_is"]["active"];
|
||||
conf.aprs_is.passcode = data["aprs_is"]["passcode"];
|
||||
conf.aprs_is.server = data["aprs_is"]["server"];
|
||||
conf.aprs_is.port = data["aprs_is"]["port"];
|
||||
|
||||
conf.lora.port = data["lora"]["frequency"];
|
||||
conf.lora.port = data["lora"]["spreading_factor"];
|
||||
conf.lora.port = data["lora"]["signal_bandwidth"];
|
||||
conf.lora.port = data["lora"]["coding_rate4"];
|
||||
conf.lora.port = data["lora"]["power"];
|
||||
|
||||
conf.display.always_on = data["display"]["always_on"];
|
||||
conf.display.timeout = data["display"]["timeout"];*/
|
||||
|
||||
|
||||
configFile.close();
|
||||
}
|
||||
};
|
||||
#endif
|
||||
|
||||
/*class Configuration {
|
||||
public:
|
||||
/*class WiFiAccessPoint {
|
||||
public:
|
||||
class WiFiAP {
|
||||
WiFiAP(): SSID(), Password(), Latitude(), Longitude() {
|
||||
}
|
||||
std::string SSID;
|
||||
std::string Password;
|
||||
long Latitude;
|
||||
long Longitude;
|
||||
}
|
||||
|
||||
WiFiAccessPoint() : active() {
|
||||
}
|
||||
bool active;
|
||||
};*/
|
||||
|
||||
/*class APRSIS {
|
||||
public:
|
||||
APRSIS() : active(), passcode(), server(), port() {
|
||||
}
|
||||
bool active;
|
||||
int passcode;
|
||||
String server;
|
||||
int port;
|
||||
|
||||
};
|
||||
|
||||
class LoRa {
|
||||
public:
|
||||
LoRa() : frequency(), power(), spreadingFactor(), signalBandwidth(), codingRate4() {
|
||||
}
|
||||
long frequency;
|
||||
int spreadingFactor;
|
||||
long signalBandwidth;
|
||||
int codingRate4;
|
||||
int power;
|
||||
};
|
||||
|
||||
class Display {
|
||||
public:
|
||||
Display() : always_on(), timeout() {
|
||||
}
|
||||
bool always_on;
|
||||
int timeout;
|
||||
};
|
||||
|
||||
|
||||
Configuration() : callsign(), comment() {
|
||||
}
|
||||
|
||||
String callsign;
|
||||
String comment;
|
||||
/// WIFI
|
||||
std::list<Beacon> beacons;
|
||||
///
|
||||
WiFiAccessPioint wifiap;
|
||||
APRSIS aprsis;
|
||||
LoRa lora;
|
||||
Display display;
|
||||
|
||||
};*/
|
||||
32
src/iGate_config_OLD.h
Normal file
32
src/iGate_config_OLD.h
Normal file
|
|
@ -0,0 +1,32 @@
|
|||
#ifndef IGATE_CONFIG_H_
|
||||
#define IGATE_CONFIG_H_
|
||||
|
||||
#include <Arduino.h>
|
||||
|
||||
#define VERSION "V.0.0.1" //MEGA BETA
|
||||
|
||||
#define WIFI_SSID "Richon"
|
||||
#define WIFI_PASSWORD "k4fPnmg5qnyf"
|
||||
|
||||
#define BeaconInterval 900000 // 15 minutes = 900000 seg
|
||||
#define WifiCheckInterval 60000 // wificheck after one minute
|
||||
|
||||
#define EcoModeDisplayTime 5000 // after 5 segs Display goes off
|
||||
|
||||
const String iGateCallsign = "CD2RXU-11"; // use your own iGate Callsign
|
||||
const String iGatePasscode = "23201"; // use your one iGate Callsign Passcode
|
||||
const String AprsServer = "radioaficion.pro"; // write the address of the aprs server near you , like "brazil.aprs2.net";
|
||||
const int AprsServerPort = 14580;
|
||||
const String AprsSoftwareName = "ESP32_LoRa_iGate";
|
||||
const String AprsSoftwareVersion = "0.0.9";
|
||||
const int AprsReportingDistance = 20; // kms
|
||||
const String AprsFilter = "t/m/" + iGateCallsign + "/" + (String)AprsReportingDistance;
|
||||
|
||||
const String iGateComment = "LoRa_APRS_iGate https://github.com/richonguzman/LoRa_APRS_iGate";
|
||||
|
||||
const String Latitude = "3302.02S"; // write your own iGate latitude and longitude
|
||||
const String Longitude = "07134.42W";
|
||||
|
||||
String iGateBeaconPacket = iGateCallsign + ">APRS,TCPIP*,qAC,CHILE:=" + Latitude + "L" + Longitude+ "&" + iGateComment + "\n";
|
||||
|
||||
#endif
|
||||
72
src/igate_config.cpp
Normal file
72
src/igate_config.cpp
Normal file
|
|
@ -0,0 +1,72 @@
|
|||
#include "igate_config.h"
|
||||
/*#include "Arduino.h"
|
||||
#include <SPIFFS.h>
|
||||
#include <FS.h>
|
||||
#include <ArduinoJson.h>
|
||||
#include <vector>
|
||||
|
||||
/*class WiFi_AP {
|
||||
public:
|
||||
String ssid;
|
||||
String password;
|
||||
double latitude;
|
||||
double longitude;
|
||||
};
|
||||
|
||||
class Configuration {
|
||||
public:
|
||||
//std::vector<WiFi_AP> wifiAPs;
|
||||
|
||||
Configuration(String &filePath) {
|
||||
_filePath = filePath;
|
||||
if (!SPIFFS.begin(false)) {
|
||||
Serial.println("SPIFFS Mount Failed");
|
||||
return;
|
||||
}
|
||||
readFile(SPIFFS, _filePath.c_str());
|
||||
}
|
||||
|
||||
private:
|
||||
String _filePath;
|
||||
|
||||
void readFile(fs::FS &fs, const char *fileName) {
|
||||
StaticJsonDocument<1024> data;
|
||||
File configFile = fs.open(fileName, "r");
|
||||
DeserializationError error = deserializeJson(data, configFile);
|
||||
if (error) {
|
||||
Serial.println("Failed to read file, using default configuration");
|
||||
}
|
||||
|
||||
Configuration conf;
|
||||
|
||||
conf.callsign = data["callsign"];
|
||||
conf.comment = data["comment"];
|
||||
|
||||
JsonArray WiFiArray = doc["wifi"]["AP"];
|
||||
for (int i = 0; i < WiFiArray.size(); i++) {
|
||||
WiFi_AP wifi;
|
||||
wifi.ssid = WiFiArray[i]["wifi"]["AP"]["SSID"].as<String>();
|
||||
wifi.password = WiFiArray[i]["wifi"]["AP"]["Password"].as<String>();
|
||||
wifi.latitude = WiFiArray[i]["wifi"]["AP"]["Latitude"].as<double>();
|
||||
wifi.longitude = WiFiArray[i]["wifi"]["AP"]["Longitude"].as<double>();
|
||||
|
||||
conf.wifiAPs.push_back(wifi);
|
||||
}
|
||||
|
||||
conf.aprs_is.active = data["aprs_is"]["active"];
|
||||
conf.aprs_is.passcode = data["aprs_is"]["passcode"];
|
||||
conf.aprs_is.server = data["aprs_is"]["server"];
|
||||
conf.aprs_is.port = data["aprs_is"]["port"];
|
||||
|
||||
conf.lora.port = data["lora"]["frequency"];
|
||||
conf.lora.port = data["lora"]["spreading_factor"];
|
||||
conf.lora.port = data["lora"]["signal_bandwidth"];
|
||||
conf.lora.port = data["lora"]["coding_rate4"];
|
||||
conf.lora.port = data["lora"]["power"];
|
||||
|
||||
conf.display.always_on = data["display"]["always_on"];
|
||||
conf.display.timeout = data["display"]["timeout"];
|
||||
|
||||
configFile.close();
|
||||
}
|
||||
}*/
|
||||
|
|
@ -10,7 +10,10 @@
|
|||
#define LORA_RST 23 // GPIO14 - SX1276 RST
|
||||
#define LORA_IRQ 26 // GPIO26 - SX1276 IRQ ---->DIO0
|
||||
|
||||
/*
|
||||
#define OLED_SDA 21
|
||||
#define OLED_SCL 22
|
||||
|
||||
/* (Same pins for LILYGO LoRa32 and ESP32 Wroom Dev )
|
||||
SX1278-------------------> ESP32 TTGO LILYGO 2.1 or 1.6.1
|
||||
GND GND
|
||||
DIO1 -
|
||||
|
|
@ -25,8 +28,4 @@ DIO0 26
|
|||
REST 14
|
||||
GND -
|
||||
*/
|
||||
|
||||
#define OLED_SDA 21
|
||||
#define OLED_SCL 22
|
||||
|
||||
#endif
|
||||
|
|
|
|||
Loading…
Reference in a new issue